org.apache.solr.core
Class CoreContainer

java.lang.Object
  extended by org.apache.solr.core.CoreContainer

public class CoreContainer
extends Object

Since:
solr 1.3

Field Summary
protected  ConfigSolr cfg
           
protected  CollectionsHandler collectionsHandler
           
protected  Properties containerProperties
           
protected  CoreAdminHandler coreAdminHandler
           
protected  Map<String,Exception> coreInitFailures
           
protected  CoresLocator coresLocator
           
protected  Map<String,IndexSchema> indexSchemaCache
           
protected  SolrResourceLoader loader
           
protected static org.slf4j.Logger log
           
protected  LogWatcher logging
           
protected  boolean shareSchema
           
protected  String solrHome
           
protected  ZkContainer zkSys
           
 
Constructor Summary
CoreContainer()
          Create a new CoreContainer using system properties to detect the solr home directory.
CoreContainer(SolrResourceLoader loader)
          Create a new CoreContainer using the given SolrResourceLoader.
CoreContainer(SolrResourceLoader loader, ConfigSolr config)
          Create a new CoreContainer using the given SolrResourceLoader, configuration and CoresLocator.
CoreContainer(SolrResourceLoader loader, ConfigSolr config, CoresLocator locator)
           
CoreContainer(String solrHome)
          Create a new CoreContainer using the given solr home directory.
 
Method Summary
 void cancelCoreRecoveries()
           
 SolrCore create(CoreDescriptor dcore)
          Creates a new core based on a descriptor but does not register it.
static CoreContainer createAndLoad(String solrHome, File configFile)
          Create a new CoreContainer and load its cores
protected
<T> T
createHandler(String handlerClass, Class<T> clazz)
           
protected  void finalize()
           
 String getAdminPath()
           
 Collection<String> getAllCoreNames()
          get a list of all the cores that are currently loaded
 CollectionsHandler getCollectionsHandler()
           
 Properties getContainerProperties()
           
 SolrCore getCore(String name)
          Gets a core by name and increase its refcount.
 CoreDescriptor getCoreDescriptor(String coreName)
           
 List<CoreDescriptor> getCoreDescriptors()
          Get the CoreDescriptors for all cores managed by this container
 Map<String,Exception> getCoreInitFailures()
          Returns an immutable Map of Exceptions that occured when initializing SolrCores (either at startup, or do to runtime requests to create cores) keyed off of the name (String) of the SolrCore that had the Exception during initialization.
 Collection<String> getCoreNames()
           
 Collection<String> getCoreNames(SolrCore core)
          This method is currently experimental.
 String getCoreRootDirectory()
           
 Collection<SolrCore> getCores()
           
 CoresLocator getCoresLocator()
           
 String getDefaultCoreName()
          the default core name, or null if there is no default core name
 String getHostName()
           
 InfoHandler getInfoHandler()
           
 LogWatcher getLogging()
           
 String getManagementPath()
          Gets the alternate path for multicore handling: This is used in case there is a registered unnamed core (aka name is "") to declare an alternate way of accessing named cores.
 CoreAdminHandler getMultiCoreHandler()
           
 ShardHandlerFactory getShardHandlerFactory()
          The default ShardHandlerFactory used to communicate with other solr instances
 String getSolrHome()
           
 CoreDescriptor getUnloadedCoreDescriptor(String cname)
          Gets a solr core descriptor for a core that is not loaded.
 UpdateShardHandler getUpdateShardHandler()
           
 ZkController getZkController()
           
 boolean isLoaded(String name)
          Determines whether the core is already loaded or not but does NOT load the core
 boolean isLoadedNotPendingClose(String name)
           
 boolean isPersistent()
          Deprecated. 
 boolean isShareSchema()
           
 boolean isShutDown()
           
 boolean isZooKeeperAware()
           
 void load()
          Load the cores defined for this CoreContainer
 void preRegisterInZk(CoreDescriptor p)
           
 SolrCore register(SolrCore core, boolean returnPrev)
          Registers a SolrCore descriptor in the registry using the core's name.
 SolrCore register(String name, SolrCore core, boolean returnPrev)
           
