Search in sources :

Example 1 with RestManager

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

the class TestModelManager method test.

@Test
public void test() throws Exception {
    final SolrResourceLoader loader = new SolrResourceLoader(tmpSolrHome.toPath());
    final RestManager.Registry registry = loader.getManagedResourceRegistry();
    assertNotNull("Expected a non-null RestManager.Registry from the SolrResourceLoader!", registry);
    final String resourceId = "/schema/fstore1";
    registry.registerManagedResource(resourceId, ManagedFeatureStore.class, new LTRQParserPlugin());
    final String resourceId2 = "/schema/mstore1";
    registry.registerManagedResource(resourceId2, ManagedModelStore.class, new LTRQParserPlugin());
    final NamedList<String> initArgs = new NamedList<>();
    final RestManager restManager = new RestManager();
    restManager.init(loader, initArgs, new ManagedResourceStorage.InMemoryStorageIO());
    final ManagedResource res = restManager.getManagedResource(resourceId);
    assertTrue(res instanceof ManagedFeatureStore);
    assertEquals(res.getResourceId(), resourceId);
}
Also used : SolrResourceLoader(org.apache.solr.core.SolrResourceLoader) NamedList(org.apache.solr.common.util.NamedList) LTRQParserPlugin(org.apache.solr.ltr.search.LTRQParserPlugin) ManagedResourceStorage(org.apache.solr.rest.ManagedResourceStorage) RestManager(org.apache.solr.rest.RestManager) ManagedResource(org.apache.solr.rest.ManagedResource) Test(org.junit.Test)

Example 2 with RestManager

use of org.apache.solr.rest.RestManager 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 RestManager (org.apache.solr.rest.RestManager)2 SolrResourceLoader (org.apache.solr.core.SolrResourceLoader)1 LTRQParserPlugin (org.apache.solr.ltr.search.LTRQParserPlugin)1 ManagedResource (org.apache.solr.rest.ManagedResource)1 ManagedResourceStorage (org.apache.solr.rest.ManagedResourceStorage)1 StorageIO (org.apache.solr.rest.ManagedResourceStorage.StorageIO)1 Test (org.junit.Test)1