Search in sources :

Example 26 with ProcessingDetailsImpl

use of ddf.catalog.operation.impl.ProcessingDetailsImpl in project ddf by codice.

the class RemoteDeleteOperations method doRemoteDelete.

private DeleteResponse doRemoteDelete(DeleteRequest deleteRequest) {
    HashSet<ProcessingDetails> exceptions = new HashSet<>();
    Map<String, Serializable> properties = new HashMap<>();
    List<CatalogStore> stores = opsCatStoreSupport.getCatalogStoresForRequest(deleteRequest, exceptions);
    List<Metacard> metacards = new ArrayList<>();
    for (CatalogStore store : stores) {
        try {
            if (!store.isAvailable()) {
                exceptions.add(new ProcessingDetailsImpl(store.getId(), null, "CatalogStore is not available"));
            } else {
                // TODO: 4/27/17 Address bug in DDF-2970 for overwriting deleted metacards
                DeleteResponse response = store.delete(deleteRequest);
                properties.put(store.getId(), new ArrayList<>(response.getDeletedMetacards()));
                metacards = response.getDeletedMetacards();
            }
        } catch (IngestException e) {
            INGEST_LOGGER.error("Error deleting metacards for CatalogStore {}", store.getId(), e);
            exceptions.add(new ProcessingDetailsImpl(store.getId(), e));
        }
    }
    return new DeleteResponseImpl(deleteRequest, properties, metacards, exceptions);
}
Also used : Serializable(java.io.Serializable) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ProcessingDetailsImpl(ddf.catalog.operation.impl.ProcessingDetailsImpl) ProcessingDetails(ddf.catalog.operation.ProcessingDetails) CatalogStore(ddf.catalog.source.CatalogStore) Metacard(ddf.catalog.data.Metacard) DeleteResponse(ddf.catalog.operation.DeleteResponse) DeleteResponseImpl(ddf.catalog.operation.impl.DeleteResponseImpl) IngestException(ddf.catalog.source.IngestException) HashSet(java.util.HashSet)

Example 27 with ProcessingDetailsImpl

use of ddf.catalog.operation.impl.ProcessingDetailsImpl in project ddf by codice.

the class CatalogMetricsTest method catalogUpdateExceptionMetric.

@Test
public void catalogUpdateExceptionMetric() throws Exception {
    Iterable<Tag> updateExceptionTags = Tags.of("type", IngestException.class.getName(), "source", "source3");
    UpdateRequest request = mock(UpdateRequest.class);
    UpdateResponse response = mock(UpdateResponse.class);
    mockCatalogResponseExceptions(request, response, new ProcessingDetailsImpl("source3", new IngestException()));
    catalogMetrics.process(response);
    assertThat(meterRegistry.counter("ddf.catalog.update.exceptions", updateExceptionTags).count(), is(1.0));
}
Also used : UpdateResponse(ddf.catalog.operation.UpdateResponse) UpdateRequest(ddf.catalog.operation.UpdateRequest) IngestException(ddf.catalog.source.IngestException) Tag(io.micrometer.core.instrument.Tag) ProcessingDetailsImpl(ddf.catalog.operation.impl.ProcessingDetailsImpl) Test(org.junit.Test)

Example 28 with ProcessingDetailsImpl

use of ddf.catalog.operation.impl.ProcessingDetailsImpl in project ddf by codice.

the class CatalogMetricsTest method catalogCreateExceptionMetric.

@Test
public void catalogCreateExceptionMetric() throws Exception {
    Iterable<Tag> createExceptionTags = Tags.of("type", IngestException.class.getName(), "source", "source2");
    CreateRequest request = mock(CreateRequest.class);
    CreateResponse response = mock(CreateResponse.class);
    mockCatalogResponseExceptions(request, response, new ProcessingDetailsImpl("source2", new IngestException()));
    catalogMetrics.process(response);
    assertThat(meterRegistry.counter("ddf.catalog.create.exceptions", createExceptionTags).count(), is(1.0));
}
Also used : CreateRequest(ddf.catalog.operation.CreateRequest) CreateResponse(ddf.catalog.operation.CreateResponse) IngestException(ddf.catalog.source.IngestException) Tag(io.micrometer.core.instrument.Tag) ProcessingDetailsImpl(ddf.catalog.operation.impl.ProcessingDetailsImpl) Test(org.junit.Test)

Example 29 with ProcessingDetailsImpl

use of ddf.catalog.operation.impl.ProcessingDetailsImpl in project ddf by codice.

the class SourceMetricsImplTest method testExceptionCounterForQueryResponse.

@Test
public void testExceptionCounterForQueryResponse() throws PluginExecutionException, StopProcessingException {
    QueryResponse queryResponse = mock(QueryResponse.class);
    Set<ProcessingDetails> processingDetails = Stream.of(new ProcessingDetailsImpl("testSource", new Exception())).collect(Collectors.toSet());
    when(queryResponse.getProcessingDetails()).thenReturn(processingDetails);
    sourceMetricsImpl.process(queryResponse);
    String suffix = METRICS_PREFIX + "." + QUERY_SCOPE + "." + EXCEPTION_TYPE;
    assertThat(meterRegistry.counter(suffix, "source", "testSource").count(), is(1.0));
}
Also used : ProcessingDetails(ddf.catalog.operation.ProcessingDetails) QueryResponse(ddf.catalog.operation.QueryResponse) ProcessingDetailsImpl(ddf.catalog.operation.impl.ProcessingDetailsImpl) PluginExecutionException(ddf.catalog.plugin.PluginExecutionException) StopProcessingException(ddf.catalog.plugin.StopProcessingException) Test(org.junit.Test)

Example 30 with ProcessingDetailsImpl

use of ddf.catalog.operation.impl.ProcessingDetailsImpl in project ddf by codice.

the class ProcessingDetailsImplTest method testInequalityOfSourceIds.

@Test
public void testInequalityOfSourceIds() {
    String sourceId = "test source";
    String differentSourceId = "different test source";
    Exception exception = new UnsupportedQueryException("We do not support this query");
    List<String> warning = Collections.singletonList("warning");
    ProcessingDetails processingDetails = new ProcessingDetailsImpl(sourceId, exception, warning);
    ProcessingDetails processingDetailsWithDifferentSourceId = new ProcessingDetailsImpl(differentSourceId, exception, warning);
    assertThat(processingDetails, is(not(processingDetailsWithDifferentSourceId)));
}
Also used : UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) ProcessingDetailsImpl(ddf.catalog.operation.impl.ProcessingDetailsImpl) 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