use of org.talend.dataprep.dataset.service.analysis.synchronous.SynchronousDataSetAnalyzer in project data-prep by Talend.
the class DataSetAnalyzersTest method testSynchronousOrder.
@Test
public void testSynchronousOrder() throws Exception {
synchronousAnalyzers.sort((analyzer1, analyzer2) -> analyzer1.order() - analyzer2.order());
int previousOrder = -1;
for (SynchronousDataSetAnalyzer synchronousAnalyzer : synchronousAnalyzers) {
assertThat(synchronousAnalyzer.order(), greaterThan(previousOrder));
}
}
use of org.talend.dataprep.dataset.service.analysis.synchronous.SynchronousDataSetAnalyzer in project data-prep by Talend.
the class BaseDataSetService method analyzeDataSet.
/**
* Performs the analysis on the given dataset id.
*
* @param id the dataset id.
* @param performAsyncBackgroundAnalysis true if the asynchronous background analysis should be performed.
* @param analysersToSkip the list of analysers to skip.
*/
protected final void analyzeDataSet(String id, boolean performAsyncBackgroundAnalysis, List<Class<? extends DataSetAnalyzer>> analysersToSkip) {
// Calls all synchronous analysis first
try {
for (SynchronousDataSetAnalyzer synchronousDataSetAnalyzer : synchronousAnalyzers) {
if (analysersToSkip.contains(synchronousDataSetAnalyzer.getClass())) {
continue;
}
LOG.info("Running {}", synchronousDataSetAnalyzer.getClass());
synchronousDataSetAnalyzer.analyze(id);
LOG.info("Done running {}", synchronousDataSetAnalyzer.getClass());
}
} catch (Exception e) {
// Clean up content & metadata (don't keep invalid information)
try {
final DataSetMetadata metadata = metadataBuilder.metadata().id(id).build();
contentStore.delete(metadata);
dataSetMetadataRepository.remove(id);
} catch (Exception unableToCleanResources) {
LOG.error("Unable to clean temporary resources for '{}'.", id, unableToCleanResources);
}
throw e;
}
// important log here (TDP-4137)
final DataSetMetadata metadata = dataSetMetadataRepository.get(id);
LOG.info("New DataSet #{}, name: {}, type: {}, from: {}", metadata.getId(), metadata.getName(), metadata.getContent().getMediaType(), metadata.getLocation().getStoreName());
// perform async analysis
if (performAsyncBackgroundAnalysis) {
LOG.debug("starting async background analysis");
publisher.publishEvent(new DatasetImportedEvent(id));
} else {
LOG.info("skipping asynchronous background analysis");
}
}
Aggregations