org.apache.solr.core
Class SolrCore

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

public final class SolrCore
extends java.lang.Object

Version:
$Id: SolrCore.java 542679 2007-05-29 22:28:21Z ryan $
Author:
yonik, Mike Baranczak

Field Summary
static java.util.logging.Logger log
           
static SolrIndexConfig mainIndexConfig
           
static java.lang.String version
           
 
Constructor Summary
SolrCore(java.lang.String dataDir, IndexSchema schema)
           
 
Method Summary
 void close()
           
 void closeSearcher()
           
 void execute(SolrQueryRequest req, SolrQueryResponse rsp)
          Deprecated. 
 void execute(SolrRequestHandler handler, SolrQueryRequest req, SolrQueryResponse rsp)
           
protected  void finalize()
           
 java.lang.String getDataDir()
           
 java.lang.String getIndexDir()
           
 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
 IndexSchema getSchema()
           
 RefCounted<SolrIndexSearcher> getSearcher()
           
 RefCounted<SolrIndexSearcher> getSearcher(boolean forceNew, boolean returnSearcher, java.util.concurrent.Future[] waitSearcher)
          Get a SolrIndexSearcher or start the process of creating a new one.
static SolrCore getSolrCore()
           
 long getStartTime()
           
 UpdateHandler getUpdateHandler()
          RequestHandlers need access to the updateHandler so they can all talk to the same RAM indexer.
static void log(java.lang.Throwable e)
           
 SolrIndexSearcher newSearcher(java.lang.String name)
           
static java.util.List<SolrEventListener> parseListener(java.lang.String path)
           
 SolrRequestHandler registerRequestHandler(java.lang.String handlerName, SolrRequestHandler handler)
          Registers a handler at the specified location.
protected  void setResponseHeaderValues(SolrRequestHandler handler, NamedList<java.lang.Object> responseHeader, SolrQueryRequest req, SolrQueryResponse rsp)
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

version

public static final java.lang.String version
See Also:
Constant Field Values

log

public static java.util.logging.Logger log

mainIndexConfig

public static SolrIndexConfig mainIndexConfig
Constructor Detail

SolrCore

public SolrCore(java.lang.String dataDir,
                IndexSchema schema)
Method Detail

getStartTime

public long getStartTime()

parseListener

public static java.util.List<SolrEventListener> parseListener(java.lang.String path)

getSchema

public IndexSchema getSchema()

getDataDir

public java.lang.String getDataDir()

getIndexDir

public java.lang.String getIndexDir()

newSearcher

public SolrIndexSearcher newSearcher(java.lang.String name)
                              throws java.io.IOException
Throws:
java.io.IOException

getSolrCore

public static SolrCore getSolrCore()

close

public void close()

finalize

protected void finalize()
Overrides:
finalize in class java.lang.Object

getRequestHandler

public SolrRequestHandler getRequestHandler(java.lang.String handlerName)
Get the request handler registered to a given name. This function is thread safe.


getRequestHandlers

public java.util.Map<java.lang.String,SolrRequestHandler> getRequestHandlers()
Returns an unmodifieable Map containing the registered handlers


registerRequestHandler

public SolrRequestHandler registerRequestHandler(java.lang.String handlerName,
                                                 SolrRequestHandler handler)
Registers a handler at the specified location. If one exists there, it will be replaced. To remove a handler, register 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.

Returns:
the previous SolrRequestHandler registered to this name null if none.

getUpdateHandler

public UpdateHandler getUpdateHandler()
RequestHandlers need access to the updateHandler so they can all talk to the same RAM indexer.


getSearcher

public RefCounted<SolrIndexSearcher> getSearcher()

getSearcher

public RefCounted<SolrIndexSearcher> getSearcher(boolean forceNew,
                                                 boolean returnSearcher,
                                                 java.util.concurrent.Future[] waitSearcher)
                                          throws java.io.IOException
Get a 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).

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.

Parameters:
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.
Throws:
java.io.IOException

closeSearcher

public void closeSearcher()

execute

public void execute(SolrRequestHandler handler,
                    SolrQueryRequest req,
                    SolrQueryResponse rsp)

execute

@Deprecated
public void execute(SolrQueryRequest req,
                               SolrQueryResponse rsp)
Deprecated. 


setResponseHeaderValues

protected void setResponseHeaderValues(SolrRequestHandler handler,
                                       NamedList<java.lang.Object> responseHeader,
                                       SolrQueryRequest req,
                                       SolrQueryResponse rsp)

log

public static final void log(java.lang.Throwable e)

getQueryResponseWriter

public final QueryResponseWriter getQueryResponseWriter(java.lang.String writerName)
Finds a writer by name, or returns the default writer if not found.


getQueryResponseWriter

public final QueryResponseWriter getQueryResponseWriter(SolrQueryRequest request)
Returns the appropriate writer for a request. If the request specifies a writer via the 'wt' parameter, attempts to find that one; otherwise return the default writer.



Copyright © 2006 - 2008 The Apache Software Foundation