public final class SolrCore extends java.lang.Object implements SolrInfoMBean
Modifier and Type | Class and Description |
---|---|
class |
SolrCore.LazyQueryResponseWriterWrapper |
SolrInfoMBean.Category
Modifier and Type | Field and Description |
---|---|
private RefCounted<SolrIndexSearcher> |
_searcher |
private java.util.LinkedList<RefCounted<SolrIndexSearcher>> |
_searchers |
(package private) static int |
boolean_query_max_clause_count |
private java.util.Collection<CloseHook> |
closeHooks |
private CoreDescriptor |
coreDescriptor |
private java.lang.String |
dataDir |
static java.util.Map<java.lang.String,QueryResponseWriter> |
DEFAULT_RESPONSE_WRITERS |
private QueryResponseWriter |
defaultResponseWriter |
private DirectoryFactory |
directoryFactory |
private static java.util.Set<java.lang.String> |
dirs |
(package private) java.util.List<SolrEventListener> |
firstSearcherListeners |
private IndexReaderFactory |
indexReaderFactory |
private java.util.Map<java.lang.String,SolrInfoMBean> |
infoRegistry |
private static SolrCore |
instance
Deprecated.
Use
CoreContainer.getCore(String) instead. |
static org.slf4j.Logger |
log |
private java.lang.String |
logid |
private int |
maxWarmingSearchers |
private java.lang.String |
name |
(package private) java.util.List<SolrEventListener> |
newSearcherListeners |
private int |
onDeckSearchers |
private java.util.Map<java.lang.String,QParserPlugin> |
qParserPlugins |
private java.util.concurrent.atomic.AtomicInteger |
refCount |
private RequestHandlers |
reqHandlers |
private SolrResourceLoader |
resourceLoader |
private java.util.Map<java.lang.String,QueryResponseWriter> |
responseWriters |
private IndexSchema |
schema |
private java.util.Map<java.lang.String,SearchComponent> |
searchComponents |
(package private) java.util.concurrent.ExecutorService |
searcherExecutor |
private java.lang.Object |
searcherLock |
private SolrConfig |
solrConfig |
private IndexDeletionPolicyWrapper |
solrDelPolicy |
private long |
startTime |
private UpdateHandler |
updateHandler |
private java.util.Map<java.lang.String,UpdateRequestProcessorChain> |
updateProcessorChains |
private java.util.HashMap<java.lang.String,ValueSourceParser> |
valueSourceParsers |
static java.lang.String |
version |
Constructor and Description |
---|
SolrCore(java.lang.String dataDir,
IndexSchema schema) |
SolrCore(java.lang.String name,
java.lang.String dataDir,
SolrConfig config,
IndexSchema schema,
CoreDescriptor cd)
Creates a new core and register it in the list of cores.
|
Modifier and Type | Method and Description |
---|---|
void |
addCloseHook(CloseHook hook)
Add a close callback hook
|
private <T> void |
addIfNotPresent(java.util.Map<java.lang.String,T> registry,
java.lang.String name,
java.lang.Class<? extends T> c) |
(package private) void |
booleanQueryMaxClauseCount() |
void |
close()
Close all resources allocated by the core if it is no longer in use...
|
void |
closeSearcher() |
SolrEventListener |
createEventListener(java.lang.String className) |
<T> T |
createInitInstance(PluginInfo info,
java.lang.Class<T> cast,
java.lang.String msg,
java.lang.String defClassName) |
private <T> T |
createInstance(java.lang.String className,
java.lang.Class<T> cast,
java.lang.String msg)
Creates an instance by trying a constructor that accepts a SolrCore before
trying the default (no arg) constructor.
|
private QueryResponseWriter |
createQueryResponseWriter(java.lang.String className) |
SolrRequestHandler |
createRequestHandler(java.lang.String className) |
private UpdateHandler |
createUpdateHandler(java.lang.String className) |
void |
execute(SolrQueryRequest req,
SolrQueryResponse rsp)
Deprecated.
|
void |
execute(SolrRequestHandler handler,
SolrQueryRequest req,
SolrQueryResponse rsp) |
protected void |
finalize() |
SolrInfoMBean.Category |
getCategory()
Purpose of this Class
|
java.lang.String |
getConfigFile()
Deprecated.
Use
getConfigResource() instead. |
java.lang.String |
getConfigResource()
Gets the configuration resource name used by this core instance.
|
CoreDescriptor |
getCoreDescriptor() |
java.lang.String |
getDataDir() |
IndexDeletionPolicyWrapper |
getDeletionPolicy() |
java.lang.String |
getDescription()
Simple one or two line description
|
DirectoryFactory |
getDirectoryFactory() |
java.net.URL[] |
getDocs()
Documentation URL list.
|
SolrHighlighter |
getHighlighter()
Deprecated.
|
java.lang.String |
getIndexDir() |
IndexReaderFactory |
getIndexReaderFactory() |
java.util.Map<java.lang.String,SolrInfoMBean> |
getInfoRegistry()
Returns a Map of name vs SolrInfoMBean objects.
|
java.lang.String |
getLogId() |
java.lang.String |
getName()
Simple common usage name, e.g.
|
RefCounted<SolrIndexSearcher> |
getNewestSearcher(boolean openNew)
Return the newest
RefCounted <SolrIndexSearcher > with
the reference count incremented. |
java.lang.String |
getNewIndexDir()
Returns the indexdir as given in index.properties.
|
int |
getOpenCount()
Current core usage count.
|
SolrQueryRequest |
getPingQueryRequest()
Deprecated.
use
PingRequestHandler instead |
QParserPlugin |
getQueryPlugin(java.lang.String parserName) |
QueryResponseWriter |
getQueryResponseWriter(SolrQueryRequest request)
Returns the appropriate writer for a request.
|
QueryResponseWriter |
getQueryResponseWriter(java.lang.String writerName)
Finds a writer by name, or returns the default writer if not found.
|
SolrRequestHandler |
getRequestHandler(java.lang.String handlerName)
Get the request handler registered to a given name.
|
java.util.Map<java.lang.String,SolrRequestHandler> |
getRequestHandlers()
Returns an unmodifieable Map containing the registered handlers
|
java.util.Map<java.lang.String,SolrRequestHandler> |
getRequestHandlers(java.lang.Class clazz)
Returns an unmodifieable Map containing the registered handlers of the specified type.
|
SolrResourceLoader |
getResourceLoader()
The SolrResourceLoader used to load all resources for this core.
|
IndexSchema |
getSchema()
Gets the schema object used by this core instance.
|
java.lang.String |
getSchemaFile()
Deprecated.
Use
getSchemaResource() instead. |
java.lang.String |
getSchemaResource()
Gets the schema resource name used by this core instance.
|
SearchComponent |
getSearchComponent(java.lang.String name) |
java.util.Map<java.lang.String,SearchComponent> |
getSearchComponents()
Accessor for all the Search Components
|
RefCounted<SolrIndexSearcher> |
getSearcher()
Return a registered
RefCounted <SolrIndexSearcher > with
the reference count incremented. |
RefCounted<SolrIndexSearcher> |
getSearcher(boolean forceNew,
boolean returnSearcher,
java.util.concurrent.Future[] waitSearcher)
Get a
SolrIndexSearcher or start the process of creating a new one. |
SolrConfig |
getSolrConfig()
Gets the configuration object used by this core instance.
|
static SolrCore |
getSolrCore()
Deprecated.
Use
CoreContainer.getCore(String) instead. |
java.lang.String |
getSource()
CVS Source, SVN Source, etc
|
java.lang.String |
getSourceId()
CVS Id, SVN Id, etc
|
long |
getStartTime() |
NamedList |
getStatistics()
Any statistics this instance would like to be publicly available via
the Solr Administration interface.
|
UpdateHandler |
getUpdateHandler()
RequestHandlers need access to the updateHandler so they can all talk to the
same RAM indexer.
|
UpdateRequestProcessorChain |
getUpdateProcessingChain(java.lang.String name) |
ValueSourceParser |
getValueSourceParser(java.lang.String parserName) |
java.lang.String |
getVersion()
Simple common usage version, e.g.
|
private void |
initDeletionPolicy() |
private void |
initDeprecatedSupport()
Manage anything that should be taken care of in case configs change
|
private void |
initDirectoryFactory() |
(package private) void |
initIndex() |
private void |
initIndexReaderFactory() |
private void |
initListeners() |
<T> java.util.List<T> |
initPlugins(java.util.List<PluginInfo> pluginInfos,
java.lang.Class<T> type,
java.lang.String defClassName)
For a given List of PluginInfo return the instances as a List
|
<T> T |
initPlugins(java.util.List<PluginInfo> pluginInfos,
java.util.Map<java.lang.String,T> registry,
java.lang.Class<T> type,
java.lang.String defClassName) |
<T> T |
initPlugins(java.util.Map<java.lang.String,T> registry,
java.lang.Class<T> type) |
<T> T |
initPlugins(java.util.Map<java.lang.String,T> registry,
java.lang.Class<T> type,
java.lang.String defClassName) |
private void |
initQParsers()
Configure the query parsers.
|
private void |
initValueSourceParsers()
Configure the ValueSource (function) plugins
|
private void |
initWriters()
Configure the query response writers.
|
boolean |
isClosed()
Whether this core is closed.
|
private java.util.Map<java.lang.String,SearchComponent> |
loadSearchComponents()
Register the default search components
|
private java.util.Map<java.lang.String,UpdateRequestProcessorChain> |
loadUpdateProcessorChains()
Load the request processors
|
static void |
log(java.lang.Throwable e) |
private RefCounted<SolrIndexSearcher> |
newHolder(SolrIndexSearcher newSearcher) |
SolrIndexSearcher |
newSearcher(java.lang.String name) |
SolrIndexSearcher |
newSearcher(java.lang.String name,
boolean readOnly) |
(package private) void |
open() |
void |
registerFirstSearcherListener(SolrEventListener listener)
NOTE: this function is not thread safe.
|
void |
registerNewSearcherListener(SolrEventListener listener)
NOTE: this function is not thread safe.
|
SolrRequestHandler |
registerRequestHandler(java.lang.String handlerName,
SolrRequestHandler handler)
Registers a handler at the specified location.
|
QueryResponseWriter |
registerResponseWriter(java.lang.String name,
QueryResponseWriter responseWriter)
NOTE: this function is not thread safe.
|
private void |
registerSearcher(RefCounted<SolrIndexSearcher> newSearcherHolder) |
void |
setName(java.lang.String v) |
static void |
setResponseHeaderValues(SolrRequestHandler handler,
SolrQueryRequest req,
SolrQueryResponse rsp) |
public static final java.lang.String version
public static org.slf4j.Logger log
private java.lang.String name
private java.lang.String logid
private final CoreDescriptor coreDescriptor
private final SolrConfig solrConfig
private final SolrResourceLoader resourceLoader
private final IndexSchema schema
private final java.lang.String dataDir
private final UpdateHandler updateHandler
private final long startTime
private final RequestHandlers reqHandlers
private final java.util.Map<java.lang.String,SearchComponent> searchComponents
private final java.util.Map<java.lang.String,UpdateRequestProcessorChain> updateProcessorChains
private final java.util.Map<java.lang.String,SolrInfoMBean> infoRegistry
private IndexDeletionPolicyWrapper solrDelPolicy
private DirectoryFactory directoryFactory
private IndexReaderFactory indexReaderFactory
@Deprecated private static SolrCore instance
CoreContainer.getCore(String)
instead.static int boolean_query_max_clause_count
final java.util.List<SolrEventListener> firstSearcherListeners
final java.util.List<SolrEventListener> newSearcherListeners
private static java.util.Set<java.lang.String> dirs
private final java.util.concurrent.atomic.AtomicInteger refCount
private java.util.Collection<CloseHook> closeHooks
private RefCounted<SolrIndexSearcher> _searcher
private final java.util.LinkedList<RefCounted<SolrIndexSearcher>> _searchers
final java.util.concurrent.ExecutorService searcherExecutor
private int onDeckSearchers
private java.lang.Object searcherLock
private final int maxWarmingSearchers
private QueryResponseWriter defaultResponseWriter
private final java.util.Map<java.lang.String,QueryResponseWriter> responseWriters
public static final java.util.Map<java.lang.String,QueryResponseWriter> DEFAULT_RESPONSE_WRITERS
private final java.util.Map<java.lang.String,QParserPlugin> qParserPlugins
private final java.util.HashMap<java.lang.String,ValueSourceParser> valueSourceParsers
public SolrCore(java.lang.String dataDir, IndexSchema schema) throws javax.xml.parsers.ParserConfigurationException, java.io.IOException, org.xml.sax.SAXException
dataDir
- schema
- org.xml.sax.SAXException
java.io.IOException
javax.xml.parsers.ParserConfigurationException
public SolrCore(java.lang.String name, java.lang.String dataDir, SolrConfig config, IndexSchema schema, CoreDescriptor cd)
dataDir
- the index directoryconfig
- a solr config instanceschema
- a solr schema instancepublic long getStartTime()
void booleanQueryMaxClauseCount()
public SolrResourceLoader getResourceLoader()
public java.lang.String getConfigResource()
@Deprecated public java.lang.String getConfigFile()
getConfigResource()
instead.public SolrConfig getSolrConfig()
public java.lang.String getSchemaResource()
@Deprecated public java.lang.String getSchemaFile()
getSchemaResource()
instead.public IndexSchema getSchema()
public java.lang.String getDataDir()
public java.lang.String getIndexDir()
public java.lang.String getNewIndexDir()
public DirectoryFactory getDirectoryFactory()
public IndexReaderFactory getIndexReaderFactory()
public java.lang.String getName()
SolrInfoMBean
getName
in interface SolrInfoMBean
public void setName(java.lang.String v)
public java.lang.String getLogId()
public java.util.Map<java.lang.String,SolrInfoMBean> getInfoRegistry()
private void initDeletionPolicy()
private void initListeners()
public void registerFirstSearcherListener(SolrEventListener listener)
inform( SolrCore core )
function for SolrCoreAware
classes.
Outside inform
, this could potentially throw a ConcurrentModificationExceptionSolrCoreAware
public void registerNewSearcherListener(SolrEventListener listener)
inform( SolrCore core )
function for SolrCoreAware
classes.
Outside inform
, this could potentially throw a ConcurrentModificationExceptionSolrCoreAware
public QueryResponseWriter registerResponseWriter(java.lang.String name, QueryResponseWriter responseWriter)
inform( SolrCore core )
function for SolrCoreAware
classes.
Outside inform
, this could potentially throw a ConcurrentModificationExceptionSolrCoreAware
public SolrIndexSearcher newSearcher(java.lang.String name) throws java.io.IOException
java.io.IOException
public SolrIndexSearcher newSearcher(java.lang.String name, boolean readOnly) throws java.io.IOException
java.io.IOException
private void initDirectoryFactory()
private void initIndexReaderFactory()
void initIndex()
private <T> T createInstance(java.lang.String className, java.lang.Class<T> cast, java.lang.String msg)
className
- the instance class to createcast
- the class or interface that the instance should extend or implementmsg
- a message helping compose the exception error if any occurs.SolrException
- if the object could not be instantiatedpublic <T> T createInitInstance(PluginInfo info, java.lang.Class<T> cast, java.lang.String msg, java.lang.String defClassName)
public SolrEventListener createEventListener(java.lang.String className)
public SolrRequestHandler createRequestHandler(java.lang.String className)
private UpdateHandler createUpdateHandler(java.lang.String className)
@Deprecated public static SolrCore getSolrCore()
CoreContainer.getCore(String)
instead.private QueryResponseWriter createQueryResponseWriter(java.lang.String className)
private java.util.Map<java.lang.String,UpdateRequestProcessorChain> loadUpdateProcessorChains()
public UpdateRequestProcessorChain getUpdateProcessingChain(java.lang.String name)
final void open()
public void close()
The behavior of this method is determined by the result of decrementing the core's reference count (A core is created with a refrence count of 1)...
isClosed()
public int getOpenCount()
public boolean isClosed()
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
public void addCloseHook(CloseHook hook)
@Deprecated public SolrQueryRequest getPingQueryRequest()
PingRequestHandler
insteadpublic SolrRequestHandler getRequestHandler(java.lang.String handlerName)
public java.util.Map<java.lang.String,SolrRequestHandler> getRequestHandlers(java.lang.Class clazz)
public java.util.Map<java.lang.String,SolrRequestHandler> getRequestHandlers()
@Deprecated public SolrHighlighter getHighlighter()
public SolrRequestHandler registerRequestHandler(java.lang.String handlerName, SolrRequestHandler handler)
null
at its path
Once registered the handler can be accessed through:
http://${host}:${port}/${context}/${handlerName} or: http://${host}:${port}/${context}/select?qt=${handlerName}Handlers must be initalized before getting registered. Registered handlers can immediatly accept requests. This call is thread safe.
SolrRequestHandler
registered to this name null
if none.private java.util.Map<java.lang.String,SearchComponent> loadSearchComponents()
private <T> void addIfNotPresent(java.util.Map<java.lang.String,T> registry, java.lang.String name, java.lang.Class<? extends T> c)
public SearchComponent getSearchComponent(java.lang.String name)
public java.util.Map<java.lang.String,SearchComponent> getSearchComponents()
public UpdateHandler getUpdateHandler()
public RefCounted<SolrIndexSearcher> getSearcher()
RefCounted
<SolrIndexSearcher
> with
the reference count incremented. It must be decremented when no longer needed.
This method should not be called from SolrCoreAware.inform() since it can result
in a deadlock if useColdSearcher==false.
If handling a normal request, the searcher should be obtained from
SolrQueryRequest.getSearcher()
instead.public RefCounted<SolrIndexSearcher> getNewestSearcher(boolean openNew)
RefCounted
<SolrIndexSearcher
> with
the reference count incremented. It must be decremented when no longer needed.
If no searcher is currently open, then if openNew==true a new searcher will be opened,
or null is returned if openNew==false.public RefCounted<SolrIndexSearcher> getSearcher(boolean forceNew, boolean returnSearcher, java.util.concurrent.Future[] waitSearcher) throws java.io.IOException
SolrIndexSearcher
or start the process of creating a new one.
The registered searcher is the default searcher used to service queries. A searcher will normally be registered after all of the warming and event handlers (newSearcher or firstSearcher events) have run. In the case where there is no registered searcher, the newly created searcher will be registered before running the event handlers (a slow searcher is better than no searcher).
These searchers contain read-only IndexReaders. To access a non read-only IndexReader, see newSearcher(String name, boolean readOnly).
If forceNew==true then A new searcher will be opened and registered regardless of whether there is already a registered searcher or other searchers in the process of being created.
If forceNew==false then:
If returnSearcher==true then a RefCounted
<SolrIndexSearcher
> will be returned with
the reference count incremented. It must be decremented when no longer needed.
If waitSearcher!=null and a new SolrIndexSearcher
was created,
then it is filled in with a Future that will return after the searcher is registered. The Future may be set to
null in which case the SolrIndexSearcher created has already been registered at the time
this method returned.
forceNew
- if true, force the open of a new index searcher regardless if there is already one open.returnSearcher
- if true, returns a SolrIndexSearcher
holder with the refcount already incremented.waitSearcher
- if non-null, will be filled in with a Future
that will return after the new searcher is registered.java.io.IOException
private RefCounted<SolrIndexSearcher> newHolder(SolrIndexSearcher newSearcher)
private void registerSearcher(RefCounted<SolrIndexSearcher> newSearcherHolder) throws java.io.IOException
java.io.IOException
public void closeSearcher()
public void execute(SolrRequestHandler handler, SolrQueryRequest req, SolrQueryResponse rsp)
@Deprecated public void execute(SolrQueryRequest req, SolrQueryResponse rsp)
execute(SolrRequestHandler, SolrQueryRequest, SolrQueryResponse)
instead.public static void setResponseHeaderValues(SolrRequestHandler handler, SolrQueryRequest req, SolrQueryResponse rsp)
public static final void log(java.lang.Throwable e)
private void initWriters()
public final QueryResponseWriter getQueryResponseWriter(java.lang.String writerName)
public final QueryResponseWriter getQueryResponseWriter(SolrQueryRequest request)
private void initQParsers()
public QParserPlugin getQueryPlugin(java.lang.String parserName)
private void initValueSourceParsers()
public <T> T initPlugins(java.util.Map<java.lang.String,T> registry, java.lang.Class<T> type, java.lang.String defClassName)
registry
- The map to which the instance should be added to. The key is the name attributetype
- the class or interface that the instance should extend or implement.defClassName
- If PluginInfo does not have a classname, use this as the classnamepublic <T> T initPlugins(java.util.List<PluginInfo> pluginInfos, java.util.Map<java.lang.String,T> registry, java.lang.Class<T> type, java.lang.String defClassName)
public <T> java.util.List<T> initPlugins(java.util.List<PluginInfo> pluginInfos, java.lang.Class<T> type, java.lang.String defClassName)
defClassName
- The default classname if PluginInfo#className == nullpublic <T> T initPlugins(java.util.Map<java.lang.String,T> registry, java.lang.Class<T> type)
registry
- The map to which the instance should be added to. The key is the name attributetype
- The type of the Plugin. These should be standard ones registerd by type.getName() in SolrConfigpublic ValueSourceParser getValueSourceParser(java.lang.String parserName)
private void initDeprecatedSupport()
public CoreDescriptor getCoreDescriptor()
public IndexDeletionPolicyWrapper getDeletionPolicy()
public java.lang.String getVersion()
SolrInfoMBean
getVersion
in interface SolrInfoMBean
public java.lang.String getDescription()
SolrInfoMBean
getDescription
in interface SolrInfoMBean
public SolrInfoMBean.Category getCategory()
SolrInfoMBean
getCategory
in interface SolrInfoMBean
public java.lang.String getSourceId()
SolrInfoMBean
getSourceId
in interface SolrInfoMBean
public java.lang.String getSource()
SolrInfoMBean
getSource
in interface SolrInfoMBean
public java.net.URL[] getDocs()
SolrInfoMBean
Suggested documentation URLs: Homepage for sponsoring project, FAQ on class usage, Design doc for class, Wiki, bug reporting URL, etc...
getDocs
in interface SolrInfoMBean
public NamedList getStatistics()
SolrInfoMBean
Any Object type may be stored in the list, but only the
toString()
representation will be used.
getStatistics
in interface SolrInfoMBean