use of alien4cloud.exception.IndexingServiceException in project alien4cloud by alien4cloud.
the class ESIndexMapper method initIndices.
/**
* Create if not exist indices.
* A TTL can be defined for all indices under this index (ESearch TTL notation)
*
* @param indexName The index to initialize
* @param classes An array of classes to map to this index.
*/
@SneakyThrows({ IOException.class, IntrospectionException.class })
public void initIndices(String indexName, String ttl, Class<?>... classes) {
if (indexExist(indexName)) {
addToMappedClasses(indexName, classes);
} else {
// create the index and add the mapping
CreateIndexRequestBuilder createIndexRequestBuilder = esClient.getClient().admin().indices().prepareCreate(indexName);
for (Class<?> clazz : classes) {
String typeName = addToMappedClasses(indexName, clazz);
if (Modifier.isAbstract(clazz.getModifiers())) {
// no mapping to register for abstract classes.
continue;
}
String typeMapping = mappingBuilder.getMapping(clazz);
Map<String, Object> typesMap = JsonUtil.toMap(typeMapping);
addAlienScore(typesMap);
addTTL(typesMap, ttl);
Field generatedIdField = ReflectionUtil.getDeclaredField(clazz, EsGeneratedId.class);
if (generatedIdField != null) {
generatedIdField.setAccessible(true);
classTogeneratedIdFields.put(clazz, generatedIdField);
}
String mapping = jsonMapper.writeValueAsString(typesMap);
createIndexRequestBuilder.addMapping(typeName, mapping);
// add settings if any (including analysers definitions)
String indexSettings = mappingBuilder.getIndexSettings(clazz);
if (StringUtils.isNotBlank(indexSettings)) {
createIndexRequestBuilder.setSettings(indexSettings);
}
}
try {
final CreateIndexResponse createResponse = createIndexRequestBuilder.execute().actionGet();
if (!createResponse.isAcknowledged()) {
throw new IndexingServiceException("Failed to create index <" + indexName + ">");
}
} catch (Exception e) {
log.warn("Not able to init indice for index {}, maybe it has been created elsewhere", indexName);
}
}
}
use of alien4cloud.exception.IndexingServiceException in project alien4cloud by alien4cloud.
the class ElasticSearchUserDao method initEnvironment.
@PostConstruct
public void initEnvironment() {
// init ES annotation scanning
try {
mappingBuilder.initialize(User.class.getPackage().getName());
} catch (IntrospectionException | IOException e) {
throw new IndexingServiceException("Could not initialize elastic search mapping builder", e);
}
// init indexes and mapped classes
initIndices(User.class.getSimpleName().toLowerCase(), null, new Class<?>[] { User.class });
initCompleted();
}
use of alien4cloud.exception.IndexingServiceException in project alien4cloud by alien4cloud.
the class MonitorESDAO method initEnvironment.
/**
* Initialize the dao after being loaded by spring (Create the indexes).
*/
@PostConstruct
public void initEnvironment() {
// init ES annotation scanning
try {
getMappingBuilder().initialize("alien4cloud.paas.model");
} catch (IntrospectionException | IOException e) {
throw new IndexingServiceException("Could not initialize elastic search mapping builder", e);
}
// init indices and mapped classes
setJsonMapper(ElasticSearchMapper.getInstance());
Class<?>[] classes = new Class<?>[] { AbstractMonitorEvent.class, PaaSDeploymentStatusMonitorEvent.class, PaaSInstanceStateMonitorEvent.class, PaaSMessageMonitorEvent.class, PaaSInstancePersistentResourceMonitorEvent.class, PaaSWorkflowStepMonitorEvent.class, PaaSWorkflowMonitorEvent.class };
initIndices("deployedtopologies", null, DeploymentTopology.class);
initIndices("deploymentmonitorevents", eventMonitoringTtl, classes);
initIndices(PaaSDeploymentLog.class.getSimpleName().toLowerCase(), eventMonitoringTtl, PaaSDeploymentLog.class);
initCompleted();
}
use of alien4cloud.exception.IndexingServiceException in project alien4cloud by alien4cloud.
the class ElasticSearchDAO method initEnvironment.
/**
* Initialize the dao after being loaded by spring (Create the indexes).
*/
@PostConstruct
public void initEnvironment() {
// init ES annotation scanning
try {
getMappingBuilder().initialize("alien4cloud");
getMappingBuilder().initialize("org.alien4cloud");
getMappingBuilder().parseClassAnnotations(AbstractToscaType.class, "");
} catch (IntrospectionException | IOException e) {
throw new IndexingServiceException("Could not initialize elastic search mapping builder", e);
}
// init indices and mapped classes
setJsonMapper(ElasticSearchMapper.getInstance());
initIndices(TOSCA_ELEMENT_INDEX, null, CapabilityType.class, ArtifactType.class, RelationshipType.class, NodeType.class, DataType.class, PrimitiveDataType.class, PolicyType.class);
initIndices(TOSCA_ELEMENT_INDEX, null, AbstractInstantiableToscaType.class, AbstractToscaType.class);
initIndice(Application.class);
initIndice(ApplicationVersion.class);
initIndice(ApplicationEnvironment.class);
initIndice(Topology.class);
initIndice(Csar.class);
initIndice(Repository.class);
initIndice(ServiceResource.class);
initIndice(Plugin.class);
initIndice(PluginConfiguration.class);
initIndice(MetaPropConfiguration.class);
initIndice(Orchestrator.class);
initIndice(OrchestratorConfiguration.class);
initIndice(Location.class);
initIndices(LocationResourceTemplate.class.getSimpleName().toLowerCase(), null, LocationResourceTemplate.class, PolicyLocationResourceTemplate.class, AbstractLocationResourceTemplate.class);
initIndice(Deployment.class);
initIndice(CsarGitRepository.class);
initIndice(DeploymentInputs.class);
initIndice(DeploymentMatchingConfiguration.class);
initIndice(OrchestratorDeploymentProperties.class);
initIndice(DataObjectVersion.class);
initIndice(MaintenanceModeState.class);
initIndice(GitLocation.class);
initIndices(SUGGESTION_INDEX, null, AbstractSuggestionEntry.class, SuggestionEntry.class, SimpleSuggestionEntry.class);
initCompleted();
}
use of alien4cloud.exception.IndexingServiceException in project alien4cloud by alien4cloud.
the class ImageDAO method initEnvironment.
@PostConstruct
public void initEnvironment() {
// init ES annotation scanning
try {
mappingBuilder.initialize(ImageData.class.getPackage().getName());
} catch (IntrospectionException | IOException e) {
throw new IndexingServiceException("Could not initialize elastic search mapping builder", e);
}
// init indexes and mapped classes
initIndices(ImageData.class.getSimpleName().toLowerCase(), null, ImageData.class);
initCompleted();
}
Aggregations