SOLR-695 -- renaming MultiCore* to CoreAdmin*

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@685989 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Ryan McKinley 2008-08-14 18:44:56 +00:00
parent 3c034ffbc9
commit 9e11b2c21d
10 changed files with 69 additions and 69 deletions

View File

@ -55,7 +55,7 @@ import org.apache.solr.servlet.SolrRequestParsers;
public class EmbeddedSolrServer extends SolrServer
{
protected final CoreContainer multicore; // either multicore
protected final CoreContainer multicore; // either cores
protected final SolrCore core; // or single core
protected final String coreName; // use CoreContainer registry
@ -97,7 +97,7 @@ public class EmbeddedSolrServer extends SolrServer
path = "/select";
}
// Check for multicore action
// Check for cores action
SolrCore core = this.core;
if( core == null )
core = multicore.getCore( coreName );

View File

@ -23,31 +23,31 @@ import java.util.Collection;
import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.response.MultiCoreResponse;
import org.apache.solr.client.solrj.response.CoreAdminResponse;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.MultiCoreParams;
import org.apache.solr.common.params.CoreAdminParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.params.MultiCoreParams.MultiCoreAction;
import org.apache.solr.common.params.CoreAdminParams.CoreAdminAction;
import org.apache.solr.common.util.ContentStream;
/**
*
* @version $Id: MultiCoreRequest.java 606335 2007-12-21 22:23:39Z ryan $
* @version $Id: CoreAdminRequest.java 606335 2007-12-21 22:23:39Z ryan $
* @since solr 1.3
*/
public class MultiCoreRequest extends SolrRequest
public class CoreAdminRequest extends SolrRequest
{
protected String core = null;
protected MultiCoreParams.MultiCoreAction action = null;
protected CoreAdminParams.CoreAdminAction action = null;
//a create core request
public static class Create extends MultiCoreRequest {
public static class Create extends CoreAdminRequest {
protected String instanceDir;
protected String configName = null;
protected String schemaName = null;
public Create() {
action = MultiCoreAction.CREATE;
action = CoreAdminAction.CREATE;
}
public void setInstanceDir(String instanceDir) { this.instanceDir = instanceDir; }
@ -64,25 +64,25 @@ public class MultiCoreRequest extends SolrRequest
throw new RuntimeException( "no action specified!" );
}
ModifiableSolrParams params = new ModifiableSolrParams();
params.set( MultiCoreParams.ACTION, action.toString() );
params.set( MultiCoreParams.CORE, core );
params.set( MultiCoreParams.INSTANCE_DIR, instanceDir);
params.set( CoreAdminParams.ACTION, action.toString() );
params.set( CoreAdminParams.CORE, core );
params.set( CoreAdminParams.INSTANCE_DIR, instanceDir);
if (configName != null) {
params.set( MultiCoreParams.CONFIG, configName);
params.set( CoreAdminParams.CONFIG, configName);
}
if (schemaName != null) {
params.set( MultiCoreParams.SCHEMA, schemaName);
params.set( CoreAdminParams.SCHEMA, schemaName);
}
return params;
}
}
public MultiCoreRequest()
public CoreAdminRequest()
{
super( METHOD.GET, "/admin/multicore" );
super( METHOD.GET, "/admin/cores" );
}
public MultiCoreRequest( String path )
public CoreAdminRequest( String path )
{
super( METHOD.GET, path );
}
@ -96,7 +96,7 @@ public class MultiCoreRequest extends SolrRequest
//
//---------------------------------------------------------------------------------------
public void setAction( MultiCoreAction action )
public void setAction( CoreAdminAction action )
{
this.action = action;
}
@ -112,8 +112,8 @@ public class MultiCoreRequest extends SolrRequest
throw new RuntimeException( "no action specified!" );
}
ModifiableSolrParams params = new ModifiableSolrParams();
params.set( MultiCoreParams.ACTION, action.toString() );
params.set( MultiCoreParams.CORE, core );
params.set( CoreAdminParams.ACTION, action.toString() );
params.set( CoreAdminParams.CORE, core );
return params;
}
@ -127,10 +127,10 @@ public class MultiCoreRequest extends SolrRequest
}
@Override
public MultiCoreResponse process(SolrServer server) throws SolrServerException, IOException
public CoreAdminResponse process(SolrServer server) throws SolrServerException, IOException
{
long startTime = System.currentTimeMillis();
MultiCoreResponse res = new MultiCoreResponse();
CoreAdminResponse res = new CoreAdminResponse();
res.setResponse( server.request( this ) );
res.setElapsedTime( System.currentTimeMillis()-startTime );
return res;
@ -140,25 +140,25 @@ public class MultiCoreRequest extends SolrRequest
//
//---------------------------------------------------------------------------------------
public static MultiCoreResponse reloadCore( String name, SolrServer server ) throws SolrServerException, IOException
public static CoreAdminResponse reloadCore( String name, SolrServer server ) throws SolrServerException, IOException
{
MultiCoreRequest req = new MultiCoreRequest();
CoreAdminRequest req = new CoreAdminRequest();
req.setCoreParam( name );
req.setAction( MultiCoreAction.RELOAD );
req.setAction( CoreAdminAction.RELOAD );
return req.process( server );
}
public static MultiCoreResponse getStatus( String name, SolrServer server ) throws SolrServerException, IOException
public static CoreAdminResponse getStatus( String name, SolrServer server ) throws SolrServerException, IOException
{
MultiCoreRequest req = new MultiCoreRequest();
CoreAdminRequest req = new CoreAdminRequest();
req.setCoreParam( name );
req.setAction( MultiCoreAction.STATUS );
req.setAction( CoreAdminAction.STATUS );
return req.process( server );
}
public static MultiCoreResponse createCore( String name, String instanceDir, SolrServer server ) throws SolrServerException, IOException
public static CoreAdminResponse createCore( String name, String instanceDir, SolrServer server ) throws SolrServerException, IOException
{
MultiCoreRequest.Create req = new MultiCoreRequest.Create();
CoreAdminRequest.Create req = new CoreAdminRequest.Create();
req.setCoreParam( name );
req.setInstanceDir(instanceDir);
return req.process( server );

View File

@ -25,7 +25,7 @@ import org.apache.solr.common.util.NamedList;
* @version $Id$
* @since solr 1.3
*/
public class MultiCoreResponse extends SolrResponseBase
public class CoreAdminResponse extends SolrResponseBase
{
@SuppressWarnings("unchecked")
public NamedList<NamedList<Object>> getCoreStatus()

View File

@ -19,11 +19,11 @@ package org.apache.solr.client.solrj;
import java.io.File;
import org.apache.solr.client.solrj.request.MultiCoreRequest;
import org.apache.solr.client.solrj.request.CoreAdminRequest;
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.MultiCoreResponse;
import org.apache.solr.client.solrj.response.CoreAdminResponse;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.core.CoreContainer;
@ -34,7 +34,7 @@ import org.apache.solr.core.CoreContainer;
*/
public abstract class MultiCoreExampleTestBase extends SolrExampleTestBase
{
protected static final CoreContainer multicore = new CoreContainer();
protected static final CoreContainer cores = new CoreContainer();
@Override public String getSolrHome() { return "../../../example/multicore/"; }
@ -118,11 +118,11 @@ public abstract class MultiCoreExampleTestBase extends SolrExampleTestBase
// Now test reloading it should have a newer open time
String name = "core0";
SolrServer coreadmin = getSolrAdmin();
MultiCoreResponse mcr = MultiCoreRequest.getStatus( name, coreadmin );
CoreAdminResponse mcr = CoreAdminRequest.getStatus( name, coreadmin );
long before = mcr.getStartTime( name ).getTime();
MultiCoreRequest.reloadCore( name, coreadmin );
CoreAdminRequest.reloadCore( name, coreadmin );
mcr = MultiCoreRequest.getStatus( name, coreadmin );
mcr = CoreAdminRequest.getStatus( name, coreadmin );
long after = mcr.getStartTime( name ).getTime();
assertTrue( "should have more recent time: "+after+","+before, after > before );
}

View File

@ -36,24 +36,24 @@ public class MultiCoreEmbeddedTest extends MultiCoreExampleTestBase {
File home = new File( getSolrHome() );
File f = new File( home, "solr.xml" );
multicore.load( getSolrHome(), f );
cores.load( getSolrHome(), f );
}
@Override
protected SolrServer getSolrCore0()
{
return new EmbeddedSolrServer( multicore, "core0" );
return new EmbeddedSolrServer( cores, "core0" );
}
@Override
protected SolrServer getSolrCore1()
{
return new EmbeddedSolrServer( multicore, "core1" );
return new EmbeddedSolrServer( cores, "core1" );
}
@Override
protected SolrServer getSolrAdmin()
{
return new EmbeddedSolrServer( multicore, "core0" );
return new EmbeddedSolrServer( cores, "core0" );
}
}

View File

@ -25,10 +25,10 @@
<solr persistent="true">
<!--
adminPath: RequestHandler path to manage multicores.
If 'null', cores will not be managable via REST
adminPath: RequestHandler path to manage cores.
If 'null' (or absent), cores will not be manageable via REST
-->
<cores adminPath="/admin/multicore">
<cores adminPath="/admin/cores">
<core name="core0" instanceDir="core0" />
<core name="core1" instanceDir="core1" />
</cores>

View File

@ -21,12 +21,12 @@ package org.apache.solr.common.params;
/**
* @since solr 1.3
*/
public interface MultiCoreParams
public interface CoreAdminParams
{
/** What Core are we talking about **/
public final static String CORE = "core";
/** Persistent -- should it save the multicore state? **/
/** Persistent -- should it save the cores state? **/
public final static String PERSISTENT = "persistent";
/** The name of the the core to swap names with **/
@ -47,7 +47,7 @@ public interface MultiCoreParams
/** Specifies a core instance dir. */
public final static String INSTANCE_DIR = "instanceDir";
public enum MultiCoreAction {
public enum CoreAdminAction {
STATUS,
LOAD,
UNLOAD,
@ -57,11 +57,11 @@ public interface MultiCoreParams
PERSIST,
SWAP;
public static MultiCoreAction get( String p )
public static CoreAdminAction get( String p )
{
if( p != null ) {
try {
return MultiCoreAction.valueOf( p.toUpperCase() );
return CoreAdminAction.valueOf( p.toUpperCase() );
}
catch( Exception ex ) {}
}

View File

@ -290,7 +290,7 @@ public class CoreContainer
* @throws org.xml.sax.SAXException
*/
public SolrCore create(CoreDescriptor dcore) throws ParserConfigurationException, IOException, SAXException {
// Make the instanceDir relative to the multicore instanceDir if not absolute
// Make the instanceDir relative to the cores instanceDir if not absolute
File idir = new File(dcore.getInstanceDir());
if (!idir.isAbsolute()) {
idir = new File(loader.getInstanceDir(), dcore.getInstanceDir());
@ -522,12 +522,12 @@ public class CoreContainer
return configFile;
}
/** Persists the multicore config file in multicore.xml. */
/** Persists the cores config file in cores.xml. */
public void persist() {
persistFile(null);
}
/** Persists the multicore config file in a user provided file. */
/** Persists the cores config file in a user provided file. */
public void persistFile(File file) {
File tmpFile = null;
try {
@ -565,7 +565,7 @@ public class CoreContainer
}
}
/** Write the multicore configuration through a writer.*/
/** Write the cores configuration through a writer.*/
void persist(Writer writer) throws IOException {
writer.write("<?xml version='1.0' encoding='UTF-8'?>");
writer.write("<solr");
@ -596,7 +596,7 @@ public class CoreContainer
writer.write("</solr>\n");
}
/** Writes the multicore configuration node for a given core. */
/** Writes the cores configuration node for a given core. */
void persist(Writer writer, CoreDescriptor dcore) throws IOException {
writer.write(" <core");
writer.write (" name='");

View File

@ -21,9 +21,9 @@ import java.io.IOException;
import java.util.Date;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.MultiCoreParams;
import org.apache.solr.common.params.CoreAdminParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.params.MultiCoreParams.MultiCoreAction;
import org.apache.solr.common.params.CoreAdminParams.CoreAdminAction;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap;
import org.apache.solr.core.CoreContainer;
@ -77,29 +77,29 @@ public abstract class CoreAdminHandler extends RequestHandlerBase
// Pick the action
SolrParams params = req.getParams();
SolrParams required = params.required();
MultiCoreAction action = MultiCoreAction.STATUS;
String a = params.get( MultiCoreParams.ACTION );
CoreAdminAction action = CoreAdminAction.STATUS;
String a = params.get( CoreAdminParams.ACTION );
if( a != null ) {
action = MultiCoreAction.get( a );
action = CoreAdminAction.get( a );
if( action == null ) {
throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,
"Unknown 'action' value. Use: "+MultiCoreAction.values() );
"Unknown 'action' value. Use: "+CoreAdminAction.values() );
}
}
String cname = params.get( MultiCoreParams.CORE );
String cname = params.get( CoreAdminParams.CORE );
switch(action) {
case CREATE: {
CoreDescriptor dcore = new CoreDescriptor(cores);
dcore.init(params.get(MultiCoreParams.NAME),
params.get(MultiCoreParams.INSTANCE_DIR));
dcore.init(params.get(CoreAdminParams.NAME),
params.get(CoreAdminParams.INSTANCE_DIR));
// fillup optional parameters
String opts = params.get(MultiCoreParams.CONFIG);
String opts = params.get(CoreAdminParams.CONFIG);
if (opts != null)
dcore.setConfigName(opts);
opts = params.get(MultiCoreParams.SCHEMA);
opts = params.get(CoreAdminParams.SCHEMA);
if (opts != null)
dcore.setSchemaName(opts);
@ -138,8 +138,8 @@ public abstract class CoreAdminHandler extends RequestHandlerBase
}
case SWAP: {
do_persist = params.getBool(MultiCoreParams.PERSISTENT, cores.isPersistent());
String with = required.get( MultiCoreParams.WITH );
do_persist = params.getBool(CoreAdminParams.PERSISTENT, cores.isPersistent());
String with = required.get( CoreAdminParams.WITH );
cores.swap( cname, with );
break;
}

View File

@ -159,7 +159,7 @@ public class SolrDispatchFilter implements Filter
// pick a core to use for output generation
core = cores.getAdminCore();
if( core == null ) {
throw new RuntimeException( "Can not find a valid core for the multicore admin handler" );
throw new RuntimeException( "Can not find a valid core for the cores admin handler" );
}
}
else {