SOLR-918 follow up -- Remove synchronization when iterating over infoRegistry and update Javadocs

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@727944 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2008-12-19 06:37:28 +00:00
parent d495237c0e
commit 3ea8440652
3 changed files with 30 additions and 30 deletions

View File

@ -238,6 +238,10 @@ public final class SolrCore implements SolrInfoMBean {
} }
/** /**
* Returns a Map of name vs SolrInfoMBean objects. The returned map is an instance of
* a ConcurrentHashMap and therefore no synchronization is needed for putting, removing
* or iterating over it.
*
* @return the Info Registry map which contains SolrInfoMBean objects keyed by name * @return the Info Registry map which contains SolrInfoMBean objects keyed by name
* @since solr 1.3 * @since solr 1.3
*/ */

View File

@ -59,36 +59,34 @@ public class PluginInfoHandler extends RequestHandlerBase
SimpleOrderedMap<Object> category = new SimpleOrderedMap<Object>(); SimpleOrderedMap<Object> category = new SimpleOrderedMap<Object>();
list.add( cat.name(), category ); list.add( cat.name(), category );
Map<String, SolrInfoMBean> reg = core.getInfoRegistry(); Map<String, SolrInfoMBean> reg = core.getInfoRegistry();
synchronized(reg) { for (Map.Entry<String,SolrInfoMBean> entry : reg.entrySet()) {
for (Map.Entry<String,SolrInfoMBean> entry : reg.entrySet()) { SolrInfoMBean m = entry.getValue();
SolrInfoMBean m = entry.getValue(); if (m.getCategory() != cat) continue;
if (m.getCategory() != cat) continue;
String na = "Not Declared";
String na = "Not Declared"; SimpleOrderedMap<Object> info = new SimpleOrderedMap<Object>();
SimpleOrderedMap<Object> info = new SimpleOrderedMap<Object>(); category.add( entry.getKey(), info );
category.add( entry.getKey(), info );
info.add( "name", (m.getName() !=null ? m.getName() : na) );
info.add( "name", (m.getName() !=null ? m.getName() : na) ); info.add( "version", (m.getVersion() !=null ? m.getVersion() : na) );
info.add( "version", (m.getVersion() !=null ? m.getVersion() : na) ); info.add( "description", (m.getDescription()!=null ? m.getDescription() : na) );
info.add( "description", (m.getDescription()!=null ? m.getDescription() : na) );
info.add( "sourceId", (m.getSourceId() !=null ? m.getSourceId() : na) );
info.add( "sourceId", (m.getSourceId() !=null ? m.getSourceId() : na) ); info.add( "source", (m.getSource() !=null ? m.getSource() : na) );
info.add( "source", (m.getSource() !=null ? m.getSource() : na) );
URL[] urls = m.getDocs();
URL[] urls = m.getDocs(); if ((urls != null) && (urls.length > 0)) {
if ((urls != null) && (urls.length > 0)) { ArrayList<String> docs = new ArrayList<String>(urls.length);
ArrayList<String> docs = new ArrayList<String>(urls.length); for( URL u : urls ) {
for( URL u : urls ) { docs.add( u.toExternalForm() );
docs.add( u.toExternalForm() );
}
info.add( "docs", docs );
}
if( stats ) {
info.add( "stats", m.getStatistics() );
} }
info.add( "docs", docs );
} }
}
if( stats ) {
info.add( "stats", m.getStatistics() );
}
}
} }
return list; return list;
} }

View File

@ -40,7 +40,6 @@ for (SolrInfoMBean.Category cat : SolrInfoMBean.Category.values()) {
<<%= cat.toString() %>> <<%= cat.toString() %>>
<% <%
Map<String,SolrInfoMBean> reg = core.getInfoRegistry(); Map<String,SolrInfoMBean> reg = core.getInfoRegistry();
synchronized(reg) {
for (Map.Entry<String,SolrInfoMBean> entry : reg.entrySet()) { for (Map.Entry<String,SolrInfoMBean> entry : reg.entrySet()) {
String key = entry.getKey(); String key = entry.getKey();
SolrInfoMBean m = entry.getValue(); SolrInfoMBean m = entry.getValue();
@ -84,7 +83,6 @@ for (SolrInfoMBean.Category cat : SolrInfoMBean.Category.values()) {
%> %>
<% <%
} }
}
%> %>
</<%= cat.toString() %>> </<%= cat.toString() %>>
<% <%