io.bdeploy.bhive.op.DirectoryAwaitOperation Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of api Show documentation
Show all versions of api Show documentation
Public API including dependencies, ready to be used for integrations and plugins.
The newest version!
package io.bdeploy.bhive.op;
import java.nio.file.Path;
import io.bdeploy.common.util.PathHelper;
import io.bdeploy.common.util.Threads;
/**
* Waits until a given directory is unlocked.
*
* @see DirectoryLockOperation
* @see DirectoryReleaseOperation
*/
public class DirectoryAwaitOperation extends DirectoryModificationOperation {
@Override
public void doCall(Path lockFile) {
for (int i = 0; i < RETRIES; ++i) {
if (!PathHelper.exists(lockFile) || !DirectoryLockOperation.isLockFileValid(lockFile, getLockContentValidator())) {
return;
}
if (!Threads.sleep(SLEEP_MILLIS)) {
break;
}
}
throw new IllegalStateException("Retries exceeded or interrupted while waiting that lock " + lockFile
+ " is released. Please check manually if another process is still running and delete the lock file manually.");
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy