Repository: aurora Updated Branches: refs/heads/master fe028ad99 -> a0e128d2f
Kill unused `.st` files and params. This cleans up stringtemplate use in Aurora as directed by spikes on https://issues.apache.org/jira/browse/AURORA-987 that included upgrading to the stringtemplate 4.x series which errors when parameters used anywhere in a template - including un-triggered conditionals - are not bound. The cleanups are valid under stringtemplate 3.x as verified by testing the affected endpoints via the vagrant vm. Reviewed at https://reviews.apache.org/r/40466/ Project: http://git-wip-us.apache.org/repos/asf/aurora/repo Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/a0e128d2 Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/a0e128d2 Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/a0e128d2 Branch: refs/heads/master Commit: a0e128d2fa2568e105054d1c34b5550053bb549b Parents: fe028ad Author: John Sirois <[email protected]> Authored: Mon Nov 23 16:48:01 2015 -0800 Committer: Bill Farner <[email protected]> Committed: Mon Nov 23 16:48:06 2015 -0800 ---------------------------------------------------------------------- .../common/net/http/handlers/logprinter.st | 180 ------------------- .../aurora/scheduler/http/StructDump.java | 1 + .../org/apache/aurora/scheduler/http/slaves.st | 3 - .../apache/aurora/scheduler/http/utilization.st | 3 - 4 files changed, 1 insertion(+), 186 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/aurora/blob/a0e128d2/commons/src/main/resources/org/apache/aurora/common/net/http/handlers/logprinter.st ---------------------------------------------------------------------- diff --git a/commons/src/main/resources/org/apache/aurora/common/net/http/handlers/logprinter.st b/commons/src/main/resources/org/apache/aurora/common/net/http/handlers/logprinter.st deleted file mode 100644 index a9c98a4..0000000 --- a/commons/src/main/resources/org/apache/aurora/common/net/http/handlers/logprinter.st +++ /dev/null @@ -1,180 +0,0 @@ -<html> - <title>Log Printer</title> - <body> - $if(file)$ - <h3>$file.path$</h3> - - $if(prev)$ - <a href='?file=$file.urlpath$&page=$prev$&filter=$filter$'>Prev</a> - $else$ - Prev - $endif$ - $if(next)$ - <a href='?file=$file.urlpath$&page=$next$&filter=$filter$'>Next</a> - $else$ - Next - $endif$ - - <div align='right'> - <form action='' method='get'> - <input type='hidden' name='file' value='$file.path$'> - <input type='hidden' name='page' value='$page$'> - - <table border=0 cellpadding=0 cellspacing=0 align=right> - <tr> - <td>Regexp Filter: </td> - <td><input type='text' name='filter' value='$filter$'> - <input type='submit' value='Go'> - </td> - </tr> - </table> - </form> - </div> - - <br/> - <hr> - <br/> - <pre id='log_contents'> - <!-- Will be populated with log contents when AJAX call returns --> - </pre> - <br/> - <hr> - <br/> - - <script type='text/javascript'> - var intervalId; - - function toggleTailState(tailCheckbox) { - if (tailCheckbox.checked) { - startTailing(); - } else { - clearInterval(intervalId); - } - - loc = '?file=$file.urlpath$&page=$page$&filter=$filter$'; - if (tailCheckbox.checked) { - loc = loc + '&tail=true'; - } - window.location = loc; - } - - function fetchLogContents() { - if (outstandingRequest) return; - outstandingRequest = true; - - var req = new XMLHttpRequest(); - req.onreadystatechange = getReadyStateHandler(req, populateLog); - - // Open an HTTP POST connection to the logs servlet. - // Third parameter specifies request is asynchronous. - req.open("POST", "logs", true); - - // Specify that the body of the request contains form data - req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); - - // Send form encoded data that specifies the request. - req.send("file=$file.urlpath$&page=$page$&filter=$filter$&tail=$tail$&start_pos=" + tailEndPosition); - } - - function populateLog(logXml) { - outstandingRequest = false; - var logChunk = logXml.getElementsByTagName("logchunk")[0]; - if ($tail$) { - logDisplay = document.getElementById("log_contents").innerHTML + logChunk.getAttribute("text"); - } else { - logDisplay = logChunk.getAttribute("text"); - } - - document.getElementById("log_contents").innerHTML = logDisplay; - tailEndPosition = logChunk.getAttribute("end_pos"); - document.body.scrollTop = document.body.scrollHeight; - } - - function startTailing() { - intervalId = setInterval(fetchLogContents, 1000); - } - - /** - * Returns a function that waits for the specified XMLHttpRequest - * to complete, then passes its XML response - * to the given handler function. - * req - The XMLHttpRequest whose state is changing - * responseXmlHandler - Function to pass the XML response to - */ - function getReadyStateHandler(req, responseXmlHandler) { - // Return an anonymous function that listens to the - // XMLHttpRequest instance - return function () { - // If the request's status is "complete" - if (req.readyState == 4) { - // Check that a successful server response was received - if (req.status == 200) { - // Pass the XML payload of the response to the - // handler function - responseXmlHandler(req.responseXML); - - } else { - // An HTTP problem has occurred - alert("HTTP error: "+req.status); - } - } - } - } - - var tailMode = false; - var outstandingRequest = false; - var tailEndPosition = -1; - if ($tail$) { - startTailing(); - } else { - fetchLogContents(); - } - </script> - - $if(prev)$ - <a href='?file=$file.urlpath$&page=$prev$&filter=$filter$'>Prev</a> - $else$ - Prev - $endif$ - $if(next)$ - <a href='?file=$file.urlpath$&page=$next$&filter=$filter$'>Next</a> - $else$ - Next - $endif$ - - <div align='right'> - <input type='checkbox' id='tail' $if(tail)$ checked $endif$ onclick='toggleTailState(this);'> - <label for='tail'>Tail log output</label> - </div> - $else$ - <h3>$dir.absolutePath$</h3> - - <table border=0 cellpadding=0 cellspacing=5 align=left> - $if(parent)$ - <tr> - <td></td> - <td><a href='?file=$parent$'>../</a></td> - </tr> - $endif$ - - $files:{ - <tr> - <td> - $if(it.regularFile)$ - <a href='?file=$it.urlpath$&download=true'><font size=1>DL</font></a> - $endif$ - </td> - <td> - <a href='?file=$it.urlpath$'>$it.name$$if(it.dir)$/$endif$</a> - $if(it.regularFile)$ ($it.size$) $endif$ - </td> - </tr> - }$ - </table> - $endif$ - - $if(exception)$ - <font color='red'>Exception: $exception$</font> - $endif$ - </body> -</html> http://git-wip-us.apache.org/repos/asf/aurora/blob/a0e128d2/src/main/java/org/apache/aurora/scheduler/http/StructDump.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/http/StructDump.java b/src/main/java/org/apache/aurora/scheduler/http/StructDump.java index 916269f..d66f4ce 100644 --- a/src/main/java/org/apache/aurora/scheduler/http/StructDump.java +++ b/src/main/java/org/apache/aurora/scheduler/http/StructDump.java @@ -122,6 +122,7 @@ public class StructDump extends JerseyTemplateServlet { Optional<? extends TBase<?, ?>> struct = storage.read(work); if (struct.isPresent()) { template.setAttribute("structPretty", Util.prettyPrint(struct.get())); + template.setAttribute("exception", null); } else { template.setAttribute("exception", "Entity not found"); } http://git-wip-us.apache.org/repos/asf/aurora/blob/a0e128d2/src/main/resources/org/apache/aurora/scheduler/http/slaves.st ---------------------------------------------------------------------- diff --git a/src/main/resources/org/apache/aurora/scheduler/http/slaves.st b/src/main/resources/org/apache/aurora/scheduler/http/slaves.st index 854a9d4..009e5af 100644 --- a/src/main/resources/org/apache/aurora/scheduler/http/slaves.st +++ b/src/main/resources/org/apache/aurora/scheduler/http/slaves.st @@ -36,8 +36,5 @@ }$ </tbody> </table> - $if(exception)$ - <font color='red'>Exception: $exception$</font> - $endif$ </body> </html> http://git-wip-us.apache.org/repos/asf/aurora/blob/a0e128d2/src/main/resources/org/apache/aurora/scheduler/http/utilization.st ---------------------------------------------------------------------- diff --git a/src/main/resources/org/apache/aurora/scheduler/http/utilization.st b/src/main/resources/org/apache/aurora/scheduler/http/utilization.st index 4a8a072..ae497a7 100644 --- a/src/main/resources/org/apache/aurora/scheduler/http/utilization.st +++ b/src/main/resources/org/apache/aurora/scheduler/http/utilization.st @@ -41,8 +41,5 @@ }$ </tbody> </table> - $if(exception)$ - <font color='red'>Exception: $exception$</font> - $endif$ </body> </html>
