use of ddf.catalog.operation.impl.ProcessingDetailsImpl in project ddf by codice.
the class CatalogMetricsTest method catalogResourceExceptionMetric.
@Test
public void catalogResourceExceptionMetric() throws Exception {
Iterable<Tag> ioExceptionTags = Tags.of("type", IOException.class.getName(), "source", "source5");
ResourceRequest request = mock(ResourceRequest.class);
ResourceResponse response = mock(ResourceResponse.class);
mockCatalogResponseExceptions(request, response, new ProcessingDetailsImpl("source5", new IOException()));
catalogMetrics.process(response);
assertThat(meterRegistry.counter("ddf.catalog.resource.exceptions", ioExceptionTags).count(), is(1.0));
}
use of ddf.catalog.operation.impl.ProcessingDetailsImpl in project ddf by codice.
the class CatalogMetricsTest method catalogQueryExceptionMetric.
@Test
public void catalogQueryExceptionMetric() throws Exception {
Iterable<Tag> unsupportedQueryExceptionTags = Tags.of("type", UnsupportedQueryException.class.getName(), "source", "source1");
QueryResponse response = new QueryResponseImpl(new QueryRequestImpl(new QueryImpl(idFilter)), Collections.emptyList(), true, 0, Collections.emptyMap(), Collections.singleton(new ProcessingDetailsImpl("source1", new ExecutionException(new UnsupportedQueryException()))));
catalogMetrics.process(response);
assertThat(meterRegistry.counter("ddf.catalog.query.exceptions", unsupportedQueryExceptionTags).count(), is(1.0));
}
use of ddf.catalog.operation.impl.ProcessingDetailsImpl in project ddf by codice.
the class CatalogMetricsTest method catalogDeleteExceptionMetric.
@Test
public void catalogDeleteExceptionMetric() throws Exception {
Iterable<Tag> deleteExceptionTags = Tags.of("type", Exception.class.getName(), "source", "source4");
DeleteRequest request = mock(DeleteRequest.class);
DeleteResponse response = mock(DeleteResponse.class);
mockCatalogResponseExceptions(request, response, new ProcessingDetailsImpl("source4", new Exception()));
catalogMetrics.process(response);
assertThat(meterRegistry.counter("ddf.catalog.delete.exceptions", deleteExceptionTags).count(), is(1.0));
}
use of ddf.catalog.operation.impl.ProcessingDetailsImpl in project ddf by codice.
the class SortedQueryMonitor method executePostFederationQueryPluginsWithSourceError.
/**
* Execute Post Federation Query Plugins with a new processing error.
*
* @param queryRequest
* @param sourceId
* @param e
* @return
*/
private SourceResponse executePostFederationQueryPluginsWithSourceError(QueryRequest queryRequest, String sourceId, Exception e) {
ProcessingDetails processingDetail = new ProcessingDetailsImpl(sourceId, e);
SourceResponse sourceResponse = new SourceResponseImpl(queryRequest, new ArrayList<>());
return executePostFederationQueryPlugins(sourceResponse, queryRequest, sourceId, Collections.singleton(processingDetail));
}
use of ddf.catalog.operation.impl.ProcessingDetailsImpl in project ddf by codice.
the class SortedQueryMonitorTest method testPersistenceOfProcessingDetails.
@Test
public void testPersistenceOfProcessingDetails() throws InterruptedException, ExecutionException {
Map<Future<SourceResponse>, QueryRequest> futures = new HashMap<>();
Future mockedFuture = mock(Future.class);
SourceResponse mockedSourceResponseWithProcessingDetails = mock(SourceResponse.class);
when(mockedFuture.get()).thenReturn(mockedSourceResponseWithProcessingDetails);
Set<ProcessingDetails> processingDetailsOfMockedSourceResponse = new HashSet<>();
doReturn(processingDetailsOfMockedSourceResponse).when(mockedSourceResponseWithProcessingDetails).getProcessingErrors();
QueryRequest mockedQueryRequest = mock(QueryRequest.class);
String idOfTestSource = "test source";
when(mockedQueryRequest.getSourceIds()).thenReturn(Collections.singleton(idOfTestSource));
List<String> errorFromMalformedQuery = Collections.singletonList("We do not support this query.");
final Exception exception = new Exception("test exception");
ProcessingDetails processingDetailsForMalformedQuery = new ProcessingDetailsImpl(idOfTestSource, exception, errorFromMalformedQuery);
processingDetailsOfMockedSourceResponse.add(processingDetailsForMalformedQuery);
List<String> nonspecificError = Collections.singletonList("Something went wrong.");
ProcessingDetails processingDetailsForNonspecificError = new ProcessingDetailsImpl(idOfTestSource, null, nonspecificError);
processingDetailsOfMockedSourceResponse.add(processingDetailsForNonspecificError);
futures.put(mockedFuture, mockedQueryRequest);
when(queryRequest.getQuery()).thenReturn(query);
when(query.getTimeoutMillis()).thenReturn(0L);
SortedQueryMonitor queryMonitor = new SortedQueryMonitor(completionService, futures, queryResponse, queryRequest, new ArrayList<>());
final Iterator<Future<SourceResponse>> iterator = futures.keySet().iterator();
when(completionService.take()).thenAnswer((invocationOnMock -> iterator.next()));
queryMonitor.run();
verify(completionService, times(1)).take();
verify(completionService, never()).poll(anyLong(), eq(TimeUnit.MILLISECONDS));
assertThat(queryResponse.getProcessingDetails()).extracting(byName("sourceId")).containsOnly(idOfTestSource);
assertThat(queryResponse.getProcessingDetails()).extracting(byName("warnings")).containsOnly(errorFromMalformedQuery, nonspecificError);
assertThat(queryResponse.getProcessingDetails()).extracting(byName("exception")).contains(exception);
}
Aggregations