diff --git a/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/Directory.java b/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/Directory.java index 25a822a17a29233d7df46a775a02712e892b7ae3..fb8fa52b7df6367e89ecc95bec0d45ab1cd3661b 100644 --- a/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/Directory.java +++ b/bds/source/java/ch/systemsx/cisd/bds/storage/filesystem/Directory.java @@ -159,7 +159,7 @@ final class Directory extends AbstractNode implements IDirectory assert name != null : "Name can not be null."; final java.io.File file = getNodeFile(node); final java.io.File fileLink = - LinkMakerProvider.getLinkMaker().tryCopy(file, nodeFile, name); + LinkMakerProvider.getLinkMaker().tryImmutableCopy(file, nodeFile, name); if (fileLink != null) { final Link link = (Link) NodeFactory.createLinkNode(name, file); diff --git a/common/source/java/ch/systemsx/cisd/common/utilities/IPathImmutableCopier.java b/common/source/java/ch/systemsx/cisd/common/utilities/IPathImmutableCopier.java index d37c1c010c49f9a0f8e635ae218eea2d6586b6b3..699d15d8231d55c60982004cbc52875ac26d283d 100644 --- a/common/source/java/ch/systemsx/cisd/common/utilities/IPathImmutableCopier.java +++ b/common/source/java/ch/systemsx/cisd/common/utilities/IPathImmutableCopier.java @@ -38,5 +38,5 @@ public interface IPathImmutableCopier * @param nameOrNull the link name in the destination directory. * @return the new path created, or <code>null</code> if the operation fails. */ - File tryCopy(final File path, final File destinationDirectory, final String nameOrNull); + File tryImmutableCopy(final File path, final File destinationDirectory, final String nameOrNull); } diff --git a/common/source/java/ch/systemsx/cisd/common/utilities/RecursiveHardLinkMaker.java b/common/source/java/ch/systemsx/cisd/common/utilities/RecursiveHardLinkMaker.java index cde309fa3065de1c65ad12d2a723d8d5c236826c..411b98372f13e30bd2e92755a48762fb45e5a41a 100644 --- a/common/source/java/ch/systemsx/cisd/common/utilities/RecursiveHardLinkMaker.java +++ b/common/source/java/ch/systemsx/cisd/common/utilities/RecursiveHardLinkMaker.java @@ -41,7 +41,7 @@ import ch.systemsx.cisd.common.process.ProcessExecutionHelper; public final class RecursiveHardLinkMaker implements IPathImmutableCopier { private static final String HARD_LINK_EXEC = "ln"; - + private static final Logger operationLog = LogFactory.getLogger(LogCategory.OPERATION, RecursiveHardLinkMaker.class); @@ -66,11 +66,6 @@ public final class RecursiveHardLinkMaker implements IPathImmutableCopier return new RetryingOperationTimeout(0, 1, 0); } - public static final IPathImmutableCopier create(final String linkExecPath) - { - return new RecursiveHardLinkMaker(linkExecPath, null); - } - private static class RetryingOperationTimeout { private final long millisToWaitForCompletion; @@ -103,6 +98,30 @@ public final class RecursiveHardLinkMaker implements IPathImmutableCopier } } + // + // Factory methods + // + + /** + * Creates copier which won't retry an operation if it fails. + * + * @param linkExecPath The path to the <code>ln</code> executable. + */ + public static final IPathImmutableCopier create(final String linkExecPath) + { + return new RecursiveHardLinkMaker(linkExecPath, null); + } + + /** + * Creates copier trying to find the path to the <code>ln</code> executable. + * + * @return <code>null</code> if the <code>ln</code> executable was not found. + */ + public static final IPathImmutableCopier tryCreate() + { + return tryCreate(null); + } + /** * Creates copier which is able to retry the operation of creating each hard link of a file if * it does not complete after a specified timeout. @@ -125,12 +144,6 @@ public final class RecursiveHardLinkMaker implements IPathImmutableCopier return tryCreate(timeout); } - /** Creates copier trying to find the path to hard link tool, null if nothing is found. */ - public static final IPathImmutableCopier tryCreate() - { - return tryCreate(null); - } - private static final IPathImmutableCopier tryCreate( RetryingOperationTimeout singleFileLinkTimeoutOrNull) { @@ -142,6 +155,10 @@ public final class RecursiveHardLinkMaker implements IPathImmutableCopier return new RecursiveHardLinkMaker(lnExec.getAbsolutePath(), singleFileLinkTimeoutOrNull); } + // + // IPathImmutableCopier + // + /** * Copies <var>path</var> (file or directory) to <var>destinationDirectory</var> by * duplicating directory structure and creating hard link for each file. @@ -149,7 +166,7 @@ public final class RecursiveHardLinkMaker implements IPathImmutableCopier * <i>Note that <var>nameOrNull</var> cannot already exist in given <var>destinationDirectory</var>.</i> * </p> */ - public final File tryCopy(final File path, final File destinationDirectory, + public final File tryImmutableCopy(final File path, final File destinationDirectory, final String nameOrNull) { assert path != null : "Given path can not be null."; diff --git a/common/sourceTest/java/ch/systemsx/cisd/common/utilities/RecursiveHardLinkMakerTest.java b/common/sourceTest/java/ch/systemsx/cisd/common/utilities/RecursiveHardLinkMakerTest.java index 06d1ff15aca3f8fa5512e4332fefea2cbdeeb508..0aea53f1c30f594de3afaafae3eadb1ce843ed8e 100644 --- a/common/sourceTest/java/ch/systemsx/cisd/common/utilities/RecursiveHardLinkMakerTest.java +++ b/common/sourceTest/java/ch/systemsx/cisd/common/utilities/RecursiveHardLinkMakerTest.java @@ -143,7 +143,7 @@ public class RecursiveHardLinkMakerTest { File inputDir = createDirectory(workingDirectory, "resource-to-copy"); createStructure(inputDir); - File newInput = createHardLinkCopier().tryCopy(inputDir, outputDir, null); + File newInput = createHardLinkCopier().tryImmutableCopy(inputDir, outputDir, null); assert newInput != null; assertStructureExists(newInput); @@ -170,7 +170,7 @@ public class RecursiveHardLinkMakerTest File src = createFile(workingDirectory, "fileXXX"); assertFileExists(src); - File dest = createHardLinkCopier().tryCopy(src, outputDir, null); + File dest = createHardLinkCopier().tryImmutableCopy(src, outputDir, null); assertFileExists(dest); modifyDest(dest); diff --git a/datamover/source/java/ch/systemsx/cisd/datamover/LocalProcessor.java b/datamover/source/java/ch/systemsx/cisd/datamover/LocalProcessor.java index d0b48e73615368f01ea52046d3c41a432726e89a..e12f5ef751520fcb4c5069da062109283e6c145c 100644 --- a/datamover/source/java/ch/systemsx/cisd/datamover/LocalProcessor.java +++ b/datamover/source/java/ch/systemsx/cisd/datamover/LocalProcessor.java @@ -272,7 +272,7 @@ public final class LocalProcessor implements IPathHandler, IRecoverableTimerTask return; } } - extraTmpCopy = copier.tryCopy(path, tempDir, null); + extraTmpCopy = copier.tryImmutableCopy(path, tempDir, null); if (extraTmpCopy == null) { notificationLog.error(String.format("Creating extra copy of '%s' failed.", path)); diff --git a/datamover/source/java/ch/systemsx/cisd/datamover/filesystem/FileSysOperationsFactory.java b/datamover/source/java/ch/systemsx/cisd/datamover/filesystem/FileSysOperationsFactory.java index a3a752a1fed8e773cdfca930a6a500b98abd1b89..d78427c5a84d03e8632c75df9343cd3db3524131 100644 --- a/datamover/source/java/ch/systemsx/cisd/datamover/filesystem/FileSysOperationsFactory.java +++ b/datamover/source/java/ch/systemsx/cisd/datamover/filesystem/FileSysOperationsFactory.java @@ -85,7 +85,7 @@ public class FileSysOperationsFactory implements IFileSysOperationsFactory // IPathImmutableCopier // - public final File tryCopy(final File file, final File destinationDirectory, + public final File tryImmutableCopy(final File file, final File destinationDirectory, final String nameOrNull) { final Status status = normalCopier.copy(file, destinationDirectory);