Search in sources :

Example 1 with DatasetImportedEvent

use of org.talend.dataprep.dataset.event.DatasetImportedEvent in project data-prep by Talend.

the class AnalysisEventProcessingTest method testEventLaunchAnalysis.

@Test
public void testEventLaunchAnalysis() {
    DatasetImportedEvent event = new DatasetImportedEvent("datasetId");
    listener.onEvent(event);
    verify(analysisEventProcessingUtil, times(1)).processAnalysisEvent(any());
}
Also used : DatasetImportedEvent(org.talend.dataprep.dataset.event.DatasetImportedEvent) Test(org.junit.Test)

Example 2 with DatasetImportedEvent

use of org.talend.dataprep.dataset.event.DatasetImportedEvent 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");
    }
}
Also used : SynchronousDataSetAnalyzer(org.talend.dataprep.dataset.service.analysis.synchronous.SynchronousDataSetAnalyzer) TDPException(org.talend.dataprep.exception.TDPException) DataSetMetadata(org.talend.dataprep.api.dataset.DataSetMetadata) DatasetImportedEvent(org.talend.dataprep.dataset.event.DatasetImportedEvent)

Example 3 with DatasetImportedEvent

use of org.talend.dataprep.dataset.event.DatasetImportedEvent in project data-prep by Talend.

the class StatisticsAnalysisTest method initializeDataSetMetadata.

/**
 * Initialize a dataset with the given content. Perform the format and the schema analysis.
 *
 * @param content the dataset content.
 * @return the analyzed dataset metadata.
 */
private DataSetMetadata initializeDataSetMetadata(InputStream content) {
    String id = UUID.randomUUID().toString();
    final DataSetMetadata metadata = metadataBuilder.metadata().id(id).build();
    dataSetMetadataRepository.save(metadata);
    contentStore.storeAsRaw(metadata, content);
    formatAnalysis.analyze(id);
    contentAnalysis.analyze(id);
    schemaAnalysis.analyze(id);
    statisticsAnalysis.onEvent(new DatasetImportedEvent(id));
    final DataSetMetadata analyzed = dataSetMetadataRepository.get(id);
    assertThat(analyzed.getLifecycle().schemaAnalyzed(), is(true));
    return analyzed;
}
Also used : DataSetMetadata(org.talend.dataprep.api.dataset.DataSetMetadata) DatasetImportedEvent(org.talend.dataprep.dataset.event.DatasetImportedEvent)

Aggregations

DatasetImportedEvent (org.talend.dataprep.dataset.event.DatasetImportedEvent)3 DataSetMetadata (org.talend.dataprep.api.dataset.DataSetMetadata)2 Test (org.junit.Test)1 SynchronousDataSetAnalyzer (org.talend.dataprep.dataset.service.analysis.synchronous.SynchronousDataSetAnalyzer)1 TDPException (org.talend.dataprep.exception.TDPException)1