Search in sources :

Example 11 with ProcessingDetailsImpl

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));
}
Also used : ResourceResponse(ddf.catalog.operation.ResourceResponse) Tag(io.micrometer.core.instrument.Tag) IOException(java.io.IOException) ResourceRequest(ddf.catalog.operation.ResourceRequest) ProcessingDetailsImpl(ddf.catalog.operation.impl.ProcessingDetailsImpl) Test(org.junit.Test)

Example 12 with ProcessingDetailsImpl

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));
}
Also used : QueryResponseImpl(ddf.catalog.operation.impl.QueryResponseImpl) QueryImpl(ddf.catalog.operation.impl.QueryImpl) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) QueryResponse(ddf.catalog.operation.QueryResponse) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) Tag(io.micrometer.core.instrument.Tag) ExecutionException(java.util.concurrent.ExecutionException) ProcessingDetailsImpl(ddf.catalog.operation.impl.ProcessingDetailsImpl) Test(org.junit.Test)

Example 13 with ProcessingDetailsImpl

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));
}
Also used : DeleteResponse(ddf.catalog.operation.DeleteResponse) Tag(io.micrometer.core.instrument.Tag) DeleteRequest(ddf.catalog.operation.DeleteRequest) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) ExpectedException(org.junit.rules.ExpectedException) IngestException(ddf.catalog.source.IngestException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) ProcessingDetailsImpl(ddf.catalog.operation.impl.ProcessingDetailsImpl) Test(org.junit.Test)

Example 14 with ProcessingDetailsImpl

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));
}
Also used : SourceProcessingDetails(ddf.catalog.operation.SourceProcessingDetails) ProcessingDetails(ddf.catalog.operation.ProcessingDetails) SourceResponse(ddf.catalog.operation.SourceResponse) SourceResponseImpl(ddf.catalog.operation.impl.SourceResponseImpl) ProcessingDetailsImpl(ddf.catalog.operation.impl.ProcessingDetailsImpl)

Example 15 with ProcessingDetailsImpl

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);
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) ProcessingDetailsImpl(ddf.catalog.operation.impl.ProcessingDetailsImpl) Arrays(java.util.Arrays) ArgumentMatchers.anyLong(org.mockito.ArgumentMatchers.anyLong) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Date(java.util.Date) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) QueryResponseImpl(ddf.catalog.operation.impl.QueryResponseImpl) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) TimeoutException(java.util.concurrent.TimeoutException) HashMap(java.util.HashMap) CompletionService(java.util.concurrent.CompletionService) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) Extractors.byName(org.assertj.core.extractor.Extractors.byName) Future(java.util.concurrent.Future) SortBy(org.opengis.filter.sort.SortBy) Metacard(ddf.catalog.data.Metacard) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Map(java.util.Map) QueryRequest(ddf.catalog.operation.QueryRequest) Awaitility.with(org.awaitility.Awaitility.with) Mockito.doReturn(org.mockito.Mockito.doReturn) Result(ddf.catalog.data.Result) SortOrder(org.opengis.filter.sort.SortOrder) Before(org.junit.Before) Iterator(java.util.Iterator) ImmutableMap(com.google.common.collect.ImmutableMap) ResultImpl(ddf.catalog.data.impl.ResultImpl) Set(java.util.Set) Mockito.times(org.mockito.Mockito.times) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) Serializable(java.io.Serializable) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) Query(ddf.catalog.operation.Query) Mockito.never(org.mockito.Mockito.never) SourceResponse(ddf.catalog.operation.SourceResponse) List(java.util.List) Attribute(ddf.catalog.data.Attribute) PropertyName(org.opengis.filter.expression.PropertyName) ProcessingDetails(ddf.catalog.operation.ProcessingDetails) Lists(org.assertj.core.util.Lists) Collections(java.util.Collections) Mockito.mock(org.mockito.Mockito.mock) QueryRequest(ddf.catalog.operation.QueryRequest) SourceResponse(ddf.catalog.operation.SourceResponse) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) TimeoutException(java.util.concurrent.TimeoutException) ExecutionException(java.util.concurrent.ExecutionException) ProcessingDetailsImpl(ddf.catalog.operation.impl.ProcessingDetailsImpl) ProcessingDetails(ddf.catalog.operation.ProcessingDetails) Future(java.util.concurrent.Future) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

ProcessingDetailsImpl (ddf.catalog.operation.impl.ProcessingDetailsImpl)37 Test (org.junit.Test)19 UnsupportedQueryException (ddf.catalog.source.UnsupportedQueryException)18 ProcessingDetails (ddf.catalog.operation.ProcessingDetails)13 QueryResponseImpl (ddf.catalog.operation.impl.QueryResponseImpl)8 IngestException (ddf.catalog.source.IngestException)8 HashSet (java.util.HashSet)8 QueryRequest (ddf.catalog.operation.QueryRequest)7 SourceResponse (ddf.catalog.operation.SourceResponse)6 Serializable (java.io.Serializable)6 HashMap (java.util.HashMap)6 Tag (io.micrometer.core.instrument.Tag)5 ArrayList (java.util.ArrayList)5 Metacard (ddf.catalog.data.Metacard)4 QueryResponse (ddf.catalog.operation.QueryResponse)4 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)4 CatalogStore (ddf.catalog.source.CatalogStore)3 SourceUnavailableException (ddf.catalog.source.SourceUnavailableException)3 ExecutionException (java.util.concurrent.ExecutionException)3 TimeoutException (java.util.concurrent.TimeoutException)3