Search in sources :

Example 1 with LockFailureException

use of net.sourceforge.processdash.util.lock.LockFailureException in project processdash by dtuma.

the class ResourceBridgeClient method pingLock.

public synchronized void pingLock() throws LockFailureException {
    if (userName == null)
        throw new NotLockedException();
    ProfTimer pt = new ProfTimer(logger, "ResourceBridgeClient.pingLock[" + remoteUrl + "]");
    try {
        doLockPostRequest(PING_LOCK_ACTION);
        pt.click("Pinged bridged lock");
    } catch (LockFailureException lfe) {
        throw lfe;
    } catch (Exception e) {
        throw new LockUncertainException(e);
    }
}
Also used : ProfTimer(net.sourceforge.processdash.util.ProfTimer) NotLockedException(net.sourceforge.processdash.util.lock.NotLockedException) LockUncertainException(net.sourceforge.processdash.util.lock.LockUncertainException) LockFailureException(net.sourceforge.processdash.util.lock.LockFailureException) LockFailureException(net.sourceforge.processdash.util.lock.LockFailureException) LockUncertainException(net.sourceforge.processdash.util.lock.LockUncertainException) NotLockedException(net.sourceforge.processdash.util.lock.NotLockedException) IOException(java.io.IOException) HttpException(net.sourceforge.processdash.util.HttpException) AlreadyLockedException(net.sourceforge.processdash.util.lock.AlreadyLockedException)

Example 2 with LockFailureException

use of net.sourceforge.processdash.util.lock.LockFailureException in project processdash by dtuma.

the class ResourceBridgeClient method resumeOfflineLock.

/**
     * Reassert a lock that was enabled for offline use during a previous
     * session.
     * 
     * If the lock could be reobtained, this will return successfully - even if
     * the lock is no longer enabled for offline use. After calling this method,
     * clients should call {@link #getOfflineLockStatus()} to ensure that the
     * lock is in the mode they expect.
     */
public synchronized void resumeOfflineLock(String userName) throws LockFailureException {
    if (!StringUtils.hasValue(extraLockData))
        throw new IllegalStateException("No extra lock data has been set");
    ProfTimer pt = new ProfTimer(logger, "ResourceBridgeClient.resumeOfflineLock[" + remoteUrl + "]");
    try {
        this.userName = userName;
        doLockPostRequest(ASSERT_LOCK_ACTION);
        pt.click("Resumed offline bridged lock");
    } catch (LockFailureException lfe) {
        this.userName = null;
        throw lfe;
    } catch (Exception e) {
        // when operating in offline mode, it is not unusual for the server
        // to be unreachable, which could result in IOExceptions or other
        // errors.  Give caller the benefit of the doubt and mark the lock
        // as offline; then continue normally.
        setOfflineLockStatus(OfflineLockStatus.Enabled);
    }
}
Also used : ProfTimer(net.sourceforge.processdash.util.ProfTimer) LockFailureException(net.sourceforge.processdash.util.lock.LockFailureException) LockFailureException(net.sourceforge.processdash.util.lock.LockFailureException) LockUncertainException(net.sourceforge.processdash.util.lock.LockUncertainException) NotLockedException(net.sourceforge.processdash.util.lock.NotLockedException) IOException(java.io.IOException) HttpException(net.sourceforge.processdash.util.HttpException) AlreadyLockedException(net.sourceforge.processdash.util.lock.AlreadyLockedException)

Example 3 with LockFailureException

use of net.sourceforge.processdash.util.lock.LockFailureException in project processdash by dtuma.

the class ResourceBridgeClient method doAssertLock.

private synchronized void doAssertLock(String action) throws LockFailureException {
    if (userName == null)
        throw new NotLockedException();
    ProfTimer pt = new ProfTimer(logger, "ResourceBridgeClient." + action + "[" + remoteUrl + "]");
    try {
        doLockPostRequest(action);
        pt.click("Asserted bridged lock");
    } catch (LockFailureException lfe) {
        throw lfe;
    } catch (Exception e) {
        throw new LockUncertainException(e);
    }
}
Also used : ProfTimer(net.sourceforge.processdash.util.ProfTimer) NotLockedException(net.sourceforge.processdash.util.lock.NotLockedException) LockUncertainException(net.sourceforge.processdash.util.lock.LockUncertainException) LockFailureException(net.sourceforge.processdash.util.lock.LockFailureException) LockFailureException(net.sourceforge.processdash.util.lock.LockFailureException) LockUncertainException(net.sourceforge.processdash.util.lock.LockUncertainException) NotLockedException(net.sourceforge.processdash.util.lock.NotLockedException) IOException(java.io.IOException) HttpException(net.sourceforge.processdash.util.HttpException) AlreadyLockedException(net.sourceforge.processdash.util.lock.AlreadyLockedException)

