// Path: src/main/java/uk/sky/cqlmigrate/exception/CannotAcquireLockException.java
// public class CannotAcquireLockException extends LockException {
// 
//     public CannotAcquireLockException(String message) {
//         super(message);
//     }
// 
//     public CannotAcquireLockException(String message, Throwable cause) {
//         super(message, cause);
//     }
// }
// 
// Path: src/main/java/uk/sky/cqlmigrate/exception/CannotReleaseLockException.java
// public class CannotReleaseLockException extends LockException {
// 
//     public CannotReleaseLockException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public CannotReleaseLockException(String message) {
//         super(message);
//     }
// }


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import uk.sky.cqlmigrate.exception.CannotAcquireLockException;
import uk.sky.cqlmigrate.exception.CannotReleaseLockException;
import java.util.concurrent.TimeoutException;
package uk.sky.cqlmigrate;



/**
 * Each instance attempts to acquire the lock.
 */
class Lock {

    private static final Logger log = LoggerFactory.getLogger(Lock.class);

    private final LockingMechanism lockingMechanism;
    private final LockConfig lockConfig;

    /**
     *
     * @param lockingMechanism {@code LockingMechanism} to use to acquire the lock
     * @param lockConfig       {@code LockConfig} for configuring the lock polling interval, timeout and client id
     */
    Lock(LockingMechanism lockingMechanism, LockConfig lockConfig) {
        this.lockingMechanism = lockingMechanism;
        this.lockConfig = lockConfig;
    }

    /**
     * If the lock is successfully acquired, the method will return, otherwise
     * this will wait until the lock has been released. If a lock cannot
     * be acquired within the configured timeout interval, an exception is thrown.
     *
     * @throws CannotAcquireLockException if this cannot acquire lock within the specified time interval or locking mechanism fails
     */
// Path: src/main/java/uk/sky/cqlmigrate/exception/CannotAcquireLockException.java
// public class CannotAcquireLockException extends LockException {
// 
//     public CannotAcquireLockException(String message) {
//         super(message);
//     }
// 
//     public CannotAcquireLockException(String message, Throwable cause) {
//         super(message, cause);
//     }
// }
// 
// Path: src/main/java/uk/sky/cqlmigrate/exception/CannotReleaseLockException.java
// public class CannotReleaseLockException extends LockException {
// 
//     public CannotReleaseLockException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public CannotReleaseLockException(String message) {
//         super(message);
//     }
// }


// Path: src/main/java/uk/sky/cqlmigrate/Lock.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import uk.sky.cqlmigrate.exception.CannotAcquireLockException;
import uk.sky.cqlmigrate.exception.CannotReleaseLockException;
import java.util.concurrent.TimeoutException;

package uk.sky.cqlmigrate;



/**
 * Each instance attempts to acquire the lock.
 */
class Lock {

    private static final Logger log = LoggerFactory.getLogger(Lock.class);

    private final LockingMechanism lockingMechanism;
    private final LockConfig lockConfig;

    /**
     *
     * @param lockingMechanism {@code LockingMechanism} to use to acquire the lock
     * @param lockConfig       {@code LockConfig} for configuring the lock polling interval, timeout and client id
     */
    Lock(LockingMechanism lockingMechanism, LockConfig lockConfig) {
        this.lockingMechanism = lockingMechanism;
        this.lockConfig = lockConfig;
    }

    /**
     * If the lock is successfully acquired, the method will return, otherwise
     * this will wait until the lock has been released. If a lock cannot
     * be acquired within the configured timeout interval, an exception is thrown.
     *
     * @throws CannotAcquireLockException if this cannot acquire lock within the specified time interval or locking mechanism fails
     */
    public void lock() throws CannotAcquireLockException {