use of org.apache.geode.tools.pulse.internal.data.Cluster in project geode by apache.
the class PulseController method dataBrowserQuery.
@RequestMapping(value = "/dataBrowserQuery", method = RequestMethod.GET)
public void dataBrowserQuery(HttpServletRequest request, HttpServletResponse response) throws IOException {
// get query string
String query = request.getParameter("query");
String members = request.getParameter("members");
int limit = 0;
try {
limit = Integer.valueOf(request.getParameter("limit"));
} catch (NumberFormatException e) {
limit = 0;
logger.debug(e);
}
ObjectNode queryResult = mapper.createObjectNode();
try {
if (StringUtils.isNotBlank(query)) {
// get cluster object
Cluster cluster = Repository.get().getCluster();
String userName = request.getUserPrincipal().getName();
// Call execute query method
queryResult = cluster.executeQuery(query, members, limit);
// Add query in history if query is executed successfully
if (!queryResult.has("error")) {
// Add html escaped query to history
String escapedQuery = StringEscapeUtils.escapeHtml(query);
cluster.addQueryInHistory(escapedQuery, userName);
}
}
} catch (Exception e) {
logger.debug("Exception Occurred : ", e);
}
response.getOutputStream().write(queryResult.toString().getBytes());
}
use of org.apache.geode.tools.pulse.internal.data.Cluster in project geode by apache.
the class PulseController method acknowledgeAlert.
@RequestMapping(value = "/acknowledgeAlert", method = RequestMethod.GET)
public void acknowledgeAlert(HttpServletRequest request, HttpServletResponse response) throws IOException {
int alertId;
ObjectNode responseJSON = mapper.createObjectNode();
try {
alertId = Integer.valueOf(request.getParameter("alertId"));
} catch (NumberFormatException e) {
// Empty json response
response.getOutputStream().write(responseJSON.toString().getBytes());
logger.debug(e);
return;
}
try {
// get cluster object
Cluster cluster = Repository.get().getCluster();
// set alert is acknowledged
cluster.acknowledgeAlert(alertId);
responseJSON.put("status", "deleted");
} catch (Exception e) {
logger.debug("Exception Occurred : {}", e);
}
// Send json response
response.getOutputStream().write(responseJSON.toString().getBytes());
}
use of org.apache.geode.tools.pulse.internal.data.Cluster in project geode by apache.
the class PulseController method getQueryStatisticsGridModel.
@RequestMapping(value = "/getQueryStatisticsGridModel", method = RequestMethod.GET)
public void getQueryStatisticsGridModel(HttpServletRequest request, HttpServletResponse response) throws IOException {
ObjectNode responseJSON = mapper.createObjectNode();
// get cluster object
Cluster cluster = Repository.get().getCluster();
String userName = request.getUserPrincipal().getName();
try {
String[] arrColNames = Cluster.Statement.getGridColumnNames();
String[] arrColAttribs = Cluster.Statement.getGridColumnAttributes();
int[] arrColWidths = Cluster.Statement.getGridColumnWidths();
ArrayNode colNamesList = mapper.createArrayNode();
for (int i = 0; i < arrColNames.length; ++i) {
colNamesList.add(arrColNames[i]);
}
ArrayNode colModelList = mapper.createArrayNode();
for (int i = 0; i < arrColAttribs.length; ++i) {
ObjectNode columnJSON = mapper.createObjectNode();
columnJSON.put("name", arrColAttribs[i]);
columnJSON.put("index", arrColAttribs[i]);
columnJSON.put("width", arrColWidths[i]);
columnJSON.put("sortable", "true");
columnJSON.put("sorttype", ((i == 0) ? "String" : "integer"));
colModelList.add(columnJSON);
}
responseJSON.put("columnNames", colNamesList);
responseJSON.put("columnModels", colModelList);
responseJSON.put("clusterName", cluster.getServerName());
responseJSON.put("userName", userName);
// Send json response
response.getOutputStream().write(responseJSON.toString().getBytes());
} catch (Exception e) {
logger.debug("Exception Occurred : ", e);
}
}
use of org.apache.geode.tools.pulse.internal.data.Cluster in project geode by apache.
the class PulseVerificationTest method testConnectToLocator.
@Test
public void testConnectToLocator() throws Exception {
pulse.useLocatorPort(locator.getPort());
Cluster cluster = pulse.getRepository().getCluster("admin", null);
assertThat(cluster.isConnectedFlag()).isTrue();
assertThat(cluster.getServerCount()).isEqualTo(0);
}
use of org.apache.geode.tools.pulse.internal.data.Cluster in project geode by apache.
the class PulseVerificationTest method testConnectToJmx.
@Test
public void testConnectToJmx() throws Exception {
pulse.useJmxPort(locator.getJmxPort());
Cluster cluster = pulse.getRepository().getCluster("admin", null);
assertThat(cluster.isConnectedFlag()).isTrue();
assertThat(cluster.getServerCount()).isEqualTo(0);
}
Aggregations