use of ddf.catalog.operation.impl.ProcessingDetailsImpl in project ddf by codice.
the class CatalogMetricsTest method catalogExceptionMetric.
@Test
public void catalogExceptionMetric() throws Exception {
QueryResponse response = new QueryResponseImpl(new QueryRequestImpl(new QueryImpl(idFilter)));
Set<ProcessingDetails> details = response.getProcessingDetails();
details.addAll(new HashSet<ProcessingDetails>() {
{
add(new ProcessingDetailsImpl("source1", new UnsupportedQueryException()));
add(new ProcessingDetailsImpl("source2", new SourceUnavailableException()));
add(new ProcessingDetailsImpl("source3", new FederationException()));
add(new ProcessingDetailsImpl("source4", new Exception()));
}
});
underTest.process(response);
assertThat(underTest.exceptions.getCount(), is(4L));
assertThat(underTest.unsupportedQueryExceptions.getCount(), is(1L));
assertThat(underTest.sourceUnavailableExceptions.getCount(), is(1L));
assertThat(underTest.federationExceptions.getCount(), is(1L));
}
use of ddf.catalog.operation.impl.ProcessingDetailsImpl in project ddf by codice.
the class QueryRunnable method queryCatalog.
protected QueryResponse queryCatalog(String sourceId, SearchRequest searchRequest, Subject subject, Map<String, Serializable> properties) {
Query query = searchRequest.getQuery();
QueryResponse response = getEmptyResponse(sourceId);
long startTime = System.currentTimeMillis();
try {
if (query != null) {
List<String> sourceIds;
if (sourceId == null) {
sourceIds = new ArrayList<>(searchRequest.getSourceIds());
} else {
sourceIds = Collections.singletonList(sourceId);
}
QueryRequest request = new QueryRequestImpl(query, false, sourceIds, properties);
if (subject != null) {
LOGGER.debug("Adding {} property with value {} to request.", SecurityConstants.SECURITY_SUBJECT, subject);
request.getProperties().put(SecurityConstants.SECURITY_SUBJECT, subject);
}
LOGGER.debug("Sending query: {}", query);
response = searchController.getFramework().query(request);
}
} catch (UnsupportedQueryException | FederationException e) {
LOGGER.info("Error executing query. {}. Set log level to DEBUG for more information", e.getMessage());
LOGGER.debug("Error executing query", e);
response.getProcessingDetails().add(new ProcessingDetailsImpl(sourceId, e));
} catch (SourceUnavailableException e) {
LOGGER.info("Error executing query because the underlying source was unavailable. {}. Set log level to DEBUG for more information", e.getMessage());
LOGGER.debug("Error executing query because the underlying source was unavailable.", e);
response.getProcessingDetails().add(new ProcessingDetailsImpl(sourceId, e));
} catch (RuntimeException e) {
// Account for any runtime exceptions and send back a server error
// this prevents full stacktraces returning to the client
// this allows for a graceful server error to be returned
LOGGER.info("RuntimeException on executing query. {}. Set log level to DEBUG for more information", e.getMessage());
LOGGER.debug("RuntimeException on executing query", e);
response.getProcessingDetails().add(new ProcessingDetailsImpl(sourceId, e));
}
long estimatedTime = System.currentTimeMillis() - startTime;
response.getProperties().put("elapsed", estimatedTime);
return response;
}
use of ddf.catalog.operation.impl.ProcessingDetailsImpl in project ddf by codice.
the class QueryMonitorPluginImpl method process.
/**
* Method that is implemented for {@link PostFederatedQueryPlugin}. Uses the given {@link QueryResponse} information
* to remove the {@link ActiveSearch} from the {@link ActiveSearch} {@link Map}.
*
* @param input {@link QueryResponse} that corresponds to response from the source that was queried
* by the user's original {@link QueryRequest}
* @return {@link QueryResponse} that was given as a parameter
*/
@Override
public QueryResponse process(QueryResponse input) throws PluginExecutionException, StopProcessingException {
if (!removeSearchAfterComplete) {
LOGGER.debug("Not removing active search from map due to catalog:removeSearchAfterComplete false. To enable removing searches as searches finish, use command catalog:removesearchaftercomplete true.");
return input;
}
if (input == null) {
LOGGER.debug("Cannot remove ActiveSearch from the ActiveSearch Map. QueryResponse received in QueryMonitorPluginImpl was null.");
return null;
}
if (!removeActiveSearch((UUID) input.getRequest().getPropertyValue(SEARCH_ID))) {
QueryResponseImpl queryResponse = new QueryResponseImpl(input.getRequest(), new ArrayList<>(), 0);
queryResponse.closeResultQueue();
Set<ProcessingDetails> processingDetails = Collections.singleton(new ProcessingDetailsImpl(QueryMonitorPlugin.class.getCanonicalName(), new StopProcessingException("Query was cancelled by administrator")));
queryResponse.setProcessingDetails(processingDetails);
return queryResponse;
}
return input;
}
use of ddf.catalog.operation.impl.ProcessingDetailsImpl in project ddf by codice.
the class SortedQueryMonitor method timeoutRemainingSources.
private void timeoutRemainingSources(Set<ProcessingDetails> processingDetails) {
for (QueryRequest expiredSource : futures.values()) {
if (expiredSource != null) {
String sourceId = getSourceIdFromRequest(expiredSource);
LOGGER.info("Search timed out for {}", sourceId);
processingDetails.add(new ProcessingDetailsImpl(sourceId, new TimeoutException()));
}
}
}
use of ddf.catalog.operation.impl.ProcessingDetailsImpl in project ddf by codice.
the class ProcessingDetailsImplTest method testInequalityOfWarnings.
@Test
public void testInequalityOfWarnings() {
String sourceId = "test source";
Exception exception = new UnsupportedQueryException("We do not support this query");
List<String> warning = Collections.singletonList("warning");
List<String> differentWarning = Collections.singletonList("different warning");
ProcessingDetails processingDetails = new ProcessingDetailsImpl(sourceId, exception, warning);
ProcessingDetails processingDetailsWithDifferentWarnings = new ProcessingDetailsImpl(sourceId, exception, differentWarning);
assertThat(processingDetails, is(not(processingDetailsWithDifferentWarnings)));
}
Aggregations