protected  SolrCore registerCore(boolean isTransientCore, String name, SolrCore core, boolean returnPrevNotClosed)
           
protected  SolrCore registerCore(boolean isTransientCore, String name, SolrCore core, boolean returnPrevNotClosed, boolean registerInZk)
           
 void reload(String name)
          Recreates a SolrCore.
 SolrCore remove(String name)
          Removes and returns registered core w/o decrementing it's reference count
 void rename(String name, String toName)
           
 void shutdown()
          Stops all cores.
 void swap(String n0, String n1)
          Swaps two SolrCore descriptors.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final org.slf4j.Logger log

coreInitFailures

protected final Map<String,Exception> coreInitFailures

coreAdminHandler

protected CoreAdminHandler coreAdminHandler

collectionsHandler

protected CollectionsHandler collectionsHandler

containerProperties

protected Properties containerProperties

indexSchemaCache

protected Map<String,IndexSchema> indexSchemaCache

shareSchema

protected boolean shareSchema

zkSys

protected ZkContainer zkSys

logging

protected LogWatcher logging

cfg

protected final ConfigSolr cfg

loader

protected final SolrResourceLoader loader

solrHome

protected final String solrHome

coresLocator

protected final CoresLocator coresLocator
Constructor Detail

CoreContainer

public CoreContainer()
Create a new CoreContainer using system properties to detect the solr home directory. The container's cores are not loaded.

See Also:
load()

CoreContainer

public CoreContainer(SolrResourceLoader loader)
Create a new CoreContainer using the given SolrResourceLoader. The container's cores are not loaded.

Parameters:
loader - the SolrResourceLoader
See Also:
load()

CoreContainer

public CoreContainer(String solrHome)
Create a new CoreContainer using the given solr home directory. The container's cores are not loaded.

Parameters:
solrHome - a String containing the path to the solr home directory
See Also:
load()

CoreContainer

public CoreContainer(SolrResourceLoader loader,
                     ConfigSolr config)
Create a new CoreContainer using the given SolrResourceLoader, configuration and CoresLocator. The container's cores are not loaded.

Parameters:
loader - the SolrResourceLoader
config - a ConfigSolr representation of this container's configuration
See Also:
load()

CoreContainer

public CoreContainer(SolrResourceLoader loader,
                     ConfigSolr config,
                     CoresLocator locator)
Method Detail

createAndLoad

public static CoreContainer createAndLoad(String solrHome,
                                          File configFile)
Create a new CoreContainer and load its cores

Parameters:
solrHome - the solr home directory
configFile - the file containing this container's configuration
Returns:
a loaded CoreContainer

getContainerProperties

public Properties getContainerProperties()

load

public void load()
Load the cores defined for this CoreContainer


isShutDown

public boolean isShutDown()

shutdown

public void shutdown()
Stops all cores.


cancelCoreRecoveries

public void cancelCoreRecoveries()

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable

getCoresLocator

public CoresLocator getCoresLocator()

registerCore

protected SolrCore registerCore(boolean isTransientCore,
                                String name,
                                SolrCore core,
                                boolean returnPrevNotClosed)

registerCore

protected SolrCore registerCore(boolean isTransientCore,
                                String name,
                                SolrCore core,
                                boolean returnPrevNotClosed,
                                boolean registerInZk)

register

public SolrCore register(SolrCore core,
                         boolean returnPrev)
Registers a SolrCore descriptor in the registry using the core's name. If returnPrev==false, the old core, if different, is closed.

Returns:
a previous core having the same name if it existed and returnPrev==true

register

public SolrCore register(String name,
                         SolrCore core,
                         boolean returnPrev)

create

public SolrCore create(CoreDescriptor dcore)
Creates a new core based on a descriptor but does not register it.

Parameters:
dcore - a core descriptor
Returns:
the newly created core

getCores

