SOLR-350 -- dropping 'default' core usage and requiring the core name in the URL. Also fixes broken admin links (SOLR-441)

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@606335 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Ryan McKinley 2007-12-21 22:23:39 +00:00
parent 873bf03839
commit 0841e7ea33
25 changed files with 444 additions and 448 deletions

View File

@ -37,6 +37,9 @@ public interface SolrServer
// A general method to allow various methods
NamedList<Object> request( final SolrRequest request ) throws SolrServerException, IOException;
void setDefaultCore( String core );
String getDefaultCore();
// Standard methods
UpdateResponse add( SolrInputDocument doc ) throws SolrServerException, IOException;
UpdateResponse add( Collection<SolrInputDocument> docs ) throws SolrServerException, IOException;

View File

@ -96,19 +96,29 @@ public class EmbeddedSolrServer extends BaseSolrServer
SolrCore core = this.core;
MultiCore multicore = MultiCore.getRegistry();
if( useMultiCore ) {
String c = getDefaultCore();
if( request.getCore() != null ) {
c = request.getCore();
}
if( c != null ) {
if( !multicore.isEnabled() ) {
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,
"multicore access is not enabled" );
}
core = multicore.getCore( request.getCore() );
if( c.length() > 0 ) {
core = multicore.getCore( c );
}
else {
core = multicore.getDefaultCore();
}
if( core == null ) {
throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,
"Unknown core: "+request.getCore() );
"Unknown core: "+c );
}
}
else {
core = multicore.getDefaultCore();
throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,
"missing core" );
}
}

View File

