diff --git a/common/source/java/ch/systemsx/cisd/common/compression/file/Compressor.java b/common/source/java/ch/systemsx/cisd/common/compression/file/Compressor.java index 4db328382ff5fcca41640d7baf8b913ef9ef83f7..e387d305b3a9d2b2923af2d6a206ae9c610a8a64 100644 --- a/common/source/java/ch/systemsx/cisd/common/compression/file/Compressor.java +++ b/common/source/java/ch/systemsx/cisd/common/compression/file/Compressor.java @@ -83,19 +83,18 @@ public class Compressor return NUMBER_OF_PROCESSORS * threadsPerProcessor; } - private static void startUpWorkerThreads(int threadsPerProcessor, Queue<File> workerQueue, + private static void startUpWorkerThreads(AtomicInteger workersCounter, Queue<File> workerQueue, Collection<FailureRecord> failed, ICompressionMethod compressor) { - int workers = getInitialNumberOfWorkers(threadsPerProcessor); - AtomicInteger activeWorkers = new AtomicInteger(workers); - for (int i = 0; i < workers; ++i) + int counter = workersCounter.get(); + for (int i = 0; i < counter; ++i) { - new Thread(new CompressionWorker(workerQueue, failed, compressor, activeWorkers), + new Thread(new CompressionWorker(workerQueue, failed, compressor, workersCounter), "Compressor " + i).start(); } if (operationLog.isInfoEnabled()) { - operationLog.info(String.format("Started up %d worker threads.", workers)); + operationLog.info(String.format("Started up %d worker threads.", counter)); } } @@ -116,10 +115,15 @@ public class Compressor System.out.println("No files to compress."); return failed; } - startUpWorkerThreads(threadsPerProcessor, workerQueue, failed, compressionMethod); + AtomicInteger workersCounter = + new AtomicInteger(getInitialNumberOfWorkers(threadsPerProcessor)); + startUpWorkerThreads(workersCounter, workerQueue, failed, compressionMethod); synchronized (failed) { - failed.wait(); + while (workersCounter.get() > 0) + { + failed.wait(); + } } return failed; } diff --git a/common/source/java/ch/systemsx/cisd/common/compression/tiff/TiffConvertCompressionMethod.java b/common/source/java/ch/systemsx/cisd/common/compression/tiff/TiffConvertCompressionMethod.java index 16b445c3cbc79dd9900d9c798ebc228d1b0391b4..21aece30013ccbc2000081db83a33836f81bacc3 100644 --- a/common/source/java/ch/systemsx/cisd/common/compression/tiff/TiffConvertCompressionMethod.java +++ b/common/source/java/ch/systemsx/cisd/common/compression/tiff/TiffConvertCompressionMethod.java @@ -27,6 +27,7 @@ import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException; import ch.systemsx.cisd.common.logging.LogInitializer; import ch.systemsx.cisd.common.process.ProcessExecutionHelper; import ch.systemsx.cisd.common.process.ProcessResult; +import ch.systemsx.cisd.common.process.ProcessExecutionHelper.OutputReadingStrategy; /** * A compression method for TIFF files using the ImageMagick <code>convert</code> utility with @@ -47,7 +48,8 @@ public class TiffConvertCompressionMethod extends AbstractTiffCompressionMethod { final ProcessResult result = ProcessExecutionHelper.run(Arrays.asList(convertExecutableToCheck, "--version"), - operationLog, machineLog, Constants.MILLIS_TO_WAIT_BEFORE_TIMEOUT); + operationLog, machineLog, Constants.MILLIS_TO_WAIT_BEFORE_TIMEOUT, + OutputReadingStrategy.ALWAYS, true); result.log(); final String versionString = extractImageMagickVersion(result.getOutput().get(0)); return versionString; @@ -111,10 +113,6 @@ public class TiffConvertCompressionMethod extends AbstractTiffCompressionMethod public void check() throws EnvironmentFailureException, ConfigurationFailureException { super.check(); - if (true) // FIXME this check doesn't work properly - { - return; - } final String imageMagickVersionOrNull = getImageMagickVersion(executable.getAbsolutePath()); if (imageMagickVersionOrNull == null) {