Search in sources :

Example 6 with ProfTimer

use of net.sourceforge.processdash.util.ProfTimer 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)

Example 7 with ProfTimer

use of net.sourceforge.processdash.util.ProfTimer in project processdash by dtuma.

the class ResourceBridgeClient method releaseLock.

public synchronized void releaseLock() {
    if (userName == null)
        return;
    ProfTimer pt = new ProfTimer(logger, "ResourceBridgeClient.releaseLock[" + remoteUrl + "]");
    try {
        doLockPostRequest(RELEASE_LOCK_ACTION);
        setOfflineLockStatus(OfflineLockStatus.NotLocked);
        pt.click("Released bridged lock");
    } catch (Exception e) {
        // We don't throw any error here, because if we fail to release
        // the bridged lock, the worst case scenario is that it will time
        // out on the server after 5 minutes or so.  Log a message for
        // posterity.
        logger.log(Level.FINE, "Unable to release bridged lock", e);
    }
}
Also used : ProfTimer(net.sourceforge.processdash.util.ProfTimer) 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 8 with ProfTimer

use of net.sourceforge.processdash.util.ProfTimer in project processdash by dtuma.

the class FileBackupManager method run.

public File run() {
    ProfTimer pt = new ProfTimer(FileBackupManager.class, "FileBackupManager.run");
    File result = null;
    try {
        result = runImpl(RUNNING, null, true);
    } catch (Throwable t) {
        printError(t);
    }
    pt.click("Finished backup");
    return result;
}
Also used : ProfTimer(net.sourceforge.processdash.util.ProfTimer) File(java.io.File)

Example 9 with ProfTimer

use of net.sourceforge.processdash.util.ProfTimer in project processdash by dtuma.

the class TemplateLoader method getTemplateURLs.

/** Returns a list of URLs to templates, in logical search order.
     *
     * The URL search order is:<OL>
     * <LI>Look first in the directory specified by the user setting
     *     "templates.directory" (should end in "Templates").
     * <LI>Next, look in any JAR files contained in that directory.
     * <LI>Next, look in any JAR files contained in the parent of that
     *     directory.
     * <LI>If there is a Templates directory underneath the master application
     *     directory, look there for the file, or for JARs containing the file.
     * <LI>If there is a Templates directory alongside the pspdash.jar file,
     *     look there, first for the file, then for JARs containing the file.
     * <LI>If there are any JAR files next to the pspdash.jar file, look in
     *     them.
     * <LI>Finally, look in the classpath (which includes the pspdash.jar
     *     file).</OL>
     */
public static URL[] getTemplateURLs() {
    GET_TEMPLATE_URLS_PERMISSION.checkPermission();
    if (template_url_list != null)
        return template_url_list;
    Vector result = new Vector();
    ProfTimer pt = new ProfTimer(TemplateLoader.class, "TemplateLoader.getTemplateURLs");
    String userSetting = getSearchPath();
    if (userSetting != null && userSetting.length() != 0) {
        StringTokenizer tok = new StringTokenizer(userSetting, ";");
        while (tok.hasMoreTokens()) addTemplateURLs(tok.nextToken(), result);
    }
    File appTemplateDir = getApplicationTemplateDir();
    if (appTemplateDir.isDirectory()) {
        try {
            result.add(appTemplateDir.toURI().toURL());
            scanDirForJarFiles(appTemplateDir, result);
        } catch (MalformedURLException e) {
        }
    }
    int i = 1;
    while (true) {
        String extraDir = System.getProperty(EXTRA_DIR_SETTING_PREFIX + i);
        if (extraDir == null)
            break;
        File dirToScan = new File(extraDir);
        if (dirToScan.isDirectory())
            scanDirForJarFiles(dirToScan, result);
        i++;
    }
    String baseDir = getBaseDir();
    if (unpackagedBinaryBaseDir != null)
        addTemplateURLs(unpackagedBinaryBaseDir + Settings.sep + "dist", result);
    addTemplateURLs(baseDir, result);
    try {
        Enumeration e = TemplateLoader.class.getClassLoader().getResources(TEMPLATE_DIR);
        while (e.hasMoreElements()) result.addElement(e.nextElement());
    } catch (IOException ioe) {
        logger.severe("An exception was encountered when searching " + "for process templates in the classpath:\n\t" + ioe);
    }
    filterURLList(result);
    try {
        URL mcfUrl = new URL(MCFURLConnection.PROTOCOL + ":/");
        result.add(result.size() - 1, mcfUrl);
    } catch (MalformedURLException mue) {
    // this will occur if the URL stream handler factory hasn't been
    // installed yet. This should generally only happen as the Quick
    // Launcher opens, and the problem will be resolved during the
    // Process Dashboard startup sequence.
    }
    template_url_list = urlListToArray(result);
    mcf_url_list = new ArrayList<URL>();
    pt.click("Calculated template URL list");
    return template_url_list;
}
Also used : StringTokenizer(java.util.StringTokenizer) MalformedURLException(java.net.MalformedURLException) Enumeration(java.util.Enumeration) ProfTimer(net.sourceforge.processdash.util.ProfTimer) IOException(java.io.IOException) Vector(java.util.Vector) ZipFile(java.util.zip.ZipFile) File(java.io.File) URL(java.net.URL)

