Package org.apache.solr.request

Examples of org.apache.solr.request.SolrRequestHandler


  public SolrRequestHandler register( String handlerName, SolrRequestHandler handler ) {
    String norm = normalize( handlerName );
    if( handler == null ) {
      return handlers.remove( norm );
    }
    SolrRequestHandler old = handlers.put(norm, handler);
    if (0 != norm.length() && handler instanceof SolrInfoMBean) {
      core.getInfoRegistry().put(handlerName, handler);
    }
    return old;
  }
View Full Code Here


  void initHandlersFromConfig(SolrConfig config ){
    Map<PluginInfo,SolrRequestHandler> handlers = new HashMap<PluginInfo,SolrRequestHandler>();
    for (PluginInfo info : config.getPluginInfos(SolrRequestHandler.class.getName())) {
      try {
        SolrRequestHandler requestHandler;
        String startup = info.attributes.get("startup") ;
        if( startup != null ) {
          if( "lazy".equals(startup) ) {
            log.info("adding lazy requestHandler: " + info.className);
            requestHandler = new LazyRequestHandlerWrapper( core, info.className, info.initArgs );
          } else {
            throw new Exception( "Unknown startup value: '"+startup+"' for: "+info.className );
          }
        } else {
          requestHandler = core.createRequestHandler(info.className);
        }
        handlers.put(info,requestHandler);
        if (requestHandler instanceof PluginInfoInitialized) {
          ((PluginInfoInitialized) requestHandler).init(info);
        } else{
          requestHandler.init(info.initArgs);
        }
        SolrRequestHandler old = register(info.name, requestHandler);
        if(old != null) {
          log.warn("Multiple requestHandler registered to the same name: " + info.name + " ignoring: " + old.getClass().getName());
        }
        if(info.isDefault()){
          old = register("",requestHandler);
          if(old != null)
            log.warn("Multiple default requestHandler registered" + " ignoring: " + old.getClass().getName());
        }
        log.info("created "+info.name+": " + info.className);
      } catch (Exception e) {
          SolrConfig.severeErrors.add( e );
          SolrException.logOnce(log,null,e);
View Full Code Here

   
    /**
     * Wait for the first request before initializing the wrapped handler
     */
    public void handleRequest(SolrQueryRequest req, SolrQueryResponse rsp)  {
      SolrRequestHandler handler = _handler;
      if (handler == null) {
        handler = getWrappedHandler();
      }
      handler.handleRequest( req, rsp );
    }
View Full Code Here

    public synchronized SolrRequestHandler getWrappedHandler()
    {
      if( _handler == null ) {
        try {
          SolrRequestHandler handler = core.createRequestHandler(_className);
          handler.init( _args );

          if( handler instanceof SolrCoreAware ) {
            ((SolrCoreAware)handler).inform( core );
          }
          _handler = handler;
View Full Code Here

    EmptyRequestHandler handler1 = new EmptyRequestHandler();
    EmptyRequestHandler handler2 = new EmptyRequestHandler();

    String path = "/this/is A path /that won't be registered!";
    SolrRequestHandler old = core.registerRequestHandler( path, handler1 );
    assertNull( old ); // should not be anything...
    assertEquals( core.getRequestHandlers().get( path ), handler1 );
    old = core.registerRequestHandler( path, handler2 );
    assertEquals( old, handler1 ); // should pop out the old one
    assertEquals( core.getRequestHandlers().get( path ), handler2 );
View Full Code Here

    ClosingRequestHandler handler1 = new ClosingRequestHandler();
    handler1.inform( core );

    String path = "/this/is A path /that won't be registered!";
    SolrRequestHandler old = core.registerRequestHandler( path, handler1 );
    assertNull( old ); // should not be anything...
    assertEquals( core.getRequestHandlers().get( path ), handler1 );
    core.close();
    cores.shutdown();
    assertTrue("Handler not closed", handler1.closed == true);
View Full Code Here

    ClosingRequestHandler handler1 = new ClosingRequestHandler();
    handler1.inform( core );

    String path = "/this/is A path /that won't be registered!";
    SolrRequestHandler old = core.registerRequestHandler( path, handler1 );
    assertNull( old ); // should not be anything...
    assertEquals( core.getRequestHandlers().get( path ), handler1 );
  
    SolrCore c2 = cores.getCore("");
    c1.close();
View Full Code Here

    assertTrue("Refcount != 1", core.getOpenCount() == 1);

    final ClosingRequestHandler handler1 = new ClosingRequestHandler();
    handler1.inform(core);
    String path = "/this/is A path /that won't be registered!";
    SolrRequestHandler old = core.registerRequestHandler(path, handler1);
    assertNull(old); // should not be anything...
    assertEquals(core.getRequestHandlers().get(path), handler1);

    final int LOOP = 100;
    final int MT = 16;
View Full Code Here

  public String getSolrConfigFile() { return "solrconfig.xml"; }

 
  public void testLazyLoading() {
    SolrCore core = h.getCore();
    SolrRequestHandler handler = core.getRequestHandler( "lazy" );
    assertFalse( handler instanceof StandardRequestHandler );
   
    // But it should behave just like the 'defaults' request handler above
    assertU(adoc("id", "42",
                 "name", "Zapp Brannigan"));
View Full Code Here

  }
 
  public void testPathNormalization()
  {
    SolrCore core = h.getCore();
    SolrRequestHandler h1 = core.getRequestHandler("/update/csv" );
    assertNotNull( h1 );

    SolrRequestHandler h2 = core.getRequestHandler("/update/csv/" );
    assertNotNull( h2 );
   
    assertEquals( h1, h2 ); // the same object
   
    assertNull( core.getRequestHandler("/update/csv/asdgadsgas" ) ); // prefix
View Full Code Here

TOP

Related Classes of org.apache.solr.request.SolrRequestHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.