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);
}
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;
}
Aggregations