Example 10 with ProfTimer

use of net.sourceforge.processdash.util.ProfTimer in project processdash by dtuma.

the class TemplateLoader method loadTemplates.

public static DashHierarchy loadTemplates(DataRepository data) {
    LOAD_TEMPLATES_PERMISSION.checkPermission();
    DashHierarchy templates = new DashHierarchy(null);
    ProfTimer pt = new ProfTimer(TemplateLoader.class, "TemplateLoader.loadTemplates");
    List<URL> roots = new ArrayList<URL>(Arrays.asList(getTemplateURLs()));
    pt.click("Got template roots");
    for (int i = roots.size(); i-- > 0; ) {
        String templateDirURL = roots.get(i).toString();
        if (templateDirURL.startsWith("file:/")) {
            /* If the /Templates directory exists as a local file
                 * somewhere, search through that directory for process
                 * templates.
                 */
            // strip "file:" from the beginning of the url.
            String dirname = templateDirURL.substring(5);
            dirname = HTMLUtils.urlDecode(dirname);
            searchDirForTemplates(templates, dirname, data);
            pt.click("searched dir '" + dirname + "' for templates");
        } else if (templateDirURL.startsWith("jar:")) {
            /* If the /Templates directory found is in a jar somewhere,
                 * search through the jar for process templates.
                 */
            // Strip "jar:" from the beginning and the "!/Templates/"
            // from the end of the URL.
            String jarFileURL = templateDirURL.substring(4, templateDirURL.indexOf('!'));
            JarSearchResult searchResult = searchJarForTemplates(templates, jarFileURL, data);
            // if this was an MCF JAR, remove its URL from the search path
            if (searchResult == JarSearchResult.Mcf) {
                logger.fine("Processed MCF URL " + templateDirURL);
                mcf_url_list.add(roots.remove(i));
            }
            pt.click("searched jar '" + jarFileURL + "' for templates");
        }
    }
    // find any missing MCFs that came bundled within a data backup file
    searchExternalResourcesForMissingMcfs(templates, data);
    // store the new list of template URLs, stripped of MCF JAR files
    template_url_list = roots.toArray(new URL[roots.size()]);
    generateRollupTemplates(templates, data);
    createProcessRoot(templates);
    pt.click("done loading templates");
    return templates;
}
Also used : DashHierarchy(net.sourceforge.processdash.hier.DashHierarchy) ProfTimer(net.sourceforge.processdash.util.ProfTimer) ArrayList(java.util.ArrayList) URL(java.net.URL)

Aggregations

ProfTimer (net.sourceforge.processdash.util.ProfTimer)12 IOException (java.io.IOException)6 LockFailureException (net.sourceforge.processdash.util.lock.LockFailureException)6 NotLockedException (net.sourceforge.processdash.util.lock.NotLockedException)6 HttpException (net.sourceforge.processdash.util.HttpException)5 AlreadyLockedException (net.sourceforge.processdash.util.lock.AlreadyLockedException)5 LockUncertainException (net.sourceforge.processdash.util.lock.LockUncertainException)5 URL (java.net.URL)3 ArrayList (java.util.ArrayList)3 File (java.io.File)2 List (java.util.List)2 ResourceCollectionDiff (net.sourceforge.processdash.tool.bridge.report.ResourceCollectionDiff)2 MalformedURLException (java.net.MalformedURLException)1 Enumeration (java.util.Enumeration)1 StringTokenizer (java.util.StringTokenizer)1 Vector (java.util.Vector)1 ZipFile (java.util.zip.ZipFile)1 DashHierarchy (net.sourceforge.processdash.hier.DashHierarchy)1