public Collection<SolrCore> getCores()
Returns:
a Collection of registered SolrCores

getCoreNames

public Collection<String> getCoreNames()
Returns:
a Collection of the names that cores are mapped to

getCoreNames

public Collection<String> getCoreNames(SolrCore core)
This method is currently experimental.

Returns:
a Collection of the names that a specific core is mapped to.

getAllCoreNames

public Collection<String> getAllCoreNames()
get a list of all the cores that are currently loaded

Returns:
a list of al lthe available core names in either permanent or transient core lists.

getCoreInitFailures

public Map<String,Exception> getCoreInitFailures()
Returns an immutable Map of Exceptions that occured when initializing SolrCores (either at startup, or do to runtime requests to create cores) keyed off of the name (String) of the SolrCore that had the Exception during initialization.

While the Map returned by this method is immutable and will not change once returned to the client, the source data used to generate this Map can be changed as various SolrCore operations are performed:


reload

public void reload(String name)
Recreates a SolrCore. While the new core is loading, requests will continue to be dispatched to and processed by the old core

Parameters:
name - the name of the SolrCore to reload

swap

public void swap(String n0,
                 String n1)
Swaps two SolrCore descriptors.


remove

public SolrCore remove(String name)
Removes and returns registered core w/o decrementing it's reference count


rename

public void rename(String name,
                   String toName)

getCoreDescriptors

public List<CoreDescriptor> getCoreDescriptors()
Get the CoreDescriptors for all cores managed by this container

Returns:
a List of CoreDescriptors

getCoreDescriptor

public CoreDescriptor getCoreDescriptor(String coreName)

getCoreRootDirectory

public String getCoreRootDirectory()

getCore

public SolrCore getCore(String name)
Gets a core by name and increase its refcount.

Parameters:
name - the core name
Returns:
the core if found, null if a SolrCore by this name does not exist
Throws:
SolrException - if a SolrCore with this name failed to be initialized
See Also:
SolrCore.close()

createHandler

protected <T> T createHandler(String handlerClass,
                              Class<T> clazz)

getMultiCoreHandler

public CoreAdminHandler getMultiCoreHandler()

getCollectionsHandler

public CollectionsHandler getCollectionsHandler()

getInfoHandler

public InfoHandler getInfoHandler()

getDefaultCoreName

public String getDefaultCoreName()
the default core name, or null if there is no default core name


isPersistent

@Deprecated
public boolean isPersistent()
Deprecated. 


getAdminPath

public String getAdminPath()

getHostName

public String getHostName()

getManagementPath

public String getManagementPath()
Gets the alternate path for multicore handling: This is used in case there is a registered unnamed core (aka name is "") to declare an alternate way of accessing named cores. This can also be used in a pseudo single-core environment so admins can prepare a new version before swapping.


getLogging

public LogWatcher getLogging()

isLoaded

public boolean isLoaded(String name)
Determines whether the core is already loaded or not but does NOT load the core


isLoadedNotPendingClose

public boolean isLoadedNotPendingClose(String name)

getUnloadedCoreDescriptor

public CoreDescriptor getUnloadedCoreDescriptor(String cname)
Gets a solr core descriptor for a core that is not loaded. Note that if the caller calls this on a loaded core, the unloaded descriptor will be returned.

Parameters:
cname - - name of the unloaded core descriptor to load. NOTE:
Returns:
a coreDescriptor. May return null

preRegisterInZk

public void preRegisterInZk(CoreDescriptor p)

getSolrHome

public String getSolrHome()

isZooKeeperAware

public boolean isZooKeeperAware()

getZkController

public ZkController getZkController()

isShareSchema

public boolean isShareSchema()

getShardHandlerFactory

public ShardHandlerFactory getShardHandlerFactory()
The default ShardHandlerFactory used to communicate with other solr instances


getUpdateShardHandler

public UpdateShardHandler getUpdateShardHandler()


Copyright © 2000-2014 Apache Software Foundation. All Rights Reserved.