Search in sources :

Example 1 with StandardDirectoryFactory

use of org.apache.solr.core.StandardDirectoryFactory in project lucene-solr by apache.

the class TestReplicationHandler method checkForSingleIndex.

private void checkForSingleIndex(JettySolrRunner jetty, boolean afterReload) {
    CoreContainer cores = jetty.getCoreContainer();
    Collection<SolrCore> theCores = cores.getCores();
    for (SolrCore core : theCores) {
        String ddir = core.getDataDir();
        CachingDirectoryFactory dirFactory = getCachingDirectoryFactory(core);
        synchronized (dirFactory) {
            Set<String> livePaths = dirFactory.getLivePaths();
            // we also allow one extra index dir - it may not be removed until the core is closed
            if (afterReload) {
                assertTrue(livePaths.toString() + ":" + livePaths.size(), 3 == livePaths.size() || 4 == livePaths.size());
            } else {
                assertTrue(livePaths.toString() + ":" + livePaths.size(), 3 == livePaths.size());
            }
        // :TODO: assert that one of the paths is a subpath of hte other
        }
        if (dirFactory instanceof StandardDirectoryFactory) {
            System.out.println(Arrays.asList(new File(ddir).list()));
            // we also allow one extra index dir - it may not be removed until the core is closed
            int cnt = indexDirCount(ddir);
            // if after reload, there may be 2 index dirs while the reloaded SolrCore closes.
            if (afterReload) {
                assertTrue("found:" + cnt + Arrays.asList(new File(ddir).list()).toString(), 1 == cnt || 2 == cnt);
            } else {
                assertTrue("found:" + cnt + Arrays.asList(new File(ddir).list()).toString(), 1 == cnt);
            }
        }
    }
}
Also used : CoreContainer(org.apache.solr.core.CoreContainer) SolrCore(org.apache.solr.core.SolrCore) StandardDirectoryFactory(org.apache.solr.core.StandardDirectoryFactory) CachingDirectoryFactory(org.apache.solr.core.CachingDirectoryFactory) File(java.io.File)

Aggregations

File (java.io.File)1 CachingDirectoryFactory (org.apache.solr.core.CachingDirectoryFactory)1 CoreContainer (org.apache.solr.core.CoreContainer)1 SolrCore (org.apache.solr.core.SolrCore)1 StandardDirectoryFactory (org.apache.solr.core.StandardDirectoryFactory)1