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