Search in sources :

Example 1 with NotLockedException

use of net.sourceforge.processdash.util.lock.NotLockedException 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 NotLockedException

use of net.sourceforge.processdash.util.lock.NotLockedException 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 3 with NotLockedException

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

the class ResourceBridgeClient method saveDefaultExcludedFiles.

public synchronized void saveDefaultExcludedFiles() throws IOException, LockFailureException {
    if (userName == null)
        throw new NotLockedException();
    List params = new ArrayList();
    for (String name : ResourceFilterFactory.DEFAULT_EXCLUDE_FILENAMES) {
        addFileUploadParams(params, name);
    }
    if (!params.isEmpty()) {
        startZipUploadThread(params);
        doPostRequest(UPLOAD_ACTION, (Object[]) params.toArray());
        logger.fine("Uploaded default excluded files");
    }
}
Also used : ArrayList(java.util.ArrayList) NotLockedException(net.sourceforge.processdash.util.lock.NotLockedException) ArrayList(java.util.ArrayList) List(java.util.List)

Example 4 with NotLockedException

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

the class ResourceBridgeClient method syncUp.

public synchronized boolean syncUp(SyncFilter filter) throws IOException, LockFailureException {
    if (userName == null)
        throw new NotLockedException();
    ProfTimer pt = new ProfTimer(logger, "ResourceBridgeClient.syncUp[" + remoteUrl + "]");
    ResourceCollectionDiff diff = getDiff();
    applySyncFilter(diff, filter);
    pt.click("Computed local-vs-remote diff");
    if (diff == null || diff.noDifferencesFound()) {
        logger.finer("no changes to sync up");
        return false;
    }
    boolean madeChange = false;
    List<String> filesToDownload = new ArrayList<String>();
    // collection (but not in our local collection)
    if (!diff.getOnlyInB().isEmpty()) {
        List<String> params = new ArrayList<String>();
        for (String resourceName : diff.getOnlyInB()) {
            if (isSyncDownOnly(resourceName)) {
                filesToDownload.add(resourceName);
            } else {
                logger.fine("deleting remote resource " + resourceName);
                params.add(DELETE_FILE_PARAM);
                params.add(resourceName);
            }
        }
        if (!params.isEmpty()) {
            doPostRequest(DELETE_ACTION, (Object[]) params.toArray());
            pt.click("Deleted remote resources");
            madeChange = true;
        }
    }
    // collection
    if (!diff.getOnlyInA().isEmpty() || !diff.getDiffering().isEmpty()) {
        List params = new ArrayList();
        for (String resourceName : diff.getOnlyInA()) {
            if (isSyncDownOnly(resourceName)) {
                logger.fine("deleting local resource " + resourceName);
                localCollection.deleteResource(resourceName);
                madeChange = true;
            } else {
                logger.fine("uploading new resource " + resourceName);
                addFileUploadParamsWithBatching(params, resourceName);
                madeChange = true;
            }
        }
        for (String resourceName : diff.getDiffering()) {
            if (isSyncDownOnly(resourceName)) {
                filesToDownload.add(resourceName);
            } else {
                logger.fine("uploading modified resource " + resourceName);
                addFileUploadParamsWithBatching(params, resourceName);
                madeChange = true;
            }
        }
        if (!params.isEmpty()) {
            startZipUploadThread(params);
            doPostRequest(UPLOAD_ACTION, (Object[]) params.toArray());
            pt.click("Uploaded new/modified resources");
            madeChange = true;
        }
    }
    if (!filesToDownload.isEmpty()) {
        List params = addMultiple(null, INCLUDE_PARAM, filesToDownload);
        downloadFiles(makeGetRequest(DOWNLOAD_ACTION, params));
        madeChange = true;
    }
    if (!madeChange) {
        logger.finer("no changes to sync up");
    }
    return madeChange;
}
Also used : ResourceCollectionDiff(net.sourceforge.processdash.tool.bridge.report.ResourceCollectionDiff) ProfTimer(net.sourceforge.processdash.util.ProfTimer) ArrayList(java.util.ArrayList) NotLockedException(net.sourceforge.processdash.util.lock.NotLockedException) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

NotLockedException (net.sourceforge.processdash.util.lock.NotLockedException)4 ProfTimer (net.sourceforge.processdash.util.ProfTimer)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 HttpException (net.sourceforge.processdash.util.HttpException)2 AlreadyLockedException (net.sourceforge.processdash.util.lock.AlreadyLockedException)2 LockFailureException (net.sourceforge.processdash.util.lock.LockFailureException)2 LockUncertainException (net.sourceforge.processdash.util.lock.LockUncertainException)2 ResourceCollectionDiff (net.sourceforge.processdash.tool.bridge.report.ResourceCollectionDiff)1