You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ho...@apache.org on 2013/04/17 23:13:21 UTC
svn commit: r1469073 - in /lucene/dev/trunk/solr: ./
core/src/java/org/apache/solr/handler/ webapp/web/css/styles/
webapp/web/js/scripts/ webapp/web/tpl/
Author: hossman
Date: Wed Apr 17 21:13:20 2013
New Revision: 1469073
URL: http://svn.apache.org/r1469073
Log:
SOLR-4661: Admin UI Replication details now correctly displays the current replicable generation/version of the master
Modified:
lucene/dev/trunk/solr/CHANGES.txt
lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
lucene/dev/trunk/solr/webapp/web/css/styles/replication.css
lucene/dev/trunk/solr/webapp/web/js/scripts/dashboard.js
lucene/dev/trunk/solr/webapp/web/js/scripts/replication.js
lucene/dev/trunk/solr/webapp/web/tpl/dashboard.html
lucene/dev/trunk/solr/webapp/web/tpl/replication.html
Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1469073&r1=1469072&r2=1469073&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Wed Apr 17 21:13:20 2013
@@ -224,6 +224,9 @@ Bug Fixes
code is not something Solr itself returned -- eg: from the Servlet Container,
or an intermediate HTTP Proxy (hossman)
+* SOLR-4661: Admin UI Replication details now correctly displays the current
+ replicable generation/version of the master. (hossman)
+
Optimizations
----------------------
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java?rev=1469073&r1=1469072&r2=1469073&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java Wed Apr 17 21:13:20 2013
@@ -78,7 +78,7 @@ import org.slf4j.LoggerFactory;
/**
* <p> A Handler which provides a REST API for replication and serves replication requests from Slaves. <p/> </p>
- * <p>When running on the master, it provides the following commands <ol> <li>Get the current replicatable index version
+ * <p>When running on the master, it provides the following commands <ol> <li>Get the current replicable index version
* (command=indexversion)</li> <li>Get the list of files for a given index version
* (command=filelist&indexversion=<VERSION>)</li> <li>Get full or a part (chunk) of a given index or a config
* file (command=filecontent&file=<FILE_NAME>) You can optionally specify an offset and length to get that
@@ -96,6 +96,38 @@ public class ReplicationHandler extends
private static final Logger LOG = LoggerFactory.getLogger(ReplicationHandler.class.getName());
SolrCore core;
+ private static final class CommitVersionInfo {
+ public final long version;
+ public final long generation;
+ private CommitVersionInfo(long g, long v) {
+ generation = g;
+ version = v;
+ }
+ /**
+ * builds a CommitVersionInfo data for the specified IndexCommit.
+ * Will never be null, ut version and generation may be zero if
+ * there are problems extracting them from the commit data
+ */
+ public static CommitVersionInfo build(IndexCommit commit) {
+ long generation = commit.getGeneration();
+ long version = 0;
+ try {
+ final Map<String,String> commitData = commit.getUserData();
+ String commitTime = commitData.get(SolrIndexWriter.COMMIT_TIME_MSEC_KEY);
+ if (commitTime != null) {
+ try {
+ version = Long.parseLong(commitTime);
+ } catch (NumberFormatException e) {
+ LOG.warn("Version in commitData was not formated correctly: " + commitTime, e);
+ }
+ }
+ } catch (IOException e) {
+ LOG.warn("Unable to get version from commitData, commit: " + commit, e);
+ }
+ return new CommitVersionInfo(generation, version);
+ }
+ }
+
private SnapPuller snapPuller;
private ReentrantLock snapPullLock = new ReentrantLock();
@@ -501,23 +533,20 @@ public class ReplicationHandler extends
return "$URL$";
}
- private long[] getIndexVersion() {
- long version[] = new long[2];
+ /**
+ * returns the CommitVersionInfo for the current searcher, or null on error.
+ */
+ private CommitVersionInfo getIndexVersion() {
+ CommitVersionInfo v = null;
RefCounted<SolrIndexSearcher> searcher = core.getSearcher();
try {
- final IndexCommit commit = searcher.get().getIndexReader().getIndexCommit();
- final Map<String,String> commitData = commit.getUserData();
- String commitTime = commitData.get(SolrIndexWriter.COMMIT_TIME_MSEC_KEY);
- if (commitTime != null) {
- version[0] = Long.parseLong(commitTime);
- }
- version[1] = commit.getGeneration();
+ v = CommitVersionInfo.build(searcher.get().getIndexReader().getIndexCommit());
} catch (IOException e) {
- LOG.warn("Unable to get index version : ", e);
+ LOG.warn("Unable to get index commit: ", e);
} finally {
searcher.decref();
}
- return version;
+ return v;
}
@Override
@@ -526,9 +555,9 @@ public class ReplicationHandler extends
NamedList list = super.getStatistics();
if (core != null) {
list.add("indexSize", NumberUtils.readableSize(getIndexSize()));
- long[] versionGen = getIndexVersion();
- list.add("indexVersion", versionGen[0]);
- list.add(GENERATION, versionGen[1]);
+ CommitVersionInfo vInfo = getIndexVersion();
+ list.add("indexVersion", null == vInfo ? 0 : vInfo.version);
+ list.add(GENERATION, null == vInfo ? 0 : vInfo.generation);
list.add("indexPath", core.getIndexDir());
list.add("isMaster", String.valueOf(isMaster));
@@ -582,10 +611,10 @@ public class ReplicationHandler extends
details.add(CMD_SHOW_COMMITS, getCommits());
details.add("isMaster", String.valueOf(isMaster));
details.add("isSlave", String.valueOf(isSlave));
- long[] versionAndGeneration = getIndexVersion();
- details.add("indexVersion", versionAndGeneration[0]);
- details.add(GENERATION, versionAndGeneration[1]);
-
+ CommitVersionInfo vInfo = getIndexVersion();
+ details.add("indexVersion", null == vInfo ? 0 : vInfo.version);
+ details.add(GENERATION, null == vInfo ? 0 : vInfo.generation);
+
IndexCommit commit = indexCommitPoint; // make a copy so it won't change
if (isMaster) {
@@ -595,7 +624,9 @@ public class ReplicationHandler extends
}
if (isMaster && commit != null) {
- master.add("replicatableGeneration", commit.getGeneration());
+ CommitVersionInfo repCommitInfo = CommitVersionInfo.build(commit);
+ master.add("replicableVersion", repCommitInfo.version);
+ master.add("replicableGeneration", repCommitInfo.generation);
}
SnapPuller snapPuller = tempSnapPuller;
Modified: lucene/dev/trunk/solr/webapp/web/css/styles/replication.css
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/webapp/web/css/styles/replication.css?rev=1469073&r1=1469072&r2=1469073&view=diff
==============================================================================
--- lucene/dev/trunk/solr/webapp/web/css/styles/replication.css (original)
+++ lucene/dev/trunk/solr/webapp/web/css/styles/replication.css Wed Apr 17 21:13:20 2013
@@ -283,6 +283,7 @@
#content #replication #details table
{
+ margin-left: 20px;
border-collapse: collapse;
}
@@ -339,6 +340,7 @@
{
padding-right: 10px;
text-align: right;
+ white-space: nowrap;
}
#content #replication #details table tbody .size
Modified: lucene/dev/trunk/solr/webapp/web/js/scripts/dashboard.js
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/webapp/web/js/scripts/dashboard.js?rev=1469073&r1=1469072&r2=1469073&view=diff
==============================================================================
--- lucene/dev/trunk/solr/webapp/web/js/scripts/dashboard.js (original)
+++ lucene/dev/trunk/solr/webapp/web/js/scripts/dashboard.js Wed Apr 17 21:13:20 2013
@@ -256,7 +256,8 @@ sammy.get
var is_slave = 'undefined' !== typeof( data.slave );
var headline = $( 'h2 span', this );
var details_element = $( '#details', this );
- var current_type_element = $( ( is_slave ? '.slave' : '.master' ), this );
+ var current_type_element = $( ( is_slave ? '.slave' : '.masterSearch' ), this );
+ var master_data = is_slave ? data.slave.masterDetails : data;
if( is_slave )
{
@@ -275,6 +276,7 @@ sammy.get
.html( headline.html() + ' (Master)' );
}
+ // the currently searchable commit regardless of type
$( '.version div', current_type_element )
.html( data.indexVersion );
$( '.generation div', current_type_element )
@@ -282,9 +284,18 @@ sammy.get
$( '.size div', current_type_element )
.html( data.indexSize );
+ // what's replicable on the master
+ var master_element = $( '.master', details_element );
+ $( '.version div', master_element )
+ .html( master_data.master.replicableVersion || '-' );
+ $( '.generation div', master_element )
+ .html( master_data.master.replicableGeneration || '-' );
+ $( '.size div', master_element )
+ .html( "-" );
+
if( is_slave )
{
- var master_element = $( '.master', details_element );
+ var master_element = $( '.masterSearch', details_element );
$( '.version div', master_element )
.html( data.slave.masterDetails.indexVersion );
$( '.generation div', master_element )
@@ -292,7 +303,8 @@ sammy.get
$( '.size div', master_element )
.html( data.slave.masterDetails.indexSize );
- if( data.indexVersion !== data.slave.masterDetails.indexVersion )
+ // warnings if slave version|gen doesn't match what's replicable
+ if( data.indexVersion !== master_data.master.replicableVersion )
{
$( '.version', details_element )
.addClass( 'diff' );
@@ -303,7 +315,7 @@ sammy.get
.removeClass( 'diff' );
}
- if( data.generation !== data.slave.masterDetails.generation )
+ if( data.generation !== master_data.master.replicableGeneration )
{
$( '.generation', details_element )
.addClass( 'diff' );
Modified: lucene/dev/trunk/solr/webapp/web/js/scripts/replication.js
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/webapp/web/js/scripts/replication.js?rev=1469073&r1=1469072&r2=1469073&view=diff
==============================================================================
--- lucene/dev/trunk/solr/webapp/web/js/scripts/replication.js (original)
+++ lucene/dev/trunk/solr/webapp/web/js/scripts/replication.js Wed Apr 17 21:13:20 2013
@@ -246,26 +246,39 @@ var replication_fetch_status = function(
}
var details_element = $( '#details', replication_element );
- var current_type_element = $( ( is_slave ? '.slave' : '.master' ), details_element );
+ var current_type_element = $( ( is_slave ? '.slave' : '.masterSearch' ), details_element );
+ var master_data = is_slave ? data.slave.masterDetails : data;
+ // the currently searchable commit regardless of type
$( '.version div', current_type_element )
.html( data.indexVersion );
$( '.generation div', current_type_element )
.html( data.generation );
$( '.size div', current_type_element )
.html( data.indexSize );
+
+ // what's replicable on the master
+ var master_element = $( '.master', details_element );
+ $( '.version div', master_element )
+ .html( master_data.master.replicableVersion || '-' );
+ $( '.generation div', master_element )
+ .html( master_data.master.replicableGeneration || '-' );
+ $( '.size div', master_element )
+ .html( "-" );
if( is_slave )
{
- var master_element = $( '.master', details_element );
- $( '.version div', master_element )
- .html( data.slave.masterDetails.indexVersion );
- $( '.generation div', master_element )
- .html( data.slave.masterDetails.generation );
- $( '.size div', master_element )
- .html( data.slave.masterDetails.indexSize );
-
- if( data.indexVersion !== data.slave.masterDetails.indexVersion )
+ // what's searchable on the master
+ var master_searchable = $( '.masterSearch', details_element );
+ $( '.version div', master_searchable )
+ .html( master_data.indexVersion );
+ $( '.generation div', master_searchable )
+ .html( master_data.generation );
+ $( '.size div', master_searchable )
+ .html( master_data.indexSize );
+
+ // warnings if slave version|gen doesn't match what's replicable
+ if( data.indexVersion !== master_data.master.replicableVersion )
{
$( '.version', details_element )
.addClass( 'diff' );
@@ -276,7 +289,7 @@ var replication_fetch_status = function(
.removeClass( 'diff' );
}
- if( data.generation !== data.slave.masterDetails.generation )
+ if( data.generation !== master_data.master.replicableGeneration )
{
$( '.generation', details_element )
.addClass( 'diff' );
@@ -511,4 +524,4 @@ sammy.get
}
);
}
-);
\ No newline at end of file
+);
Modified: lucene/dev/trunk/solr/webapp/web/tpl/dashboard.html
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/webapp/web/tpl/dashboard.html?rev=1469073&r1=1469072&r2=1469073&view=diff
==============================================================================
--- lucene/dev/trunk/solr/webapp/web/tpl/dashboard.html (original)
+++ lucene/dev/trunk/solr/webapp/web/tpl/dashboard.html Wed Apr 17 21:13:20 2013
@@ -103,9 +103,18 @@ limitations under the License.
</thead>
<tbody>
+ <tr class="masterSearch">
+
+ <th>Master (Searching)</th>
+ <td class="version"><div>x</div></td>
+ <td class="generation"><div>y</div></td>
+ <td class="size"><div>z</div></td>
+
+ </tr>
+
<tr class="master">
- <th>Master:</th>
+ <th>Master (Replicable)</th>
<td class="version"><div>x</div></td>
<td class="generation"><div>y</div></td>
<td class="size"><div>z</div></td>
@@ -114,7 +123,7 @@ limitations under the License.
<tr class="slave slaveOnly">
- <th>Slave:</th>
+ <th>Slave (Searching)</th>
<td class="version"><div>a</div></td>
<td class="generation"><div>c</div></td>
<td class="size"><div>c</div></td>
Modified: lucene/dev/trunk/solr/webapp/web/tpl/replication.html
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/webapp/web/tpl/replication.html?rev=1469073&r1=1469072&r2=1469073&view=diff
==============================================================================
--- lucene/dev/trunk/solr/webapp/web/tpl/replication.html (original)
+++ lucene/dev/trunk/solr/webapp/web/tpl/replication.html Wed Apr 17 21:13:20 2013
@@ -116,9 +116,18 @@ limitations under the License.
</thead>
<tbody>
+ <tr class="masterSearch">
+
+ <th>Master (Searching)</th>
+ <td class="version"><div></div></td>
+ <td class="generation"><div></div></td>
+ <td class="size"><div></div></td>
+
+ </tr>
+
<tr class="master">
- <th>Master:</th>
+ <th>Master (Replicable)</th>
<td class="version"><div></div></td>
<td class="generation"><div></div></td>
<td class="size"><div></div></td>
@@ -127,7 +136,7 @@ limitations under the License.
<tr class="slave slaveOnly">
- <th>Slave:</th>
+ <th>Slave (Searching)</th>
<td class="version"><div></div></td>
<td class="generation"><div></div></td>
<td class="size"><div></div></td>
@@ -204,4 +213,4 @@ limitations under the License.
</div>
-</div>
\ No newline at end of file
+</div>