Example 4 with LockFailureException

use of net.sourceforge.processdash.util.lock.LockFailureException in project processdash by dtuma.

the class ResourceBridgeClient method acquireLock.

public synchronized void acquireLock(String userName) throws LockFailureException {
    ProfTimer pt = new ProfTimer(logger, "ResourceBridgeClient.acquireLock[" + remoteUrl + "]");
    try {
        this.userName = userName;
        doLockPostRequest(ACQUIRE_LOCK_ACTION);
        pt.click("Acquired bridged lock");
    } catch (LockFailureException lfe) {
        this.userName = null;
        throw lfe;
    } catch (Exception e) {
        this.userName = null;
        setOfflineLockStatus(OfflineLockStatus.NotLocked);
        throw new LockFailureException(e);
    }
}
Also used : ProfTimer(net.sourceforge.processdash.util.ProfTimer) LockFailureException(net.sourceforge.processdash.util.lock.LockFailureException) LockFailureException(net.sourceforge.processdash.util.lock.LockFailureException) LockUncertainException(net.sourceforge.processdash.util.lock.LockUncertainException) NotLockedException(net.sourceforge.processdash.util.lock.NotLockedException) IOException(java.io.IOException) HttpException(net.sourceforge.processdash.util.HttpException) AlreadyLockedException(net.sourceforge.processdash.util.lock.AlreadyLockedException)

Example 5 with LockFailureException

use of net.sourceforge.processdash.util.lock.LockFailureException in project processdash by dtuma.

the class ResourceBridgeClient method doBackup.

public synchronized URL doBackup(String qualifier) throws IOException {
    ProfTimer pt = new ProfTimer(logger, "ResourceBridgeClient.doBackup[" + remoteUrl + "]");
    try {
        doPostRequest(BACKUP_ACTION, BACKUP_QUALIFIER_PARAM, qualifier);
        pt.click("backup finished, qualifer = " + qualifier);
    } catch (LockFailureException e) {
        // shouldn't happen
        logger.log(Level.SEVERE, "Received unexpected exception", e);
        pt.click("backup failed");
    }
    StringBuffer result = new StringBuffer(remoteUrl);
    HTMLUtils.appendQuery(result, VERSION_PARAM, CLIENT_VERSION);
    HTMLUtils.appendQuery(result, ACTION_PARAM, GET_BACKUP_ACTION);
    return new URL(result.toString());
}
Also used : ProfTimer(net.sourceforge.processdash.util.ProfTimer) LockFailureException(net.sourceforge.processdash.util.lock.LockFailureException) URL(java.net.URL)

Aggregations

LockFailureException (net.sourceforge.processdash.util.lock.LockFailureException)14 AlreadyLockedException (net.sourceforge.processdash.util.lock.AlreadyLockedException)10 IOException (java.io.IOException)8 HttpException (net.sourceforge.processdash.util.HttpException)7 ReadOnlyLockFailureException (net.sourceforge.processdash.util.lock.ReadOnlyLockFailureException)6 File (java.io.File)5 ProfTimer (net.sourceforge.processdash.util.ProfTimer)5 LockUncertainException (net.sourceforge.processdash.util.lock.LockUncertainException)5 NotLockedException (net.sourceforge.processdash.util.lock.NotLockedException)4 BridgedWorkingDirectory (net.sourceforge.processdash.tool.bridge.client.BridgedWorkingDirectory)3 SentLockMessageException (net.sourceforge.processdash.util.lock.SentLockMessageException)3 Random (java.util.Random)2 CompressedWorkingDirectory (net.sourceforge.processdash.tool.bridge.client.CompressedWorkingDirectory)2 WorkingDirectory (net.sourceforge.processdash.tool.bridge.client.WorkingDirectory)2 CannotCreateLockException (net.sourceforge.processdash.util.lock.CannotCreateLockException)2 HeadlessException (java.awt.HeadlessException)1 BufferedOutputStream (java.io.BufferedOutputStream)1 OutputStream (java.io.OutputStream)1 HttpURLConnection (java.net.HttpURLConnection)1 URL (java.net.URL)1