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);
}
}
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);
}
}
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);
}
}
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);
}
}
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());
}
Aggregations