Search in sources :

Example 1 with EmptyCompleteGraphException

use of es.bsc.compss.exceptions.EmptyCompleteGraphException in project compss by bsc-wdc.

the class CompleteGraphViewModel method update.

@Command
@NotifyChange("completeGraph")
public void update(Application monitoredApp) {
    logger.debug("Updating Complete Graph...");
    String completeMonitorLocation = monitoredApp.getPath() + Constants.MONITOR_COMPLETE_DOT_FILE;
    File completeMonitorFile = new File(completeMonitorLocation);
    if (completeMonitorFile.exists()) {
        SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
        String modifiedTime = sdf.format(completeMonitorFile.lastModified());
        if (!modifiedTime.equals(completeGraphLastUpdateTime)) {
            // Update needed
            try {
                String completeGraphSVG = File.separator + "svg" + File.separator + monitoredApp.getName() + "_" + Constants.COMPLETE_GRAPH_FILE_NAME;
                completeGraph = loadGraph(completeMonitorLocation, completeGraphSVG);
                completeGraphLastUpdateTime = modifiedTime;
            } catch (EmptyCompleteGraphException ecge) {
                logger.debug("Empty complete graph");
                completeGraph = Constants.EMPTY_GRAPH_PATH;
                completeGraphLastUpdateTime = modifiedTime;
            } catch (Exception e) {
                completeGraph = Constants.GRAPH_NOT_FOUND_PATH;
                completeGraphLastUpdateTime = "";
                logger.error("Graph generation error", e);
            }
        } else {
            logger.debug("Complete Graph is already loaded");
        }
    } else {
        completeGraph = Constants.GRAPH_NOT_FOUND_PATH;
        completeGraphLastUpdateTime = "";
        logger.debug("Complete Graph file not found");
    }
}
Also used : File(java.io.File) SimpleDateFormat(java.text.SimpleDateFormat) EmptyCompleteGraphException(es.bsc.compss.exceptions.EmptyCompleteGraphException) EmptyCompleteGraphException(es.bsc.compss.exceptions.EmptyCompleteGraphException) IOException(java.io.IOException) NotifyChange(org.zkoss.bind.annotation.NotifyChange) Command(org.zkoss.bind.annotation.Command)

Example 2 with EmptyCompleteGraphException

use of es.bsc.compss.exceptions.EmptyCompleteGraphException in project compss by bsc-wdc.

the class CompleteGraphViewModel method loadGraph.

private String loadGraph(String location, String target) throws EmptyCompleteGraphException, IOException, InterruptedException {
    if (logger.isDebugEnabled()) {
        logger.debug("Loading Graph...");
        logger.debug("   - Monitoring source: " + location);
        logger.debug("   - Monitoring target: " + target);
    }
    // Create SVG
    String targetFullPath = System.getProperty("catalina.base") + File.separator + "webapps" + File.separator + "compss-monitor" + File.separator + target;
    String[] createSVG = { "/bin/bash", "-c", "dot -T svg " + location + " > " + targetFullPath };
    Process p1 = Runtime.getRuntime().exec(createSVG);
    p1.waitFor();
    // If the complete graph is empty, throw exception to load empty graph image
    File graphFile = new File(targetFullPath);
    if (!graphFile.exists() || graphFile.length() <= COMPLETE_GRAPH_EMPTY_SIZE) {
        throw new EmptyCompleteGraphException("Empty complete graph");
    }
    // Add JSPan.js configuration
    String[] addJSScript = { "/bin/bash", "-c", "sed -i \"s/\\<g id\\=\\\"graph0/script xlink:href\\=\\\"SVGPan.js\\\"\\/\\>\\n\\<g id\\=\\\"viewport/\" " + targetFullPath };
    Process p2 = Runtime.getRuntime().exec(addJSScript);
    p2.waitFor();
    // Workaround for architectures with dot tool generating main graph as graph1 not graph0
    String[] addJSScript2 = { "/bin/bash", "-c", "sed -i \"s/\\<g id\\=\\\"graph1/script xlink:href\\=\\\"SVGPan.js\\\"\\/\\>\\n\\<g id\\=\\\"viewport/\" " + targetFullPath };
    Process p3 = Runtime.getRuntime().exec(addJSScript2);
    p3.waitFor();
    String[] createViewBox = { "/bin/bash", "-c", "sed -i \"s/<svg .*/<svg xmlns\\=\\\"http:\\/\\/www.w3.org\\/2000\\/svg\\\" xmlns:xlink\\=\\\"http:\\/\\/www.w3.org\\/1999\\/xlink\\\"\\>/g\" " + targetFullPath };
    Process p4 = Runtime.getRuntime().exec(createViewBox);
    p4.waitFor();
    // Load graph image
    logger.debug("Graph loaded");
    return target + "?t=" + System.currentTimeMillis();
}
Also used : File(java.io.File) EmptyCompleteGraphException(es.bsc.compss.exceptions.EmptyCompleteGraphException)

Aggregations

EmptyCompleteGraphException (es.bsc.compss.exceptions.EmptyCompleteGraphException)2 File (java.io.File)2 IOException (java.io.IOException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Command (org.zkoss.bind.annotation.Command)1 NotifyChange (org.zkoss.bind.annotation.NotifyChange)1