@Test public void testAnalysisWithLimit() { final DataSetMetadata metadata = createMetadata(UUID.randomUUID().toString(), Arrays.asList("id", "first_name", "last_name", "email", "gender", "ip_address")); metadataBuilder.metadata().id("3548").build(); createCsvDataSet(metadata, "100_lines.csv"); final Long newLimit = 16L; final Long originalLimit = (Long) ReflectionTestUtils.getField(contentAnalysis, ContentAnalysis.class, "sizeLimit"); ReflectionTestUtils.setField(contentAnalysis, "sizeLimit", newLimit); contentAnalysis.analyze(metadata.getId()); ReflectionTestUtils.setField(contentAnalysis, "sizeLimit", originalLimit); final DataSetMetadata actual = dataSetMetadataRepository.get(metadata.getId()); final Optional<Long> limit = actual.getContent().getLimit(); assertTrue(limit.isPresent()); assertThat(limit.get(), is(newLimit)); }
@Override public void analyze(String dataSetId) { if (StringUtils.isEmpty(dataSetId)) { throw new IllegalArgumentException("Data set id cannot be null or empty."); } DistributedLock datasetLock = repository.createDatasetMetadataLock(dataSetId); datasetLock.lock(); try { DataSetMetadata metadata = repository.get(dataSetId); if (metadata != null) { LOG.info("Indexing content of data set #{}...", metadata.getId()); updateHeaderAndFooter(metadata); updateLimit(metadata); metadata.getLifecycle().contentIndexed(true); DataSetMetadata savedDataSetMetadata = repository.get(dataSetId); if (savedDataSetMetadata != null) { repository.save(metadata); } LOG.info("Indexed content of data set #{}.", dataSetId); } else { LOG.info("Data set #{} no longer exists.", dataSetId); } } finally { datasetLock.unlock(); } }
ContentAnalysis implements SynchronousDataSetAnalyzer { @Override public void analyze(String dataSetId) { if (StringUtils.isEmpty(dataSetId)) { throw new IllegalArgumentException("Data set id cannot be null or empty."); } DistributedLock datasetLock = repository.createDatasetMetadataLock(dataSetId); datasetLock.lock(); try { DataSetMetadata metadata = repository.get(dataSetId); if (metadata != null) { LOG.info("Indexing content of data set #{}...", metadata.getId()); updateHeaderAndFooter(metadata); updateLimit(metadata); metadata.getLifecycle().contentIndexed(true); DataSetMetadata savedDataSetMetadata = repository.get(dataSetId); if (savedDataSetMetadata != null) { repository.save(metadata); } LOG.info("Indexed content of data set #{}.", dataSetId); } else { LOG.info("Data set #{} no longer exists.", dataSetId); } } finally { datasetLock.unlock(); } } }
ContentAnalysis implements SynchronousDataSetAnalyzer { @Override public void analyze(String dataSetId) { if (StringUtils.isEmpty(dataSetId)) { throw new IllegalArgumentException("Data set id cannot be null or empty."); } DistributedLock datasetLock = repository.createDatasetMetadataLock(dataSetId); datasetLock.lock(); try { DataSetMetadata metadata = repository.get(dataSetId); if (metadata != null) { LOG.info("Indexing content of data set #{}...", metadata.getId()); updateHeaderAndFooter(metadata); updateLimit(metadata); metadata.getLifecycle().contentIndexed(true); DataSetMetadata savedDataSetMetadata = repository.get(dataSetId); if (savedDataSetMetadata != null) { repository.save(metadata); } LOG.info("Indexed content of data set #{}.", dataSetId); } else { LOG.info("Data set #{} no longer exists.", dataSetId); } } finally { datasetLock.unlock(); } }  }
ContentAnalysis implements SynchronousDataSetAnalyzer { @Override public void analyze(String dataSetId) { if (StringUtils.isEmpty(dataSetId)) { throw new IllegalArgumentException("Data set id cannot be null or empty."); } DistributedLock datasetLock = repository.createDatasetMetadataLock(dataSetId); datasetLock.lock(); try { DataSetMetadata metadata = repository.get(dataSetId); if (metadata != null) { LOG.info("Indexing content of data set #{}...", metadata.getId()); updateHeaderAndFooter(metadata); updateLimit(metadata); metadata.getLifecycle().contentIndexed(true); DataSetMetadata savedDataSetMetadata = repository.get(dataSetId); if (savedDataSetMetadata != null) { repository.save(metadata); } LOG.info("Indexed content of data set #{}.", dataSetId); } else { LOG.info("Data set #{} no longer exists.", dataSetId); } } finally { datasetLock.unlock(); } }  @Override void analyze(String dataSetId); @Override int order(); }
ContentAnalysis implements SynchronousDataSetAnalyzer { @Override public void analyze(String dataSetId) { if (StringUtils.isEmpty(dataSetId)) { throw new IllegalArgumentException("Data set id cannot be null or empty."); } DistributedLock datasetLock = repository.createDatasetMetadataLock(dataSetId); datasetLock.lock(); try { DataSetMetadata metadata = repository.get(dataSetId); if (metadata != null) { LOG.info("Indexing content of data set #{}...", metadata.getId()); updateHeaderAndFooter(metadata); updateLimit(metadata); metadata.getLifecycle().contentIndexed(true); DataSetMetadata savedDataSetMetadata = repository.get(dataSetId); if (savedDataSetMetadata != null) { repository.save(metadata); } LOG.info("Indexed content of data set #{}.", dataSetId); } else { LOG.info("Data set #{} no longer exists.", dataSetId); } } finally { datasetLock.unlock(); } }  @Override void analyze(String dataSetId); @Override int order();  }