Search in sources :

Example 1 with ProcessingDetails

use of ddf.catalog.operation.ProcessingDetails in project ddf by codice.

the class RemoveAllCommand method needsAlternateQueryAndResponse.

private boolean needsAlternateQueryAndResponse(SourceResponse response) {
    Set<ProcessingDetails> processingDetails = (Set<ProcessingDetails>) response.getProcessingDetails();
    if (processingDetails == null || processingDetails.iterator() == null) {
        return false;
    }
    Iterator<ProcessingDetails> iterator = processingDetails.iterator();
    while (iterator.hasNext()) {
        ProcessingDetails next = iterator.next();
        if (next != null && next.getException() != null && next.getException().getMessage() != null && next.getException().getMessage().contains(UnsupportedQueryException.class.getSimpleName())) {
            return true;
        }
    }
    return false;
}
Also used : ProcessingDetails(ddf.catalog.operation.ProcessingDetails) Set(java.util.Set)

Example 2 with ProcessingDetails

use of ddf.catalog.operation.ProcessingDetails in project ddf by codice.

the class CatalogMetrics method recordSourceQueryExceptions.

private void recordSourceQueryExceptions(QueryResponse response) {
    Set<ProcessingDetails> processingDetails = (Set<ProcessingDetails>) response.getProcessingDetails();
    if (processingDetails == null || processingDetails.iterator() == null) {
        return;
    }
    Iterator<ProcessingDetails> iterator = processingDetails.iterator();
    while (iterator.hasNext()) {
        ProcessingDetails next = iterator.next();
        if (next != null && next.getException() != null) {
            if (next.getException() instanceof UnsupportedQueryException) {
                unsupportedQueryExceptions.mark();
            } else if (next.getException() instanceof SourceUnavailableException) {
                sourceUnavailableExceptions.mark();
            } else if (next.getException() instanceof FederationException) {
                federationExceptions.mark();
            }
            exceptions.mark();
        }
    }
    return;
}
Also used : ProcessingDetails(ddf.catalog.operation.ProcessingDetails) SourceUnavailableException(ddf.catalog.source.SourceUnavailableException) Set(java.util.Set) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) FederationException(ddf.catalog.federation.FederationException)

Example 3 with ProcessingDetails

use of ddf.catalog.operation.ProcessingDetails 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));
}
Also used : ProcessingDetails(ddf.catalog.operation.ProcessingDetails) SourceUnavailableException(ddf.catalog.source.SourceUnavailableException) QueryResponseImpl(ddf.catalog.operation.impl.QueryResponseImpl) QueryImpl(ddf.catalog.operation.impl.QueryImpl) QueryResponse(ddf.catalog.operation.QueryResponse) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) FederationException(ddf.catalog.federation.FederationException) ProcessingDetailsImpl(ddf.catalog.operation.impl.ProcessingDetailsImpl) SourceUnavailableException(ddf.catalog.source.SourceUnavailableException) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) FederationException(ddf.catalog.federation.FederationException) Test(org.junit.Test)

Example 4 with ProcessingDetails

use of ddf.catalog.operation.ProcessingDetails 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;
}
Also used : ProcessingDetails(ddf.catalog.operation.ProcessingDetails) QueryResponseImpl(ddf.catalog.operation.impl.QueryResponseImpl) StopProcessingException(ddf.catalog.plugin.StopProcessingException) UUID(java.util.UUID) ProcessingDetailsImpl(ddf.catalog.operation.impl.ProcessingDetailsImpl)

Example 5 with ProcessingDetails

use of ddf.catalog.operation.ProcessingDetails in project ddf by codice.

the class UpdateOperations method doRemoteUpdate.

private UpdateResponse doRemoteUpdate(UpdateRequest updateRequest) {
    HashSet<ProcessingDetails> exceptions = new HashSet<>();
    Map<String, Serializable> properties = new HashMap<>();
    List<CatalogStore> stores = opsCatStoreSupport.getCatalogStoresForRequest(updateRequest, exceptions);
    List<Update> updates = new ArrayList<>();
    for (CatalogStore store : stores) {
        try {
            if (!store.isAvailable()) {
                exceptions.add(new ProcessingDetailsImpl(store.getId(), null, "CatalogStore is not available"));
            } else {
                UpdateResponse response = store.update(updateRequest);
                properties.put(store.getId(), new ArrayList<>(response.getUpdatedMetacards()));
                updates = response.getUpdatedMetacards();
            }
        } catch (IngestException e) {
            INGEST_LOGGER.error("Error updating metacards for CatalogStore {}", store.getId(), e);
            exceptions.add(new ProcessingDetailsImpl(store.getId(), e));
        }
    }
    return new UpdateResponseImpl(updateRequest, properties, updates, exceptions);
}
Also used : Serializable(java.io.Serializable) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Update(ddf.catalog.operation.Update) ProcessingDetailsImpl(ddf.catalog.operation.impl.ProcessingDetailsImpl) ProcessingDetails(ddf.catalog.operation.ProcessingDetails) CatalogStore(ddf.catalog.source.CatalogStore) UpdateResponse(ddf.catalog.operation.UpdateResponse) UpdateResponseImpl(ddf.catalog.operation.impl.UpdateResponseImpl) InternalIngestException(ddf.catalog.source.InternalIngestException) IngestException(ddf.catalog.source.IngestException) HashSet(java.util.HashSet)

Aggregations

ProcessingDetails (ddf.catalog.operation.ProcessingDetails)15 ProcessingDetailsImpl (ddf.catalog.operation.impl.ProcessingDetailsImpl)8 HashMap (java.util.HashMap)7 IngestException (ddf.catalog.source.IngestException)6 UnsupportedQueryException (ddf.catalog.source.UnsupportedQueryException)6 Serializable (java.io.Serializable)6 ArrayList (java.util.ArrayList)5 HashSet (java.util.HashSet)5 Metacard (ddf.catalog.data.Metacard)3 FederationException (ddf.catalog.federation.FederationException)3 SourceResponse (ddf.catalog.operation.SourceResponse)3 CatalogStore (ddf.catalog.source.CatalogStore)3 SourceUnavailableException (ddf.catalog.source.SourceUnavailableException)3 Result (ddf.catalog.data.Result)2 QueryResponse (ddf.catalog.operation.QueryResponse)2 CreateResponseImpl (ddf.catalog.operation.impl.CreateResponseImpl)2 QueryResponseImpl (ddf.catalog.operation.impl.QueryResponseImpl)2 UpdateResponseImpl (ddf.catalog.operation.impl.UpdateResponseImpl)2 InternalIngestException (ddf.catalog.source.InternalIngestException)2 Subject (ddf.security.Subject)2