private void httpDelete(String url, String warningMessage) { HttpDelete delete = new HttpDelete(url); try { CloseableHttpResponse httpResponse = httpClient.execute(delete); EntityUtils.consumeQuietly(httpResponse.getEntity()); } catch (IOException e) { LOGGER.warn(warningMessage, e); throw new ActivityRequestFailed(warningMessage, e); } } }
public List<BatchExecution> retrieveBatches() { HttpGet get = new HttpGet(batchUrl); try { CloseableHttpResponse response = httpClient.execute(get); String body = EntityUtils.toString(response.getEntity()); LOGGER.debug("Received response {}", body); BatchExecution[] batchExecutions = (BatchExecution[]) gson.fromJson(body, (Class) BatchExecution[].class); LOGGER.debug("Parsed batch executions {}", Arrays.toString(batchExecutions)); return Arrays.asList(batchExecutions); } catch (IOException e) { LOGGER.info(REQUEST_FOR_CONNECTIONS_FAILED, e); throw new ActivityRequestFailed(REQUEST_FOR_CONNECTIONS_FAILED, e); } }
/** * Retrieves all the queries that have been sent to the configured Scassandra server. * * @return A List of Query objects */ public List<Query> retrieveQueries() { HttpGet get = new HttpGet(queryUrl); try { CloseableHttpResponse response = httpClient.execute(get); String body = EntityUtils.toString(response.getEntity()); LOGGER.debug("Received response {}", body); Query[] queries = (Query[]) gson.fromJson(body, (Class) Query[].class); LOGGER.debug("Parsed queries {}", Arrays.toString(queries)); return Arrays.asList(queries); } catch (IOException e) { LOGGER.info(REQUEST_FOR_QUERIES_FAILED, e); throw new ActivityRequestFailed(REQUEST_FOR_QUERIES_FAILED, e); } }
/** * Retrieves all the connections that have been sent to the configured Scassandra server. * * @return A List of Connection objects */ public List<Connection> retrieveConnections() { HttpGet get = new HttpGet(connectionUrl); try { CloseableHttpResponse response = httpClient.execute(get); String body = EntityUtils.toString(response.getEntity()); LOGGER.debug("Received response {}", body); Connection[] connections = (Connection[]) gson.fromJson(body, (Class) Connection[].class); LOGGER.debug("Parsed connections {}", Arrays.toString(connections)); return Arrays.asList(connections); } catch (IOException e) { LOGGER.info(REQUEST_FOR_CONNECTIONS_FAILED, e); throw new ActivityRequestFailed(REQUEST_FOR_CONNECTIONS_FAILED, e); } }
/** * Retrieves the recorded prepared statement preparations. Note this the prepare * calls your applications makes, not the executions. * * @return PreparedStatementPreparation */ public List<PreparedStatementPreparation> retrievePreparedStatementPreparations() { HttpGet get = new HttpGet(preparedStatementPreparationUrl); try { CloseableHttpResponse response = httpClient.execute(get); String body = EntityUtils.toString(response.getEntity()); LOGGER.debug("Received response {}", body); int statusCode = response.getStatusLine().getStatusCode(); if (statusCode != 200) { String errorMessage = String.format("Non 200 status code when retrieving prepared statement preparations %s", statusCode); LOGGER.info(errorMessage); throw new ActivityRequestFailed(errorMessage); } PreparedStatementPreparation[] preparations = (PreparedStatementPreparation[]) gson.fromJson(body, (Class) PreparedStatementPreparation[].class); LOGGER.debug("Parsed prepared statement preparations {}", Arrays.toString(preparations)); return Arrays.asList(preparations); } catch (IOException e) { LOGGER.info(REQUEST_FAILED, e); throw new ActivityRequestFailed(REQUEST_FAILED, e); } }
/** * Retrieves the recorded prepared statement executions. Note this is the executions, not the prepare * calls your applications makes. * * If you haven't primed the prepared statement then the variable types will be empty. * * @return PreparedStatementExecution */ public List<PreparedStatementExecution> retrievePreparedStatementExecutions() { HttpGet get = new HttpGet(preparedStatementExecutionUrl); try { CloseableHttpResponse response = httpClient.execute(get); String body = EntityUtils.toString(response.getEntity()); LOGGER.debug("Received response {}", body); int statusCode = response.getStatusLine().getStatusCode(); if (statusCode != 200) { String errorMessage = String.format("Non 200 status code when retrieving prepared statement executions %s", statusCode); LOGGER.info(errorMessage); throw new ActivityRequestFailed(errorMessage); } PreparedStatementExecution[] executions = (PreparedStatementExecution[]) gson.fromJson(body, (Class) PreparedStatementExecution[].class); LOGGER.debug("Parsed prepared statement executions {}", Arrays.toString(executions)); return Arrays.asList(executions); } catch (IOException e) { LOGGER.info(REQUEST_FAILED, e); throw new ActivityRequestFailed(REQUEST_FAILED, e); } }