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

Nested Class Summary
static class CoreContainer.Initializer
           
 
Field Summary
protected  String adminHandler
           
protected  String adminPath
           
protected  CollectionsHandler collectionsHandler
           
protected  File configFile
           
protected  Properties containerProperties
           
protected  CoreAdminHandler coreAdminHandler
           
protected  Map<String,Exception> coreInitFailures
           
static String DEFAULT_DEFAULT_CORE_NAME
           
protected  String defaultCoreName
           
protected  String host
           
protected  String hostContext
           
protected  String hostPort
           
protected  Map<String,IndexSchema> indexSchemaCache
           
protected  String libDir
           
protected  SolrResourceLoader loader
           
protected static org.slf4j.Logger log
           
protected  LogWatcher logging
           
protected  String managementPath
           
protected  boolean persistent
           
protected  boolean shareSchema
           
protected  String solrHome
           
protected  Integer zkClientTimeout
           
 
Constructor Summary
CoreContainer()
          Deprecated. use the single arg constructor with locateSolrHome()
CoreContainer(SolrResourceLoader loader)
          Minimal CoreContainer constructor.
CoreContainer(String solrHome)
           
CoreContainer(String dir, File configFile)
          Initalize CoreContainer directly from the constructor
 
Method Summary
 void cancelCoreRecoveries()
           
 String checkUniqueDataDir(String targetPath)
          Checks that the data dir passed is is NOT shared by any other core
 SolrCore create(CoreDescriptor dcore)
          Creates a new core based on a descriptor but does not register it.
protected  CoreAdminHandler createMultiCoreHandler(String adminHandlerClass)
          Creates a CoreAdminHandler for this MultiCore.
protected  void finalize()
           
 String getAdminPath()
           
 Collection<String> getAllCoreNames()
          get a list of all the cores that are currently loaded
 String getBadCoreMessage(String name)
           
 CollectionsHandler getCollectionsHandler()
           
 File getConfigFile()
           
 Properties getContainerProperties()
           
 SolrCore getCore(String name)
          Gets a core by name and increase its refcount.
 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.
 Collection<SolrCore> getCores()
           
 String getDefaultCoreName()
          the default core name, or null if there is no default core name
 String getHost()
           
 String getHostContext()
           
 String getHostPort()
           
 LogWatcher getLogging()
           
 String getManagementPath()
           
 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.
 int getZkClientTimeout()
           
 ZkController getZkController()
           
protected  void initShardHandler()
           
protected  void initZooKeeper(String zkHost, int zkClientTimeout)
           
 boolean isLoaded(String name)
          Determines whether the core is already loaded or not but does NOT load the core
 boolean isPersistent()
           
 boolean isShareSchema()
           
 boolean isShutDown()
           
 boolean isZooKeeperAware()
           
 void load(String dir, File configFile)
          Load a config file listing the available solr cores.
protected  void load(String dir, InputStream is, String fileName)
          Load a config file listing the available solr cores.
 void persist()
          Persists the cores config file in cores.xml.
 void persistFile(File file)
          Persists the cores config file in a user provided file.
 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)
           
 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 setLogging(LogWatcher v)
           
 void setManagementPath(String path)
          Sets 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.
 void setPersistent(boolean persistent)
           
 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

DEFAULT_DEFAULT_CORE_NAME

public static final String DEFAULT_DEFAULT_CORE_NAME
See Also:
Constant Field Values

log

protected static org.slf4j.Logger log

coreInitFailures

protected final Map<String,Exception> coreInitFailures

persistent

protected boolean persistent

adminPath

protected String adminPath

managementPath

protected String managementPath

hostPort

protected String hostPort

hostContext

protected String hostContext

host

protected String host

coreAdminHandler

protected CoreAdminHandler coreAdminHandler

collectionsHandler

protected CollectionsHandler collectionsHandler

configFile

protected File configFile

libDir

protected String libDir

loader

protected SolrResourceLoader loader

containerProperties

protected Properties containerProperties

indexSchemaCache

protected Map<String,IndexSchema> indexSchemaCache

adminHandler

protected String adminHandler

shareSchema

protected boolean shareSchema

zkClientTimeout

protected Integer zkClientTimeout

solrHome

protected String solrHome

defaultCoreName

protected String defaultCoreName

logging

protected LogWatcher logging
Constructor Detail

CoreContainer

@Deprecated
public CoreContainer()
Deprecated. use the single arg constructor with locateSolrHome()

Deprecated

See Also:
SolrResourceLoader.locateSolrHome()

CoreContainer

public CoreContainer(String dir,
                     File configFile)
              throws FileNotFoundException
Initalize CoreContainer directly from the constructor

Throws:
FileNotFoundException

CoreContainer

public CoreContainer(SolrResourceLoader loader)
Minimal CoreContainer constructor.

Parameters:
loader - the CoreContainer resource loader

CoreContainer

public CoreContainer(String solrHome)
Method Detail

initZooKeeper

protected void initZooKeeper(String zkHost,
                             int zkClientTimeout)

getContainerProperties

public Properties getContainerProperties()

load

public void load(String dir,
                 File configFile)
          throws FileNotFoundException
Load a config file listing the available solr cores.

Parameters:
dir - the home directory of all resources.
configFile - the configuration file
Throws:
FileNotFoundException

load

protected void load(String dir,
                    InputStream is,
                    String fileName)
Load a config file listing the available solr cores.

Parameters:
dir - the home directory of all resources.
is - the configuration file InputStream. May be a properties file or an xml file

initShardHandler

protected void initShardHandler()

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

registerCore

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

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.

checkUniqueDataDir

public String checkUniqueDataDir(String targetPath)
Checks that the data dir passed is is NOT shared by any other core

Parameters:
targetPath - - path to check
Returns:
- null if this path is unique, core name of the first other core that shares this path.

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)

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()

createMultiCoreHandler

protected CoreAdminHandler createMultiCoreHandler(String adminHandlerClass)
Creates a CoreAdminHandler for this MultiCore.

Returns:
a CoreAdminHandler

getMultiCoreHandler

public CoreAdminHandler getMultiCoreHandler()

getCollectionsHandler

public CollectionsHandler getCollectionsHandler()

getDefaultCoreName

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


isPersistent

public boolean isPersistent()

setPersistent

public void setPersistent(boolean persistent)

getAdminPath

public String getAdminPath()

getHostPort

public String getHostPort()

getHostContext

public String getHostContext()

getHost

public String getHost()

getZkClientTimeout

public int getZkClientTimeout()

getManagementPath

public String getManagementPath()

setManagementPath

public void setManagementPath(String path)
Sets 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()

setLogging

public void setLogging(LogWatcher v)

getConfigFile

public File getConfigFile()

isLoaded

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


persist

public void persist()
Persists the cores config file in cores.xml.


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

persistFile

public void persistFile(File file)
Persists the cores config file in a user provided file.


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


getBadCoreMessage

public String getBadCoreMessage(String name)


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