SOLR-1385 Add an 'enable' attribute to all plugins

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@809512 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Noble Paul 2009-08-31 09:16:41 +00:00
parent d827172faf
commit 4114447c8f
5 changed files with 131 additions and 4 deletions

View File

@ -288,7 +288,9 @@ New Features
73. SOLR-1156: Sort TermsComponent results by frequency (Matt Weber via yonik)
74. SOLR-1384 : load core properties from a properties file (noble)
74. SOLR-1335 : load core properties from a properties file (noble)
75. SOLR-1385 : Add an 'enable' attribute to all plugins (noble)
Optimizations
----------------------

View File

@ -74,4 +74,9 @@ public class PluginInfo {
return sb.toString();
}
public boolean isEnabled(){
String enable = attributes.get("enable");
return enable == null || Boolean.parseBoolean(enable);
}
}

View File

@ -231,7 +231,8 @@ public class SolrConfig extends Config {
}
ArrayList<PluginInfo> result = new ArrayList<PluginInfo>();
for (int j=0; j<nl.getLength(); j++) {
result.add(new PluginInfo(nl.item(j) ,"[solrconfig.xml] processor",false));
PluginInfo pluginInfo = new PluginInfo(nl.item(j), "[solrconfig.xml] processor", false);
if(pluginInfo.isEnabled()) result.add(pluginInfo);
}
chains.put(name,result);
if(isDefault || nodes.getLength() == 1) chains.put(null,result);
@ -248,7 +249,8 @@ public class SolrConfig extends Config {
private PluginInfo loadSinglePlugin(String tag){
NodeList nodes = (NodeList) evaluate(tag, XPathConstants.NODESET);
for (int i=0; i<nodes.getLength(); i++) {
return new PluginInfo(nodes.item(i) ,"[solrconfig.xml] "+tag,false);
PluginInfo pluginInfo = new PluginInfo(nodes.item(i), "[solrconfig.xml] " + tag, false);
return pluginInfo.isEnabled() ? pluginInfo : null;
}
return null;
}
@ -257,7 +259,8 @@ public class SolrConfig extends Config {
ArrayList<PluginInfo> result = new ArrayList<PluginInfo>();
NodeList nodes = (NodeList) evaluate(tag, XPathConstants.NODESET);
for (int i=0; i<nodes.getLength(); i++) {
result.add(new PluginInfo(nodes.item(i) ,"[solrconfig.xml] "+tag,requireName));
PluginInfo pluginInfo = new PluginInfo(nodes.item(i), "[solrconfig.xml] " + tag, requireName);
if(pluginInfo.isEnabled()) result.add(pluginInfo);
}
return result.isEmpty() ?
Collections.<PluginInfo>emptyList() :

View File

@ -0,0 +1,33 @@
package org.apache.solr;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.util.AbstractSolrTestCase;
/**
* <p> Test disabling components</p>
* @version $Id:$
* @since solr 1.4
*/
public class TestPluginEnable extends AbstractSolrTestCase {
public void testSimple() throws SolrServerException {
assertNull( h.getCore().getRequestHandler("disabled"));
assertNotNull( h.getCore().getRequestHandler("enabled"));
}
@Override
public String getSchemaFile() {
return "schema-replication1.xml";
}
@Override
public String getSolrConfigFile() {
return "solrconfig-enableplugin.xml";
}
}

View File

@ -0,0 +1,84 @@
<?xml version="1.0" ?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- $Id: solrconfig-slave.xml 741684 2009-02-06 19:21:44Z shalin $
$Source$
$Name$
-->
<config>
<dataDir>${solr.data.dir:./solr/data}</dataDir>
<indexDefaults>
<useCompoundFile>false</useCompoundFile>
<mergeFactor>10</mergeFactor>
<ramBufferSizeMB>32</ramBufferSizeMB>
<maxMergeDocs>2147483647</maxMergeDocs>
<maxFieldLength>10000</maxFieldLength>
<writeLockTimeout>1000</writeLockTimeout>
<commitLockTimeout>10000</commitLockTimeout>
<writeLockTimeout>1000</writeLockTimeout>
<commitLockTimeout>10000</commitLockTimeout>
<lockType>single</lockType>
</indexDefaults>
<mainIndex>
<useCompoundFile>false</useCompoundFile>
<mergeFactor>10</mergeFactor>
<ramBufferSizeMB>32</ramBufferSizeMB>
<maxMergeDocs>2147483647</maxMergeDocs>
<maxFieldLength>10000</maxFieldLength>
<unlockOnStartup>true</unlockOnStartup>
</mainIndex>
<updateHandler class="solr.DirectUpdateHandler2">
</updateHandler>
<requestHandler name="standard" class="solr.StandardRequestHandler">
<bool name="httpCaching">true</bool>
</requestHandler>
<!-- test query parameter defaults -->
<requestHandler name="defaults" class="solr.StandardRequestHandler">
</requestHandler>
<requestHandler name="disabled" class="solr.StandardRequestHandler" enable="false"/>
<requestHandler name="enabled" class="solr.StandardRequestHandler" enable="true"/>
<!-- test query parameter defaults -->
<requestHandler name="lazy" class="solr.StandardRequestHandler" startup="lazy">
</requestHandler>
<requestHandler name="/update" class="solr.XmlUpdateRequestHandler"/>
<!-- enable streaming for testing... -->
<requestDispatcher handleSelect="true">
<requestParsers enableRemoteStreaming="true" multipartUploadLimitInKB="2048"/>
<httpCaching lastModifiedFrom="openTime" etagSeed="Solr" never304="false">
<cacheControl>max-age=30, public</cacheControl>
</httpCaching>
</requestDispatcher>
</config>