@ -37,7 +37,9 @@ import org.apache.solr.common.params.SolrParams;
* @version $Id$
* @since solr 1.3
*/
public abstract class BaseSolrServer implements SolrServer {
public abstract class BaseSolrServer implements SolrServer
{
protected String defaultCore = null;
public UpdateResponse add(Collection<SolrInputDocument> docs, boolean overwrite ) throws SolrServerException, IOException {
UpdateRequest req = new UpdateRequest();
@ -98,4 +100,12 @@ public abstract class BaseSolrServer implements SolrServer {
public QueryResponse query(SolrParams params) throws SolrServerException {
return new QueryRequest( params ).process( this );
}
public String getDefaultCore() {
return defaultCore;
}
public void setDefaultCore(String defaultCore) {
this.defaultCore = defaultCore;
}
}

View File

@ -121,8 +121,12 @@ public class CommonsHttpSolrServer extends BaseSolrServer
}
// modify the path for multicore access
String core = getDefaultCore();
if( request.getCore() != null ) {
path = "/@"+request.getCore()+path;
core= request.getCore();
}
if( core != null && core.length() > 0 ) {
path = "/"+core+path;
}
if( params == null ) {

View File

@ -49,11 +49,21 @@ public class MultiCoreRequest extends RequestBase
super( METHOD.GET, path );
}
public final void setCoreParam( String v )
{
this.core = v;
}
@Override
public final void setCore( String v )
{
this.core = v;
// this does not change the path!
throw new UnsupportedOperationException( "MultiCoreRequest does not use a core.");
}
@Override
public final String getCore()
{
return ""; // force it to invalid core
}
//---------------------------------------------------------------------------------------
@ -100,18 +110,10 @@ public class MultiCoreRequest extends RequestBase
//
//---------------------------------------------------------------------------------------
public static MultiCoreResponse setDefault( String name, SolrServer server ) throws SolrServerException, IOException
{
MultiCoreRequest req = new MultiCoreRequest();
req.setCore( name );
req.setAction( MultiCoreAction.SETASDEFAULT );
return req.process( server );
}
public static MultiCoreResponse reloadCore( String name, SolrServer server ) throws SolrServerException, IOException
{
MultiCoreRequest req = new MultiCoreRequest();
req.setCore( name );
req.setCoreParam( name );
req.setAction( MultiCoreAction.RELOAD );
return req.process( server );
}
@ -119,8 +121,8 @@ public class MultiCoreRequest extends RequestBase
public static MultiCoreResponse getStatus( String name, SolrServer server ) throws SolrServerException, IOException
{
MultiCoreRequest req = new MultiCoreRequest();
req.setCoreParam( name );
req.setAction( MultiCoreAction.STATUS );
req.setCore( name );
return req.process( server );
}
}

View File

@ -17,16 +17,12 @@
package org.apache.solr.client.solrj;
import org.apache.solr.client.solrj.request.LukeRequest;
import org.apache.solr.client.solrj.request.MultiCoreRequest;
import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.client.solrj.request.UpdateRequest.ACTION;
import org.apache.solr.client.solrj.response.LukeResponse;
import org.apache.solr.client.solrj.response.MultiCoreResponse;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.NamedList;
/**
@ -44,9 +40,6 @@ public abstract class MultiCoreExampleTestBase extends SolrExampleTestBase
public void testMultiCore() throws Exception
{
SolrServer solr = getSolrServer();
MultiCoreRequest.setDefault( "core1", solr );
MultiCoreRequest.setDefault( "core0", solr );
UpdateRequest up = new UpdateRequest();
up.setAction( ACTION.COMMIT, true, true );
@ -101,9 +94,11 @@ public abstract class MultiCoreExampleTestBase extends SolrExampleTestBase
assertEquals( 0, r.process( solr ).getResults().size() );
// Now test Changing the default core
solr.setDefaultCore( "core0" );
assertEquals( 1, solr.query( new SolrQuery( "id:AAA" ) ).getResults().size() );
assertEquals( 0, solr.query( new SolrQuery( "id:BBB" ) ).getResults().size() );
MultiCoreRequest.setDefault( "core1", solr );
solr.setDefaultCore( "core1" );
assertEquals( 0, solr.query( new SolrQuery( "id:AAA" ) ).getResults().size() );
assertEquals( 1, solr.query( new SolrQuery( "id:BBB" ) ).getResults().size() );

View File

@ -27,6 +27,6 @@
sharedLib: path to a lib files that will be shared across all cores
-->
<multicore adminPath="/admin/multicore" persistent="true" >
<core name="core0" instanceDir="core0" default="true"/>
<core name="core1" instanceDir="core1" />
<core name="core0" instanceDir="core0" default="true"/>
<core name="core1" instanceDir="core1" />
</multicore>

View File

@ -28,6 +28,9 @@ public interface MultiCoreParams
/** Persistent -- should it save the multicore state? **/
public final static String PERSISTENT = "persistent";
/** The name of the the core to swap names with **/
public final static String WITH = "with";
/** What action **/
public final static String ACTION = "action";
@ -37,7 +40,7 @@ public interface MultiCoreParams
LOAD,
UNLOAD,
RELOAD,
SETASDEFAULT;
SWAP;
public static MultiCoreAction get( String p )
{

View File

@ -20,7 +20,6 @@ package org.apache.solr.core;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@ -125,7 +124,7 @@ public class MultiCore
"multicore.xml defines multiple default cores. "+
getDefaultCore().getName() + " and " + core.getName() );
}
this.setDefaultCore( core );
defaultCore = core;
hasDefault = true;
}
}
@ -171,9 +170,13 @@ public class MultiCore
throw new RuntimeException( "Can not register a null core." );
}
String name = core.getName();
if( name == null || name.length() == 0 ) {
throw new RuntimeException( "Invalid core name." );
if( name == null ||
name.length() < 1 ||
name.indexOf( '/' ) >= 0 ||
name.indexOf( '\\' ) >= 0 ){
throw new RuntimeException( "Invalid core name: "+name );
}
SolrCore old = cores.put(name, core);
if( old == null ) {
log.info( "registering core: "+name );
@ -183,6 +186,21 @@ public class MultiCore
return old;
}
public void swap(SolrCore c0, SolrCore c1) {
if( c0 == null || c1 == null ) {
throw new RuntimeException( "Can not swap a null core." );
}
synchronized( cores ) {
String n0 = c0.getName();
String n1 = c1.getName();
cores.put(n0, c1);
cores.put(n1, c0);
c0.setName( n1 );
c1.setName( n0 );
}
log.info( "swaped: "+c0.getName() + " with " + c1.getName() );
}
/**
* While the new core is loading, requests will continue to be dispatched to
* and processed by the old core
@ -194,28 +212,21 @@ public class MultiCore
*/
public void reload(SolrCore core) throws ParserConfigurationException, IOException, SAXException
{
boolean wasDefault = (core==defaultCore);
SolrResourceLoader loader = new SolrResourceLoader( core.getResourceLoader().getInstanceDir() );
SolrConfig config = new SolrConfig( loader, core.getConfigFile(), null );
IndexSchema schema = new IndexSchema( config, core.getSchemaFile() );
SolrCore loaded = new SolrCore( core.getName(), core.getDataDir(), config, schema );
this.register( loaded );
if( wasDefault ) {
this.setDefaultCore( loaded );
}
// TODO? -- add some kind of hook to close the core after all references are
// gone... is finalize() enough?
}
public void setDefaultCore( SolrCore core )
public void remove( String name )
{
defaultCore = core;
cores.put( null, core );
cores.put( "", core );
cores.remove( name );
}
public SolrCore getDefaultCore() {
return defaultCore;
}
@ -224,13 +235,7 @@ public class MultiCore
* @return a Collection of registered SolrCores
*/
public Collection<SolrCore> getCores() {
ArrayList<SolrCore> c = new ArrayList<SolrCore>(cores.size());
for( Map.Entry<String, SolrCore> entry : cores.entrySet() ) {
if( entry.getKey() != null && entry.getKey().length() > 0 ) {
c.add( entry.getValue() );
}
}
return c;
return cores.values();
}
public SolrCore getCore(String name) {
@ -268,5 +273,4 @@ public class MultiCore
public File getConfigFile() {
return configFile;
}
}

View File

@ -83,7 +83,7 @@ public final class SolrCore {
public static Logger log = Logger.getLogger(SolrCore.class.getName());
private final String name;
private String name;
private final SolrConfig solrConfig;
private final IndexSchema schema;
private final String dataDir;
@ -136,6 +136,10 @@ public final class SolrCore {
public String getName() {
return name;
}
public void setName(String v) {
this.name = v;
}
/**
* @since solr 1.3

View File

@ -67,6 +67,7 @@ public class MultiCoreHandler extends RequestHandlerBase
// Pick the action
SolrParams params = req.getParams();
SolrParams required = params.required();
MultiCoreAction action = MultiCoreAction.STATUS;
String a = params.get( MultiCoreParams.ACTION );
if( a != null ) {
@ -109,15 +110,22 @@ public class MultiCoreHandler extends RequestHandlerBase
}
else {
switch( action ) {
case SETASDEFAULT:
manager.setDefaultCore( core );
rsp.add( "default", core.getName() );
break;
case RELOAD: {
manager.reload( core );
break;
}
case SWAP: {
String name = required.get( MultiCoreParams.WITH );
SolrCore swap = manager.getCore( name );
if( swap == null ) {
throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,
"Unknown core: "+name );
}
manager.swap( core, swap );
break;
}
default:
throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,

View File

@ -28,10 +28,6 @@
<%
//
SolrCore core = (SolrCore) request.getAttribute("org.apache.solr.SolrCore");
if (core == null) {
String coreParam = request.getParameter("core");
core = coreParam != null? org.apache.solr.core.MultiCore.getRegistry().getCore(coreParam) : null;
}
if (core == null)
core = SolrCore.getSolrCore();

View File

@ -111,6 +111,6 @@
</tr>
</table>
<br><br>
<a href=".?core=<%=core.getName()%>">Return to Admin Page</a>
<a href=".">Return to Admin Page</a>
</body>
</html>

View File

@ -60,7 +60,6 @@
<h2>Field Analysis</h2>
<form method="GET" action="analysis.jsp">
<input type='hidden' name='core' value='<%=core.getName()%>'>
<table>
<tr>
<td>

View File

@ -153,6 +153,6 @@
<%= buffer %>
</table>
<br><br>
<a href=".?<%=core.getName()%>">Return to Admin Page</a>
<a href=".">Return to Admin Page</a>
</body>
</html>

View File

@ -19,7 +19,6 @@
<br clear="all">
<form name="queryForm" method="GET" action="../select">
<input name='core' type='hidden' value='<%=core.getName()%>'>
<!-- these are good defaults to have if people bookmark the resulting
URLs, but they should not show up in the form since they are very
output type specific.

View File

@ -29,7 +29,7 @@ var host_name="<%= hostname %>"
</head>
<body>
<a href="?core=<%=core.getName()%>"><img border="0" align="right" height="61" width="142" src="solr-head.gif" alt="Solr"></a>
<a href="."><img border="0" align="right" height="61" width="142" src="solr-head.gif" alt="Solr"></a>
<h1>Solr Admin (<%= collectionName %>)
<%= enabledStatus==null ? "" : (isEnabled ? " - Enabled" : " - Disabled") %> </h1>

View File

@ -34,15 +34,15 @@
<h3>Solr</h3>
</td>
<td>
[<a href="get-file.jsp?core=<%=core.getName()%>&file=<%=core.getSchemaFile()%>">Schema</a>]
[<a href="get-file.jsp?core=<%=core.getName()%>&file=<%=core.getConfigFile()%>">Config</a>]
[<a href="analysis.jsp?core=<%=core.getName()%>&highlight=on">Analysis</a>]
[<a href="get-file.jsp?file=<%=core.getSchemaFile()%>">Schema</a>]
[<a href="get-file.jsp?file=<%=core.getConfigFile()%>">Config</a>]
[<a href="analysis.jsp?highlight=on">Analysis</a>]
<br>
[<a href="stats.jsp?core=<%=core.getName()%>">Statistics</a>]
[<a href="registry.jsp?core=<%=core.getName()%>">Info</a>]
[<a href="distributiondump.jsp?core=<%=core.getName()%>">Distribution</a>]
[<a href="ping?core=<%=core.getName()%>">Ping</a>]
[<a href="logging.jsp?core=<%=core.getName()%>">Logging</a>]
[<a href="stats.jsp">Statistics</a>]
[<a href="registry.jsp">Info</a>]
[<a href="distributiondump.jsp">Distribution</a>]
[<a href="ping">Ping</a>]
[<a href="logging.jsp">Logging</a>]
</td>
</tr>
@ -53,7 +53,7 @@ if (cores.size() > 1) {%><tr><td><strong>Cores:</strong><br></td><td><%
while (icore.hasNext()) {
SolrCore acore = icore.next();
if (acore == core) continue;
%>[<a href=".?core=<%=acore.getName()%>"><%=acore.getName()%></a>]<%
%>[<a href="../../<%=acore.getName()%>/admin/"><%=acore.getName()%></a>]<%
}%></td></tr><%
}%>
@ -62,17 +62,17 @@ if (cores.size() > 1) {%><tr><td><strong>Cores:</strong><br></td><td><%
<strong>App server:</strong><br>
</td>
<td>
[<a href="get-properties.jsp?core=<%=core.getName()%>">Java Properties</a>]
[<a href="threaddump.jsp?core=<%=core.getName()%>">Thread Dump</a>]
[<a href="get-properties.jsp">Java Properties</a>]
[<a href="threaddump.jsp">Thread Dump</a>]
<%
if (enabledFile!=null)
if (isEnabled) {
%>
[<a href="action.jsp?core=<%=core.getName()%>&action=Disable">Disable</a>]
[<a href="action.jsp?action=Disable">Disable</a>]
<%
} else {
%>
[<a href="action.jsp?core=<%=core.getName()%>&action=Enable">Enable</a>]
[<a href="action.jsp?action=Enable">Enable</a>]
<%
}
%>
@ -80,7 +80,7 @@ if (cores.size() > 1) {%><tr><td><strong>Cores:</strong><br></td><td><%
</tr>
<jsp:include page="get-file.jsp?core=<%=core.getName()%>&file=admin-extra.html&optional=y" flush="true"/>
<jsp:include page="get-file.jsp?file=admin-extra.html&optional=y" flush="true"/>
</table><P>
@ -91,7 +91,7 @@ if (cores.size() > 1) {%><tr><td><strong>Cores:</strong><br></td><td><%
<h3>Make a Query</h3>
</td>
<td>
[<a href="form.jsp?core=<%=core.getName()%>">Full Interface</a>]
[<a href="form.jsp">Full Interface</a>]
</td>
</tr>
@ -102,7 +102,6 @@ if (cores.size() > 1) {%><tr><td><strong>Cores:</strong><br></td><td><%
<td colspan=2>
<form name=queryForm method="GET" action="../select/">
<textarea class="std" rows="4" cols="40" name="q"><%= defaultSearch %></textarea>
<input name="core" type="hidden" value="<%=core.getName()%>">
<input name="version" type="hidden" value="2.2">
<input name="start" type="hidden" value="0">
<input name="rows" type="hidden" value="10">

View File

@ -1,119 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
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$ -->
<!-- $URL$ -->
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output
method="html"
indent="yes"
doctype-public="-//W3C//DTD HTML 4.01//EN"
doctype-system="http://www.w3.org/TR/html4/strict.dtd" />
<xsl:template match="/">
<html>
<head>
<link rel="stylesheet" type="text/css" href="solr-admin.css"></link>
<link rel="icon" href="/favicon.ico" type="image/ico"></link>
<link rel="shortcut icon" href="/favicon.ico" type="image/ico"></link>
<title>Solr Admin: Logging</title>
</head>
<body>
<a href="">
<img border="0" align="right" height="61" width="142" src="solr-head.gif" alt="SOLR">
</img>
</a>
<h1>Solr Admin (<xsl:value-of select="solr/meta/collection" />)</h1>
<div style="margin-top: 1em;">
<xsl:apply-templates/>
<div>
</div>
<xsl:element name='a'>
<xsl:attribute name='href'>.?core=<xsl:value-of select="//solr/core"/></xsl:attribute>
<xsl:text>Return to Admin Page</xsl:text>
</xsl:element>
</div>
</body>
</html>
</xsl:template>
<xsl:include href="meta.xsl"/>
<xsl:template match="solr/logging">
<br clear="all"/>
<h2>Solr Logging</h2>
<table>
<tr>
<td>
<H3>Log Level:</H3>
</td>
<td>
<xsl:value-of select="logLevel" />
</td>
</tr>
<tr>
<td>
Set Level
</td>
<td>
[<xsl:element name='a'>
<xsl:attribute name='href'>action.jsp?log=ALL&amp;core=<xsl:value-of select="//solr/core"/></xsl:attribute>
<xsl:text>ALL</xsl:text>
</xsl:element>]
[<xsl:element name='a'>
<xsl:attribute name='href'>action.jsp?log=CONFIG&amp;core=<xsl:value-of select="//solr/core"/></xsl:attribute>
<xsl:text>CONFIG</xsl:text>
</xsl:element>]
[<xsl:element name='a'>
<xsl:attribute name='href'>action.jsp?log=FINE&amp;core=<xsl:value-of select="//solr/core"/></xsl:attribute>
<xsl:text>FINE</xsl:text>
</xsl:element>]
[<xsl:element name='a'>
<xsl:attribute name='href'>action.jsp?log=FINER&amp;core=<xsl:value-of select="//solr/core"/></xsl:attribute>
<xsl:text>FINER</xsl:text>
</xsl:element>]
[<xsl:element name='a'>
<xsl:attribute name='href'>action.jsp?log=FINEST&amp;core=<xsl:value-of select="//solr/core"/></xsl:attribute>
<xsl:text>FINEST</xsl:text>
</xsl:element>]
[<xsl:element name='a'>
<xsl:attribute name='href'>action.jsp?log=INFO&amp;core=<xsl:value-of select="//solr/core"/></xsl:attribute>
<xsl:text>INFO</xsl:text>
</xsl:element>]
[<xsl:element name='a'>
<xsl:attribute name='href'>action.jsp?log=OFF&amp;core=<xsl:value-of select="//solr/core"/></xsl:attribute>
<xsl:text>OFF</xsl:text>
</xsl:element>]
[<xsl:element name='a'>
<xsl:attribute name='href'>action.jsp?log=SEVERE&amp;core=<xsl:value-of select="//solr/core"/></xsl:attribute>
<xsl:text>SEVERE</xsl:text>
</xsl:element>]
[<xsl:element name='a'>
<xsl:attribute name='href'>action.jsp?log=WARNING&amp;core=<xsl:value-of select="//solr/core"/></xsl:attribute>
<xsl:text>WARNING</xsl:text>
</xsl:element>]
</td>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="utf-8"?>
<!--
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$ -->
<!-- $URL$ -->
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output
method="html"
indent="yes"
doctype-public="-//W3C//DTD HTML 4.01//EN"
doctype-system="http://www.w3.org/TR/html4/strict.dtd" />
<xsl:template match="/">
<html>
<head>
<link rel="stylesheet" type="text/css" href="solr-admin.css"></link>
<link rel="icon" href="/favicon.ico" type="image/ico"></link>
<link rel="shortcut icon" href="/favicon.ico" type="image/ico"></link>
<title>Solr Admin: Logging</title>
</head>
<body>
<a href="">
<img border="0" align="right" height="61" width="142" src="solr-head.gif" alt="SOLR">
</img>
</a>
<h1>Solr Admin (<xsl:value-of select="solr/meta/collection" />)</h1>
<div style="margin-top: 1em;">
<xsl:apply-templates/>
<div>
</div>
<a href=".">Return to Admin Page</a>
</div>
</body>
</html>
</xsl:template>
<xsl:include href="meta.xsl"/>
<xsl:template match="solr/logging">
<br clear="all"/>
<h2>Solr Logging</h2>
<table>
<tr>
<td>
<H3>Log Level:</H3>
</td>
<td>
<xsl:value-of select="logLevel" />
</td>
</tr>
<tr>
<td>
Set Level
</td>
<td>
[<a href="action.jsp?log=ALL">ALL</a>]
[<a href="action.jsp?log=CONFIG">CONFIG</a>]
[<a href="action.jsp?log=FINE">FINE</a>]
[<a href="action.jsp?log=FINER">FINER</a>]
[<a href="action.jsp?log=FINEST">FINEST</a>]
[<a href="action.jsp?log=INFO">INFO</a>]
[<a href="action.jsp?log=OFF">OFF</a>]
[<a href="action.jsp?log=SEVERE">SEVERE</a>]
[<a href="action.jsp?log=WARNING">WARNING</a>]
</td>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>

View File

@ -1,72 +1,69 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
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$ -->
<!-- $URL$ -->
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output
method="html"
indent="yes"
doctype-public="-//W3C//DTD HTML 4.01//EN"
doctype-system="http://www.w3.org/TR/html4/strict.dtd" />
<xsl:template match="/">
<html>
<head>
<link rel="stylesheet" type="text/css" href="solr-admin.css"></link>
<link rel="icon" href="/favicon.ico" type="image/ico"></link>
<link rel="shortcut icon" href="/favicon.ico" type="image/ico"></link>
<title>Solr Admin: Ping</title>
</head>
<body>
<a href="">
<img border="0" align="right" height="61" width="142" src="solr-head.gif" alt="SOLR">
</img>
</a>
<h1>Solr Admin (<xsl:value-of select="solr/meta/collection" />)</h1>
<div style="margin-top: 1em;">
<xsl:apply-templates/>
<div>
</div>
<xsl:element name='a'>
<xsl:attribute name='href'>.?core=<xsl:value-of select="//solr/core"/></xsl:attribute>
<xsl:text>Return to Admin Page (ping)</xsl:text>
</xsl:element>
</div>
</body>
</html>
</xsl:template>
<xsl:include href="meta.xsl"/>
<xsl:template match="solr/ping">
<table>
<tr>
<td>
<H3>Ping</H3>
</td>
<td>
<xsl:value-of select="error" />
</td>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="utf-8"?>
<!--
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$ -->
<!-- $URL$ -->
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output
method="html"
indent="yes"
doctype-public="-//W3C//DTD HTML 4.01//EN"
doctype-system="http://www.w3.org/TR/html4/strict.dtd" />
<xsl:template match="/">
<html>
<head>
<link rel="stylesheet" type="text/css" href="solr-admin.css"></link>
<link rel="icon" href="/favicon.ico" type="image/ico"></link>
<link rel="shortcut icon" href="/favicon.ico" type="image/ico"></link>
<title>Solr Admin: Ping</title>
</head>
<body>
<a href="">
<img border="0" align="right" height="61" width="142" src="solr-head.gif" alt="SOLR">
</img>
</a>
<h1>Solr Admin (<xsl:value-of select="solr/meta/collection" />)</h1>
<div style="margin-top: 1em;">
<xsl:apply-templates/>
<div>
</div>
<a href=".">Return to Admin Page</a>
</div>
</body>
</html>
</xsl:template>
<xsl:include href="meta.xsl"/>
<xsl:template match="solr/ping">
<table>
<tr>
<td>
<H3>Ping</H3>
</td>
<td>
<xsl:value-of select="error" />
</td>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>

View File

@ -48,10 +48,7 @@
<br clear="all" />
<xsl:apply-templates/>
<br /><br />
<xsl:element name='a'>
<xsl:attribute name='href'>.?core=<xsl:value-of select="//solr/core"/></xsl:attribute>
<xsl:text>Return to Admin Page</xsl:text>
</xsl:element>
<a href="">Return to Admin Page</a>
</body>
</html>
</xsl:template>

View File

@ -48,10 +48,7 @@
<br clear="all" />
<xsl:apply-templates/>
<br /><br />
<xsl:element name='a'>
<xsl:attribute name='href'>.?core=<xsl:value-of select="//solr/core"/></xsl:attribute>
<xsl:text>Return to Admin Page</xsl:text>
</xsl:element>
<a href=".">Return to Admin Page</a>
</body>
</html>
</xsl:template>

View File

@ -1,104 +1,101 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
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$ -->
<!-- $URL$ -->
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output
method="html"
indent="yes"
doctype-public="-//W3C//DTD HTML 4.01//EN"
doctype-system="http://www.w3.org/TR/html4/strict.dtd" />
<xsl:template match="/">
<html>
<head>
<link rel="stylesheet" type="text/css" href="solr-admin.css"></link>
<link rel="icon" href="/favicon.ico" type="image/ico"></link>
<link rel="shortcut icon" href="/favicon.ico" type="image/ico"></link>
<title>SOLR Info</title>
</head>
<body>
<a href="">
<img border="0" align="right" height="61" width="142" src="solr-head.gif" alt="SOLR"/>
</a>
<h1>Solr Admin (<xsl:value-of select="solr/meta/collection" />)</h1>
<h2>Thread Dump</h2>
<div style="margin-top: 1em;">
<table>
<xsl:apply-templates/>
</table>
<xsl:element name='a'>
<xsl:attribute name='href'>.?core=<xsl:value-of select="//solr/core"/></xsl:attribute>
<xsl:text>Return to Admin Page</xsl:text>
</xsl:element>
</div>
</body>
</html>
</xsl:template>
<xsl:include href="meta.xsl"/>
<xsl:template match="solr/system/jvm">
<tr>
<td><xsl:value-of select="name"/> <xsl:value-of select="version"/></td>
</tr>
</xsl:template>
<xsl:template match="solr/system/threadCount">
<tr>
<td>
Thread Count:
current=<xsl:value-of select="current"/>,
peak=<xsl:value-of select="peak"/>,
daemon=<xsl:value-of select="daemon"/></td>
</tr>
</xsl:template>
<xsl:template match="solr/system/threadDump">
<div>Full Thread Dump:</div>
<xsl:for-each select="thread">
<!-- OG: TODO: add suspended/native conditionals -->
<tr>
<td style="margin-left: 1em; font-weight: bold;">
'<xsl:value-of select="name"/>'
Id=<xsl:value-of select="id"/>,
<xsl:value-of select="state"/>
on lock=<xsl:value-of select="lock"/>,
total cpu time=<xsl:value-of select="cpuTime"/>
user time=<xsl:value-of select="userTime"/>
</td>
</tr>
<xsl:apply-templates select="stackTrace"/>
</xsl:for-each>
</xsl:template>
<xsl:template match="stackTrace">
<tr>
<td style="margin-left: 1em;">
<xsl:for-each select="line">
<xsl:value-of select="."/><br/>
</xsl:for-each>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="utf-8"?>
<!--
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$ -->
<!-- $URL$ -->
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output
method="html"
indent="yes"
doctype-public="-//W3C//DTD HTML 4.01//EN"
doctype-system="http://www.w3.org/TR/html4/strict.dtd" />
<xsl:template match="/">
<html>
<head>
<link rel="stylesheet" type="text/css" href="solr-admin.css"></link>
<link rel="icon" href="/favicon.ico" type="image/ico"></link>
<link rel="shortcut icon" href="/favicon.ico" type="image/ico"></link>
<title>SOLR Info</title>
</head>
<body>
<a href="">
<img border="0" align="right" height="61" width="142" src="solr-head.gif" alt="SOLR"/>
</a>
<h1>Solr Admin (<xsl:value-of select="solr/meta/collection" />)</h1>
<h2>Thread Dump</h2>
<div style="margin-top: 1em;">
<table>
<xsl:apply-templates/>
</table>
<a href=".">Return to Admin Page</a>
</div>
</body>
</html>
</xsl:template>
<xsl:include href="meta.xsl"/>
<xsl:template match="solr/system/jvm">
<tr>
<td><xsl:value-of select="name"/> <xsl:value-of select="version"/></td>
</tr>
</xsl:template>
<xsl:template match="solr/system/threadCount">
<tr>
<td>
Thread Count:
current=<xsl:value-of select="current"/>,
peak=<xsl:value-of select="peak"/>,
daemon=<xsl:value-of select="daemon"/></td>
</tr>
</xsl:template>
<xsl:template match="solr/system/threadDump">
<div>Full Thread Dump:</div>
<xsl:for-each select="thread">
<!-- OG: TODO: add suspended/native conditionals -->
<tr>
<td style="margin-left: 1em; font-weight: bold;">
'<xsl:value-of select="name"/>'
Id=<xsl:value-of select="id"/>,
<xsl:value-of select="state"/>
on lock=<xsl:value-of select="lock"/>,
total cpu time=<xsl:value-of select="cpuTime"/>
user time=<xsl:value-of select="userTime"/>
</td>
</tr>
<xsl:apply-templates select="stackTrace"/>
</xsl:for-each>
</xsl:template>
<xsl:template match="stackTrace">
<tr>
<td style="margin-left: 1em;">
<xsl:for-each select="line">
<xsl:value-of select="."/><br/>
</xsl:for-each>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>

View File

@ -1,4 +1,4 @@
<!--
<%--
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.
@ -13,7 +13,8 @@
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.
-->
--%>
<html>
<head>
<link rel="stylesheet" type="text/css" href="solr-admin.css">
@ -25,6 +26,15 @@
<body>
<h1>Welcome to Solr!</h1>
<a href="."><img border="0" align="right" height="61" width="142" src="admin/solr-head.gif" alt="Solr"/></a>
<%
org.apache.solr.core.MultiCore multicore = org.apache.solr.core.MultiCore.getRegistry();
if( multicore.isEnabled() ) {
for( org.apache.solr.core.SolrCore core : multicore.getCores() ) {%>
<a href="<%= core.getName() %>/admin/">Admin <%= core.getName() %> </a><br/>
<% }} else { %>
<a href="admin/">Solr Admin</a>
<% } %>
</body>
</html>

View File

@ -76,13 +76,9 @@ public class SolrDispatchFilter implements Filter
log.info( "looking for multicore.xml: "+multiconfig.getAbsolutePath() );
if( multiconfig.exists() ) {
multicore.load( instanceDir, multiconfig );
core = multicore.getDefaultCore();
}
if( multicore.isEnabled() ) {
core = multicore.getDefaultCore();
if( core == null ) {
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,
"Multicore configuration does not include a default" );
}
singlecore = null;
}
else {
@ -93,22 +89,22 @@ public class SolrDispatchFilter implements Filter
log.info("user.dir=" + System.getProperty("user.dir"));
// Read global configuration
// Only the first registerd core configures the following attributes
Config solrConfig = core.getSolrConfig();
// Only the first registered core configures the following attributes
Config globalConfig = core.getSolrConfig();
long uploadLimitKB = solrConfig.getInt(
long uploadLimitKB = globalConfig.getInt(
"requestDispatcher/requestParsers/@multipartUploadLimitInKB", 2000 ); // 2MB default
boolean enableRemoteStreams = solrConfig.getBool(
boolean enableRemoteStreams = globalConfig.getBool(
"requestDispatcher/requestParsers/@enableRemoteStreaming", false );
parsers = new SolrRequestParsers( enableRemoteStreams, uploadLimitKB );
// Let this filter take care of /select?xxx format
this.handleSelect = solrConfig.getBool( "requestDispatcher/@handleSelect", false );
this.handleSelect = globalConfig.getBool( "requestDispatcher/@handleSelect", false );
// should it keep going if we hit an error?
abortOnConfigurationError = solrConfig.getBool("abortOnConfigurationError",true);
abortOnConfigurationError = globalConfig.getBool("abortOnConfigurationError",true);
}
catch( Throwable t ) {
// catch this so our filter still works
@ -125,7 +121,12 @@ public class SolrDispatchFilter implements Filter
out.println( "Check your log files for more detailed information on what may be wrong.\n" );
out.println( "If you want solr to continue after configuration errors, change: \n");
out.println( " <abortOnConfigurationError>false</abortOnConfigurationError>\n" );
out.println( "in solrconfig.xml\n" );
if( multicore.isEnabled() ) {
out.println( "in multicore.xml\n" );
}
else {
out.println( "in solrconfig.xml\n" );
}
for( Throwable t : SolrConfig.severeErrors ) {
out.println( "-------------------------------------------------------------" );
@ -179,54 +180,51 @@ public class SolrDispatchFilter implements Filter
}
// By default use the single core. If multicore is enabled, look for one.
SolrRequestHandler handler = null;
SolrCore core = singlecore;
if( core == null ) {
// try to get the corename as a request parameter first
String corename = null;
if( path.startsWith( "/@" ) ) { // multicore
idx = path.indexOf( '/', 2 );
if( idx < 1 ) {
throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,
"MultiCore path must contain a '/'. For example: /@corename/handlerpath" );
}
corename = path.substring( 2, idx );
path = path.substring( idx );
core = multicore.getCore( corename );
if( core == null ) {
throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,
"Can not find core: '"+corename+"'" );
}
// Perhaps this is a muli-core admin page?
if( path.equals( multicore.getAdminPath() ) ) {
handler = multicore.getMultiCoreHandler();
}
else {
core = multicore.getDefaultCore();
idx = path.indexOf( "/", 1 );
if( idx > 1 ) {
// try to get the corename as a request parameter first
String corename = path.substring( 1, idx );
path = path.substring( idx );
core = multicore.getCore( corename );
// invalid core name is ok. It could fall through to some other request
}
}
}
SolrRequestHandler handler = null;
if( path.length() > 1 ) { // don't match "" or "/" as valid path
handler = core.getRequestHandler( path );
}
if( handler == null && handleSelect ) {
if( "/select".equals( path ) || "/select/".equals( path ) ) {
solrReq = parsers.parse( core, path, req );
String qt = solrReq.getParams().get( CommonParams.QT );
if( qt != null && qt.startsWith( "/" ) ) {
throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "Invalid query type. Do not use /select to access: "+qt);
}
handler = core.getRequestHandler( qt );
if( handler == null ) {
throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "unknown handler: "+qt);
if( core != null ) {
// Only try to parse the handler *if* a valid core exists
// when multi-core is enabled, the path can lead to a null core.
if( handler == null && path.length() > 1 ) { // don't match "" or "/" as valid path
handler = core.getRequestHandler( path );
}
if( handler == null && handleSelect ) {
if( "/select".equals( path ) || "/select/".equals( path ) ) {
solrReq = parsers.parse( core, path, req );
String qt = solrReq.getParams().get( CommonParams.QT );
if( qt != null && qt.startsWith( "/" ) ) {
throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "Invalid query type. Do not use /select to access: "+qt);
}
handler = core.getRequestHandler( qt );
if( handler == null ) {
throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "unknown handler: "+qt);
}
}
}
}
// Perhaps this is a muli-core admin page?
if( handler == null && path.equals( multicore.getAdminPath() ) ) {
handler = multicore.getMultiCoreHandler();
}
if( handler != null ) {
if( core == null ) {
core = multicore.getDefaultCore();
}
if( solrReq == null ) {
solrReq = parsers.parse( core, path, req );
}
@ -245,21 +243,15 @@ public class SolrDispatchFilter implements Filter
return;
}
// otherwise, let's ensure the core is in the SolrCore request attribute so
// the servlet can retrieve it
// the servlet/jsp can retrieve it
else {
// TEMP -- to support /admin multicore grab the core from the request
// TODO -- for muticore /admin support, strip the corename from the path
// and forward to the /admin jsp file
// req.getRequestDispatcher( path ).forward( request, response );
String corename = request.getParameter("core");
if( corename != null ) {
core = multicore.getCore( corename );
if( core == null ) {
throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,
"Can not find core: '"+corename+"'" );
}
}
req.setAttribute("org.apache.solr.SolrCore", core);
// Modify the request so each core gets its own /admin
if( singlecore == null && path.startsWith( "/admin" ) ) {
req.getRequestDispatcher( path ).forward( request, response );
return;
}
}
}
catch( Throwable ex ) {