throw new ElasticsearchException(
"Could not find algorithm suite: " + suiteResourceName);
}
final List<String> failed = Lists.newArrayList();
final ProcessingComponentSuite suite = LoggerUtils.quietCall(new Callable<ProcessingComponentSuite>() {
public ProcessingComponentSuite call() throws Exception {
ProcessingComponentSuite suite = ProcessingComponentSuite.deserialize(
suiteResource, resourceLookup);
for (ProcessingComponentDescriptor desc : suite.removeUnavailableComponents()) {
failed.add(desc.getId());
if (isNoClassDefFound(desc.getInitializationFailure())) {
logger.debug("Algorithm not available on classpath: {}", desc.getId());
} else {
logger.debug("Algorithm initialization failed: {}", desc.getInitializationFailure(), desc.getId());
}
}
return suite;
}
},
Logger.getLogger(ProcessingComponentDescriptor.class),
Logger.getLogger(ReflectionUtils.class));
algorithms = Lists.newArrayList();
for (ProcessingComponentDescriptor descriptor : suite.getAlgorithms()) {
algorithms.add(descriptor.getId());
}
algorithms = Collections.unmodifiableList(algorithms);
if (!algorithms.isEmpty()) {
logger.info("Available clustering components: {}", Joiner.on(", ").join(algorithms));
}
if (!failed.isEmpty()) {
logger.info("Unavailable clustering components: {}", Joiner.on(", ").join(failed));
}
// Change the default resource lookup to include the configured location.
Map<String, Object> c2SettingsAsMap = Maps.newHashMap();
DefaultLexicalDataFactoryDescriptor.attributeBuilder(c2SettingsAsMap)
.resourceLookup(resourceLookup);
c2SettingsAsMap.putAll(c2Settings.getAsMap());
// Create component pool.
Integer poolSize = c2Settings.getAsInt(DEFAULT_COMPONENT_SIZE_PROPERTY_NAME, 0);
if (poolSize > 0) {
controller = ControllerFactory.createPooling(poolSize);
} else {
controller = ControllerFactory.createPooling();
}
controller.init(c2SettingsAsMap, suite.getComponentConfigurations());
} catch (Exception e) {
throw new ElasticsearchException(
"Could not start Carrot2 controller.", e);
}