Commit 1ce38c41 1ce38c417ada87e6a9392fd1598f51ab92c1599b by Christian Gerdes

New feature to block/unblock an Oracle DB Monitor. Not implemented for

JMX Monitors yet.
1 parent 7ec575e1
......@@ -55,6 +55,16 @@ function getData(type, input, pdb) {
client1.send();
}
function setBlocked(type, input, state) {
// Update the data
var client1 = new XMLHttpRequest();
client1.onreadystatechange = dataHandler;
client1.open("GET", "" + type + "/getData?block=" + state + "&connectionString=" + encodeURIComponent(input));
client1.setRequestHeader('Cache-Control', 'no-cache');
client1.setRequestHeader('Pragma', 'no-cache');
client1.send();
}
function getMetrics(type, input, pdb) {
// Get the metrics
var pdbAdd = "";
......@@ -104,6 +114,7 @@ function dataHandler() {
<table>
<tr>
<th>Name</th>
<th>Instance</th>
<th>Connection String</th>
<th>Data Calls</th>
<th>Success</th>
......@@ -111,10 +122,12 @@ function dataHandler() {
<th>Last Exception</th>
<th>Age</th>
<th>RT</th>
<th>Blocked</th>
<th>Action</th>
</tr>
<% for (OraMon mon : se.lil.om.Registry.getList()) { %>
<tr>
<td><%= mon.getFriendlyName() %></td>
<td><%= mon.getDBName() %></td>
<td><%= mon.getConString() %></td>
<td><%= mon.getDataCalled() %></td>
......@@ -123,8 +136,10 @@ function dataHandler() {
<td><%= mon.getLastEx() %></td>
<td><%= mon.getAgeTs() %>s</td>
<td><%= mon.getLastRTms() %>ms</td>
<td><%= mon.getBlockedState() %></td>
<td>
<form method="POST">
<input id="blockButton" type="button" <%if(mon.getBlockedState()) { %>value="Unblock"<% } else { %>value="Block"<% } %> onClick="setBlocked('OraMonREST', '<%= mon.getConString() %>','<%= !mon.getBlockedState() %>')">
<input type="submit" name="action" value="remove" >
<input type="hidden" name="omconstr" value="<%= mon.getConString() %>">
<input type="button" value="graph" onClick="showGraph('viewOraMon','<%= URLEncoder.encode(mon.getConString(), "UTF-8") %>',this.form.pdbName.value)">
......
No preview for this file type
......@@ -133,6 +133,27 @@ public class OraMonRESTgetData extends HttpServlet {
}
if(monitor != null) {
if(request.getParameterMap().containsKey("block")) {
// Call setBlocked()
boolean blockedState = false;
try {
blockedState = Boolean.parseBoolean(request.getParameter("block"));
} catch (Exception e) {
response.setStatus(400);
response.getWriter().println("{\"error\":true,\"msg\":\"The specified block parameter is not a valid boolean\"}");
return;
}
monitor.setBlockedState(blockedState);
if(blockedState == monitor.getBlockedState()) {
response.setStatus(200);
response.getWriter().println("{\"error\":false,\"msg\":\"The blocked state is now set to "+blockedState+"\"}");
return;
} else {
response.setStatus(500);
response.getWriter().println("{\"error\":true,\"msg\":\"The blocked state could not be set to "+blockedState+"\"}");
return;
}
} else {
// Call getData()
boolean didUpdate = monitor.getData(age,pdbName);
String dbName = monitor.getFriendlyName(pdbName);
......@@ -142,8 +163,10 @@ public class OraMonRESTgetData extends HttpServlet {
} else {
response.setStatus(HttpServletResponse.SC_ACCEPTED);
sb.append("{\"error\":false");
sb.append(",\"msg\":\"Data does not need to be updated on '" + dbName + "' either because another thread did concurrently update the monitor and we just waited for it to complete, or because the age (if) specified was higher than the monitors data age.\"");
sb.append(",\"age\":"+monitor.getAgeTs()+"}");
sb.append(",\"msg\":\"Data does not need to be updated on '" + dbName + "' either because it is blocked, another thread did concurrently update the monitor and we just waited for it to complete, or because the age (if) specified was higher than the monitors data age.\"");
sb.append(",\"age\":"+monitor.getAgeTs());
sb.append(",\"blocked\":"+monitor.getBlockedState()+"}");
}
}
} else {
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
......
......@@ -35,6 +35,16 @@ public class OraMon {
public static final String strNiwTime = " niwtime";
public static final String strSeparator = " ";
private boolean blocked = false;
public void setBlockedState(Boolean blockedState) {
this.blocked = blockedState;
}
public boolean getBlockedState() {
return this.blocked;
}
public int getNumPdbs() {
if(pdbSet != null) return pdbSet.size();
else return 0;
......@@ -325,6 +335,9 @@ public class OraMon {
Throwable lastEx = null;
public boolean getData(long ageTs, String pdbName) throws Throwable {
//Check if we are blocked. If we are, just return with false telling the caller we did not update.
if(this.blocked) return false;
//Check age (unless pdbName was set for the first time, in that case we need to discard the cached data)
if(getPdbs == false && pdbName != null) {
getPdbs = true;
......