Search in sources :

Example 1 with StorageIO

use of org.apache.solr.rest.ManagedResourceStorage.StorageIO in project lucene-solr by apache.

the class TestRestManager method testReloadFromPersistentStorage.

@Test
public void testReloadFromPersistentStorage() throws Exception {
    SolrResourceLoader loader = new SolrResourceLoader(Paths.get("./"));
    File unitTestStorageDir = createTempDir("testRestManager").toFile();
    assertTrue(unitTestStorageDir.getAbsolutePath() + " is not a directory!", unitTestStorageDir.isDirectory());
    assertTrue(unitTestStorageDir.canRead());
    assertTrue(unitTestStorageDir.canWrite());
    NamedList<String> ioInitArgs = new NamedList<>();
    ioInitArgs.add(ManagedResourceStorage.STORAGE_DIR_INIT_ARG, unitTestStorageDir.getAbsolutePath());
    StorageIO storageIO = new ManagedResourceStorage.FileStorageIO();
    storageIO.configure(loader, ioInitArgs);
    NamedList<String> initArgs = new NamedList<>();
    RestManager restManager = new RestManager();
    restManager.init(loader, initArgs, storageIO);
    // verifies a RestManager can be reloaded from a previous RestManager's data
    RestManager restManager2 = new RestManager();
    restManager2.init(loader, initArgs, storageIO);
}
Also used : SolrResourceLoader(org.apache.solr.core.SolrResourceLoader) NamedList(org.apache.solr.common.util.NamedList) StorageIO(org.apache.solr.rest.ManagedResourceStorage.StorageIO) File(java.io.File) Test(org.junit.Test)

Example 2 with StorageIO

use of org.apache.solr.rest.ManagedResourceStorage.StorageIO in project lucene-solr by apache.

the class SolrCore method initRestManager.

/**
   * Creates and initializes a RestManager based on configuration args in solrconfig.xml.
   * RestManager provides basic storage support for managed resource data, such as to
   * persist stopwords to ZooKeeper if running in SolrCloud mode.
   */
@SuppressWarnings("unchecked")
protected RestManager initRestManager() throws SolrException {
    PluginInfo restManagerPluginInfo = getSolrConfig().getPluginInfo(RestManager.class.getName());
    NamedList<String> initArgs = null;
    RestManager mgr = null;
    if (restManagerPluginInfo != null) {
        if (restManagerPluginInfo.className != null) {
            mgr = resourceLoader.newInstance(restManagerPluginInfo.className, RestManager.class);
        }
        if (restManagerPluginInfo.initArgs != null) {
            initArgs = (NamedList<String>) restManagerPluginInfo.initArgs;
        }
    }
    if (mgr == null)
        mgr = new RestManager();
    if (initArgs == null)
        initArgs = new NamedList<>();
    String collection = getCoreDescriptor().getCollectionName();
    StorageIO storageIO = ManagedResourceStorage.newStorageIO(collection, resourceLoader, initArgs);
    mgr.init(resourceLoader, initArgs, storageIO);
    return mgr;
}
Also used : NamedList(org.apache.solr.common.util.NamedList) StorageIO(org.apache.solr.rest.ManagedResourceStorage.StorageIO) RestManager(org.apache.solr.rest.RestManager)

Aggregations

NamedList (org.apache.solr.common.util.NamedList)2 StorageIO (org.apache.solr.rest.ManagedResourceStorage.StorageIO)2 File (java.io.File)1 SolrResourceLoader (org.apache.solr.core.SolrResourceLoader)1 RestManager (org.apache.solr.rest.RestManager)1 Test (org.junit.Test)1