本文整理汇总了Java中org.apache.solr.core.SolrResourceLoader类的典型用法代码示例。如果您正苦于以下问题:Java SolrResourceLoader类的具体用法?Java SolrResourceLoader怎么用?Java SolrResourceLoader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SolrResourceLoader类属于org.apache.solr.core包,在下文中一共展示了SolrResourceLoader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getDict
import org.apache.solr.core.SolrResourceLoader; //导入依赖的package包/类
public static Dictionary getDict(String dicPath, ResourceLoader loader) {
Dictionary dic = null;
if(dicPath != null) {
File f = new File(dicPath);
if(!f.isAbsolute() && loader instanceof SolrResourceLoader) { //相对目录
SolrResourceLoader srl = (SolrResourceLoader) loader;
dicPath = srl.getInstanceDir()+dicPath;
f = new File(dicPath);
}
dic = Dictionary.getInstance(f);
} else {
dic = Dictionary.getInstance();
}
return dic;
}
开发者ID:wanghaile,项目名称:mmseg4j,代码行数:17,代码来源:Utils.java
示例2: init
import org.apache.solr.core.SolrResourceLoader; //导入依赖的package包/类
@Override
protected void init(IndexSchema schema, Map<String, String> args) {
SolrResourceLoader loader = schema.getResourceLoader();
if (args.containsKey(SERIALIZER_ARGNAME)) {
serializer = loader.newInstance(args.remove(SERIALIZER_ARGNAME), TextTransformer.class);
}
if (args.containsKey(DISPLAYIZER_ARGNAME)) {
displayizer = loader.newInstance(args.remove(DISPLAYIZER_ARGNAME), TextTransformer.class);
}
if (args.containsKey(PAYLOAD_HANDLER_ARGNAME)) {
payloadHandler = loader.newInstance(args.remove(PAYLOAD_HANDLER_ARGNAME), FacetPayload.class);
} else {
payloadHandler = new DefaultPayloadHandler();
}
if (args.containsKey(HIERARCHY_LEVEL_ARGNAME)) {
hierarchyLevel = loader.newInstance(args.remove(HIERARCHY_LEVEL_ARGNAME), Integer.class);
}
delim = initDelim(hierarchyLevel);
delimBytes = delim.getBytes(StandardCharsets.UTF_8);
super.init(schema, args);
}
开发者ID:upenn-libraries,项目名称:solrplugins,代码行数:22,代码来源:CaseInsensitiveSortingTextField.java
示例3: testDateFacets
import org.apache.solr.core.SolrResourceLoader; //导入依赖的package包/类
@Test
public void testDateFacets() throws Exception {
XMLResponseParser parser = new XMLResponseParser();
InputStream is = new SolrResourceLoader(null, null).openResource("solrj/sampleDateFacetResponse.xml");
assertNotNull(is);
Reader in = new InputStreamReader(is, StandardCharsets.UTF_8);
NamedList<Object> response = parser.processResponse(in);
in.close();
QueryResponse qr = new QueryResponse(response, null);
Assert.assertNotNull(qr);
Assert.assertNotNull(qr.getFacetDates());
for (FacetField f : qr.getFacetDates()) {
Assert.assertNotNull(f);
// TODO - test values?
// System.out.println(f.toString());
// System.out.println("GAP: " + f.getGap());
// System.out.println("END: " + f.getEnd());
}
}
开发者ID:europeana,项目名称:search,代码行数:24,代码来源:QueryResponseTest.java
示例4: TestHarness
import org.apache.solr.core.SolrResourceLoader; //导入依赖的package包/类
/**
* @param coreName to initialize
* @param dataDir path for index data, will not be cleaned up
* @param solrConfig solrconfig resource name
* @param indexSchema schema resource name
*/
public TestHarness(String coreName, String dataDir, String solrConfig, String indexSchema) {
try {
if (coreName == null)
coreName = ConfigSolrXmlOld.DEFAULT_DEFAULT_CORE_NAME;
this.coreName = coreName;
SolrResourceLoader loader = new SolrResourceLoader(SolrResourceLoader.locateSolrHome());
ConfigSolr config = getTestHarnessConfig(loader, coreName, dataDir, solrConfig, indexSchema);
container = new CoreContainer(loader, config);
container.load();
updater = new UpdateRequestHandler();
updater.init( null );
} catch (Exception e) {
throw new RuntimeException(e);
}
}
开发者ID:europeana,项目名称:search,代码行数:24,代码来源:TestHarness.java
示例5: getTestHarnessConfig
import org.apache.solr.core.SolrResourceLoader; //导入依赖的package包/类
private static ConfigSolr getTestHarnessConfig(SolrResourceLoader loader, String coreName, String dataDir,
String solrConfig, String schema) {
String solrxml = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
+ "<solr persistent=\"false\">\n"
+ " <cores adminPath=\"/admin/cores\" defaultCoreName=\""
+ ConfigSolrXmlOld.DEFAULT_DEFAULT_CORE_NAME
+ "\""
+ " host=\"${host:}\" hostPort=\"${hostPort:}\" hostContext=\"${hostContext:}\""
+ " distribUpdateSoTimeout=\"30000\""
+ " zkClientTimeout=\"${zkClientTimeout:30000}\" distribUpdateConnTimeout=\"30000\""
+ ">\n"
+ " <core name=\"" + coreName + "\" config=\"" + solrConfig
+ "\" schema=\"" + schema + "\" dataDir=\"" + dataDir
+ "\" transient=\"false\" loadOnStartup=\"true\""
+ " shard=\"${shard:shard1}\" collection=\"${collection:collection1}\" instanceDir=\"" + coreName + "/\" />\n"
+ " </cores>\n" + "</solr>";
return ConfigSolr.fromString(loader, solrxml);
}
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:TestHarness.java
示例6: newRegisteredLogWatcher
import org.apache.solr.core.SolrResourceLoader; //导入依赖的package包/类
/**
* Create and register a LogWatcher.
*
* JUL and Log4j watchers are supported out-of-the-box. You can register your own
* LogWatcher implementation via the plugins architecture
*
* @param config a LogWatcherConfig object, containing the configuration for this LogWatcher.
* @param loader a SolrResourceLoader, to be used to load plugin LogWatcher implementations.
* Can be null if one of the built-in implementations is being used.
*
* @return a LogWatcher configured for the container's logging framework
*/
public static LogWatcher newRegisteredLogWatcher(LogWatcherConfig config, SolrResourceLoader loader) {
if (!config.isEnabled()) {
log.info("A LogWatcher is not enabled");
return null;
}
LogWatcher logWatcher = createWatcher(config, loader);
if (logWatcher != null) {
if (config.getWatcherSize() > 0) {
log.info("Registering Log Listener [{}]", logWatcher.getName());
logWatcher.registerListener(config.asListenerConfig());
}
}
return logWatcher;
}
开发者ID:europeana,项目名称:search,代码行数:31,代码来源:LogWatcher.java
示例7: shouldMutate
import org.apache.solr.core.SolrResourceLoader; //导入依赖的package包/类
/**
* Utility method that can be used to define a FieldNameSelector
* using the same types of rules as the FieldMutatingUpdateProcessor init
* code. This may be useful for Factories that wish to define default
* selectors in similar terms to what the configuration would look like.
* @lucene.internal
*/
public static FieldNameSelector createFieldNameSelector
(final SolrResourceLoader loader,
final SolrCore core,
final SelectorParams params,
final FieldNameSelector defSelector) {
if (params.noSelectorsSpecified()) {
return defSelector;
}
final ConfigurableFieldNameSelectorHelper helper =
new ConfigurableFieldNameSelectorHelper(loader, params);
return new FieldNameSelector() {
@Override
public boolean shouldMutate(String fieldName) {
return helper.shouldMutateBasedOnSchema(fieldName, core.getLatestSchema());
}
};
}
开发者ID:europeana,项目名称:search,代码行数:27,代码来源:FieldMutatingUpdateProcessor.java
示例8: getConfig
import org.apache.solr.core.SolrResourceLoader; //导入依赖的package包/类
public static CacheConfig getConfig(SolrConfig solrConfig, Node node) {
if (node==null) return null;
CacheConfig config = new CacheConfig();
config.nodeName = node.getNodeName();
config.args = DOMUtil.toMap(node.getAttributes());
String nameAttr = config.args.get("name"); // OPTIONAL
if (nameAttr==null) {
config.args.put("name",config.nodeName);
}
SolrResourceLoader loader = solrConfig.getResourceLoader();
config.cacheImpl = config.args.get("class");
config.regenImpl = config.args.get("regenerator");
config.clazz = loader.findClass(config.cacheImpl, SolrCache.class);
if (config.regenImpl != null) {
config.regenerator = loader.newInstance(config.regenImpl, CacheRegenerator.class);
}
return config;
}
开发者ID:europeana,项目名称:search,代码行数:21,代码来源:CacheConfig.java
示例9: newInstance
import org.apache.solr.core.SolrResourceLoader; //导入依赖的package包/类
/**
* Create a new ShardHandlerFactory instance
* @param info a PluginInfo object defining which type to create. If null,
* the default {@link HttpShardHandlerFactory} will be used
* @param loader a SolrResourceLoader used to find the ShardHandlerFactory classes
* @return a new, initialized ShardHandlerFactory instance
*/
public static ShardHandlerFactory newInstance(PluginInfo info, SolrResourceLoader loader) {
if (info == null)
info = DEFAULT_SHARDHANDLER_INFO;
try {
ShardHandlerFactory shf = loader.findClass(info.className, ShardHandlerFactory.class).newInstance();
if (PluginInfoInitialized.class.isAssignableFrom(shf.getClass()))
PluginInfoInitialized.class.cast(shf).init(info);
return shf;
}
catch (Exception e) {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
String.format(Locale.ROOT, "Error instantiating shardHandlerFactory class [%s]: %s",
info.className, e.getMessage()));
}
}
开发者ID:europeana,项目名称:search,代码行数:25,代码来源:ShardHandlerFactory.java
示例10: createManagedResource
import org.apache.solr.core.SolrResourceLoader; //导入依赖的package包/类
/**
* Creates a ManagedResource using registration information.
*/
protected ManagedResource createManagedResource(ManagedResourceRegistration reg) throws SolrException {
ManagedResource res = null;
try {
Constructor<? extends ManagedResource> ctor =
reg.implClass.getConstructor(String.class, SolrResourceLoader.class, StorageIO.class);
res = ctor.newInstance(reg.resourceId, loader, storageIO);
res.loadManagedDataAndNotify(reg.observers);
} catch (Exception e) {
String errMsg =
String.format(Locale.ROOT,
"Failed to create new ManagedResource %s of type %s due to: %s",
reg.resourceId, reg.implClass.getName(), e);
throw new SolrException(ErrorCode.SERVER_ERROR, errMsg, e);
}
return res;
}
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:RestManager.java
示例11: configure
import org.apache.solr.core.SolrResourceLoader; //导入依赖的package包/类
@Override
public void configure(SolrResourceLoader loader, NamedList<String> initArgs) throws SolrException {
// validate connectivity and the configured znode base
try {
if (!zkClient.exists(znodeBase, retryOnConnLoss)) {
zkClient.makePath(znodeBase, retryOnConnLoss);
}
} catch (Exception exc) {
String errMsg = String.format
(Locale.ROOT, "Failed to verify znode at %s due to: %s", znodeBase, exc.toString());
log.error(errMsg, exc);
throw new SolrException(ErrorCode.SERVER_ERROR, errMsg, exc);
}
log.info("Configured ZooKeeperStorageIO with znodeBase: "+znodeBase);
}
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:ManagedResourceStorage.java
示例12: create
import org.apache.solr.core.SolrResourceLoader; //导入依赖的package包/类
/** Returns an index schema created from a local resource */
public IndexSchema create(String resourceName, SolrConfig config) {
SolrResourceLoader loader = config.getResourceLoader();
InputStream schemaInputStream = null;
if (null == resourceName) {
resourceName = IndexSchema.DEFAULT_SCHEMA_FILE;
}
try {
schemaInputStream = loader.openSchema(resourceName);
} catch (Exception e) {
final String msg = "Error loading schema resource " + resourceName;
log.error(msg, e);
throw new SolrException(ErrorCode.SERVER_ERROR, msg, e);
}
InputSource inputSource = new InputSource(schemaInputStream);
inputSource.setSystemId(SystemIdResolver.createSystemIdFromResourceName(resourceName));
IndexSchema schema = new IndexSchema(config, resourceName, inputSource);
return schema;
}
开发者ID:europeana,项目名称:search,代码行数:22,代码来源:IndexSchemaFactory.java
示例13: readSimilarity
import org.apache.solr.core.SolrResourceLoader; //导入依赖的package包/类
static SimilarityFactory readSimilarity(SolrResourceLoader loader, Node node) {
if (node==null) {
return null;
} else {
SimilarityFactory similarityFactory;
final String classArg = ((Element) node).getAttribute(SimilarityFactory.CLASS_NAME);
final Object obj = loader.newInstance(classArg, Object.class, "search.similarities.");
if (obj instanceof SimilarityFactory) {
// configure a factory, get a similarity back
final NamedList<Object> namedList = DOMUtil.childNodesToNamedList(node);
namedList.add(SimilarityFactory.CLASS_NAME, classArg);
SolrParams params = SolrParams.toSolrParams(namedList);
similarityFactory = (SimilarityFactory)obj;
similarityFactory.init(params);
} else {
// just like always, assume it's a Similarity and get a ClassCastException - reasonable error handling
similarityFactory = new SimilarityFactory() {
@Override
public Similarity getSimilarity() {
return (Similarity) obj;
}
};
}
return similarityFactory;
}
}
开发者ID:europeana,项目名称:search,代码行数:27,代码来源:IndexSchema.java
示例14: testReloadFromPersistentStorage
import org.apache.solr.core.SolrResourceLoader; //导入依赖的package包/类
@Test
public void testReloadFromPersistentStorage() throws Exception {
SolrResourceLoader loader = new SolrResourceLoader("./");
File unitTestStorageDir = createTempDir("testRestManager");
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);
}
开发者ID:europeana,项目名称:search,代码行数:25,代码来源:TestRestManager.java
示例15: testZkBasedJsonStorage
import org.apache.solr.core.SolrResourceLoader; //导入依赖的package包/类
/**
* Runs persisted managed resource creation and update tests on Zookeeper storage.
*/
@Test
public void testZkBasedJsonStorage() throws Exception {
// test using ZooKeeper
assertTrue("Not using ZooKeeper", h.getCoreContainer().isZooKeeperAware());
SolrZkClient zkClient = h.getCoreContainer().getZkController().getZkClient();
SolrResourceLoader loader = new SolrResourceLoader("./");
// Solr unit tests can only write to their working directory due to
// a custom Java Security Manager installed in the test environment
NamedList<String> initArgs = new NamedList<>();
try {
ZooKeeperStorageIO zkStorageIO = new ZooKeeperStorageIO(zkClient, "/test");
zkStorageIO.configure(loader, initArgs);
doStorageTests(loader, zkStorageIO);
} finally {
zkClient.close();
}
}
开发者ID:europeana,项目名称:search,代码行数:22,代码来源:TestManagedResourceStorage.java
示例16: testZkHostDiscovery
import org.apache.solr.core.SolrResourceLoader; //导入依赖的package包/类
@Test
public void testZkHostDiscovery() throws ClassNotFoundException, NoSuchMethodException,
IllegalAccessException, InstantiationException, InvocationTargetException {
// Should see an error when zkHost is not defined but solr.solrxml.location is set to zookeeper.
System.clearProperty("zkHost");
try {
Method method = SolrDispatchFilter.class.getDeclaredMethod("loadConfigSolr", SolrResourceLoader.class);
method.setAccessible(true);
method.invoke(new SolrDispatchFilter(), new SolrResourceLoader(null));
fail("Should have thrown an exception");
} catch (InvocationTargetException ite) {
assertTrue("Should be catching a SolrException", ite.getTargetException() instanceof SolrException);
assertEquals("Caught Solr exception", ite.getTargetException().getMessage(),
"Could not load solr.xml from zookeeper: zkHost system property not set");
}
}
开发者ID:europeana,项目名称:search,代码行数:18,代码来源:SolrXmlInZkTest.java
示例17: checkInstanceDirs
import org.apache.solr.core.SolrResourceLoader; //导入依赖的package包/类
private void checkInstanceDirs(JettySolrRunner jetty) {
CoreContainer cores = ((SolrDispatchFilter) jetty.getDispatchFilter()
.getFilter()).getCores();
Collection<SolrCore> theCores = cores.getCores();
for (SolrCore core : theCores) {
if (!oldStyleSolrXml) {
// look for core props file
assertTrue("Could not find expected core.properties file",
new File((String) core.getStatistics().get("instanceDir"),
"core.properties").exists());
}
assertEquals(
new File(SolrResourceLoader.normalizeDir(jetty.getSolrHome() + File.separator
+ core.getName())).getAbsolutePath(),
new File(SolrResourceLoader.normalizeDir((String) core.getStatistics().get(
"instanceDir"))).getAbsolutePath());
}
}
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:CollectionsAPIDistributedZkTest.java
示例18: startSolr
import org.apache.solr.core.SolrResourceLoader; //导入依赖的package包/类
/**
* Start up an embedded Solr server.
*
* @param home The path to the Solr home directory
* @return EmbeddedSolrServer: The instantiated server
* @throws Exception if any errors occur
*/
private EmbeddedSolrServer startSolr(String home) throws Exception {
try {
SolrConfig solrConfig = new SolrConfig(home, SOLR_CONFIG, null);
IndexSchema schema = new IndexSchema(solrConfig, SOLR_SCHEMA, null);
solrContainer = new CoreContainer(new SolrResourceLoader(
SolrResourceLoader.locateSolrHome()));
CoreDescriptor descriptor = new CoreDescriptor(solrContainer, "",
solrConfig.getResourceLoader().getInstanceDir());
descriptor.setConfigName(solrConfig.getResourceName());
descriptor.setSchemaName(schema.getResourceName());
solrCore = new SolrCore(null, solrConfig.getDataDir(),
solrConfig, schema, descriptor);
solrContainer.register("cheese", solrCore, false);
// CoreAdminRequest.create
return new EmbeddedSolrServer(solrContainer, "cheese");
} catch(Exception ex) {
log.error("\nFailed to start Solr server\n");
throw ex;
}
}
开发者ID:openimaj,项目名称:openimaj,代码行数:30,代码来源:GeonamesIndexGenerator.java
示例19: registerModelTracker
import org.apache.solr.core.SolrResourceLoader; //导入依赖的package包/类
private ModelTracker registerModelTracker(SolrCore core, AlfrescoCoreAdminHandler adminHandler)
{
SolrResourceLoader loader = core.getLatestSchema().getResourceLoader();
SolrKeyResourceLoader keyResourceLoader = new SolrKeyResourceLoader(loader);
SOLRAPIClientFactory clientFactory = new SOLRAPIClientFactory();
Properties props = new CoreDescriptorDecorator(core.getCoreDescriptor()).getCoreProperties();
SOLRAPIClient repositoryClient = clientFactory.getSOLRAPIClient(props, keyResourceLoader,
AlfrescoSolrDataModel.getInstance().getDictionaryService(CMISStrictDictionaryService.DEFAULT),
AlfrescoSolrDataModel.getInstance().getNamespaceDAO());
String solrHome = core.getCoreDescriptor().getCoreContainer().getSolrHome();
SolrContentStore solrContentStore = new SolrContentStore(CoreWatcherJob.locateContentHome(solrHome));
SolrInformationServer srv = new SolrInformationServer(adminHandler, core, repositoryClient, solrContentStore);
ModelTracker mTracker = new ModelTracker(solrHome, props, repositoryClient, core.getName(), srv);
TrackerRegistry trackerRegistry = adminHandler.getTrackerRegistry();
trackerRegistry.setModelTracker(mTracker);
SolrTrackerScheduler scheduler = adminHandler.getScheduler();
scheduler.schedule(mTracker, core.getName(), props);
return mTracker;
}
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:21,代码来源:EnsureModelsComponent.java
示例20: getTestHarnessConfig
import org.apache.solr.core.SolrResourceLoader; //导入依赖的package包/类
private static ConfigSolr getTestHarnessConfig(SolrResourceLoader loader, String coreName, String dataDir,
String solrConfig, String schema) {
String solrxml = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
+ "<solr persistent=\"false\">\n"
+ " <cores adminHandler=\"org.alfresco.solr.AlfrescoCoreAdminHandler\" adminPath=\"/admin/cores\" defaultCoreName=\""
+ ConfigSolrXmlOld.DEFAULT_DEFAULT_CORE_NAME
+ "\""
+ " host=\"${host:}\" hostPort=\"${hostPort:}\" hostContext=\"${hostContext:}\""
+ " distribUpdateSoTimeout=\"30000\""
+ " zkClientTimeout=\"${zkClientTimeout:30000}\" distribUpdateConnTimeout=\"30000\""
+ ">\n"
+ " <core name=\"" + coreName + "\" config=\"" + solrConfig
+ "\" schema=\"" + schema + "\" dataDir=\"" + dataDir
+ "\" transient=\"false\" loadOnStartup=\"true\""
+ " shard=\"${shard:shard1}\" collection=\"${collection:collection1}\" instanceDir=\"" + coreName + "/\" />\n"
+ " </cores>\n" + "</solr>";
return ConfigSolr.fromString(loader, solrxml);
}
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:19,代码来源:AlfrescoSolrTestCaseJ4.java
注:本文中的org.apache.solr.core.SolrResourceLoader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论