Пример #1
0
  // Determine that when the query lists are commented out of both new and
  // first searchers in the config, we don't throw an NPE
  @Test
  public void testSearcherEvents() throws Exception {
    SolrCore core = h.getCore();
    SolrEventListener newSearcherListener = core.newSearcherListeners.get(0);
    assertTrue(
        "Not an instance of QuerySenderListener",
        newSearcherListener instanceof QuerySenderListener);
    QuerySenderListener qsl = (QuerySenderListener) newSearcherListener;

    RefCounted<SolrIndexSearcher> currentSearcherRef = core.getSearcher();
    SolrIndexSearcher currentSearcher = currentSearcherRef.get();
    SolrIndexSearcher dummy = null;
    qsl.newSearcher(currentSearcher, dummy); // test first Searcher (since param is null)
    MockQuerySenderListenerReqHandler mock =
        (MockQuerySenderListenerReqHandler) core.getRequestHandler("mock");
    assertNotNull("Mock is null", mock);
    assertNull("Req (firstsearcher) is not null", mock.req);

    SolrIndexSearcher newSearcher =
        new SolrIndexSearcher(
            core,
            core.getNewIndexDir(),
            core.getLatestSchema(),
            core.getSolrConfig().indexConfig,
            "testQuerySenderNoQuery",
            false,
            core.getDirectoryFactory());

    qsl.newSearcher(newSearcher, currentSearcher); // get newSearcher.
    assertNull("Req (newsearcher) is not null", mock.req);
    newSearcher.close();
    currentSearcherRef.decref();
  }
Пример #2
0
  @Test
  public void testLazyLoad() throws Exception {
    CoreContainer cc = init();
    try {

      // NOTE: This checks the initial state for loading, no need to do this elsewhere.
      checkInCores(cc, "collection1", "collectionLazy2", "collectionLazy5");
      checkNotInCores(
          cc,
          "collectionLazy3",
          "collectionLazy4",
          "collectionLazy6",
          "collectionLazy7",
          "collectionLazy8",
          "collectionLazy9");

      SolrCore core1 = cc.getCore("collection1");
      assertFalse("core1 should not be transient", core1.getCoreDescriptor().isTransient());
      assertTrue("core1 should be loadable", core1.getCoreDescriptor().isLoadOnStartup());
      assertNotNull(core1.getSolrConfig());

      SolrCore core2 = cc.getCore("collectionLazy2");
      assertTrue("core2 should be transient", core2.getCoreDescriptor().isTransient());
      assertTrue("core2 should be loadable", core2.getCoreDescriptor().isLoadOnStartup());

      SolrCore core3 = cc.getCore("collectionLazy3");
      assertTrue("core3 should be transient", core3.getCoreDescriptor().isTransient());
      assertFalse("core3 should not be loadable", core3.getCoreDescriptor().isLoadOnStartup());

      SolrCore core4 = cc.getCore("collectionLazy4");
      assertFalse("core4 should not be transient", core4.getCoreDescriptor().isTransient());
      assertFalse("core4 should not be loadable", core4.getCoreDescriptor().isLoadOnStartup());

      SolrCore core5 = cc.getCore("collectionLazy5");
      assertFalse("core5 should not be transient", core5.getCoreDescriptor().isTransient());
      assertTrue("core5 should be loadable", core5.getCoreDescriptor().isLoadOnStartup());

      core1.close();
      core2.close();
      core3.close();
      core4.close();
      core5.close();
    } finally {
      cc.shutdown();
    }
  }