use of ddf.catalog.operation.ProcessingDetails in project ddf by codice.
the class SourceMetricsImpl method process.
// PostFederatedQuery
@Override
public QueryResponse process(QueryResponse input) throws PluginExecutionException, StopProcessingException {
LOGGER.trace("ENTERING: process (for PostFederatedQueryPlugin)");
if (null != input) {
Set<ProcessingDetails> processingDetails = input.getProcessingDetails();
List<Result> results = input.getResults();
// Total Exceptions metric per Source
Iterator<ProcessingDetails> iterator = processingDetails.iterator();
while (iterator.hasNext()) {
ProcessingDetails next = iterator.next();
if (next != null && next.getException() != null) {
String sourceId = next.getSourceId();
updateMetric(sourceId, EXCEPTIONS_SCOPE, 1);
}
}
Map<String, Integer> totalHitsPerSource = new HashMap<String, Integer>();
for (Result result : results) {
String sourceId = result.getMetacard().getSourceId();
if (totalHitsPerSource.containsKey(sourceId)) {
totalHitsPerSource.put(sourceId, totalHitsPerSource.get(sourceId) + 1);
} else {
// First detection of this new source ID in the results list -
// initialize the Total Query Result Count for this Source
totalHitsPerSource.put(sourceId, 1);
}
}
// Total Query Results metric per Source
for (Map.Entry<String, Integer> source : totalHitsPerSource.entrySet()) {
updateMetric(source.getKey(), QUERIES_TOTAL_RESULTS_SCOPE, source.getValue());
}
}
LOGGER.trace("EXITING: process (for PostFederatedQueryPlugin)");
return input;
}
use of ddf.catalog.operation.ProcessingDetails in project ddf by codice.
the class SortedQueryMonitor method executePostFederationQueryPluginsWithSourceError.
private void executePostFederationQueryPluginsWithSourceError(QueryRequest queryRequest, String sourceId, Exception e, Set<ProcessingDetails> processingDetails) {
ProcessingDetails processingDetail = new ProcessingDetailsImpl(sourceId, e);
SourceResponse sourceResponse = new SourceResponseImpl(queryRequest, new ArrayList<>());
sourceResponse.getProcessingErrors().add(processingDetail);
processingDetails.add(processingDetail);
executePostFederationQueryPlugins(sourceResponse, queryRequest);
}
use of ddf.catalog.operation.ProcessingDetails in project ddf by codice.
the class FederationAdminServiceImpl method stringifyProcessingErrors.
private String stringifyProcessingErrors(Set<ProcessingDetails> details) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
for (ProcessingDetails detail : details) {
pw.append(detail.getSourceId());
pw.append(":");
if (detail.hasException()) {
detail.getException().printStackTrace(pw);
}
pw.append(System.lineSeparator());
}
return pw.toString();
}
use of ddf.catalog.operation.ProcessingDetails in project ddf by codice.
the class AbstractCswStore method update.
@Override
public UpdateResponse update(UpdateRequest updateRequest) throws IngestException {
Map<String, Serializable> properties = new HashMap<>();
validateOperation();
Subject subject = (Subject) updateRequest.getPropertyValue(SecurityConstants.SECURITY_SUBJECT);
Csw csw = factory.getClientForSubject(subject);
CswTransactionRequest transactionRequest = getTransactionRequest();
OperationTransaction opTrans = (OperationTransaction) updateRequest.getPropertyValue(Constants.OPERATION_TRANSACTION_KEY);
String insertTypeName = schemaTransformerManager.getTransformerIdForSchema(cswSourceConfiguration.getOutputSchema());
HashSet<ProcessingDetails> errors = new HashSet<>();
if (insertTypeName == null) {
insertTypeName = CswConstants.CSW_RECORD;
}
ArrayList<Metacard> updatedMetacards = new ArrayList<>(updateRequest.getUpdates().size());
ArrayList<Filter> updatedMetacardFilters = new ArrayList<>(updateRequest.getUpdates().size());
for (Map.Entry<Serializable, Metacard> update : updateRequest.getUpdates()) {
Metacard metacard = update.getValue();
properties.put(metacard.getId(), metacard);
updatedMetacardFilters.add(filterBuilder.attribute(updateRequest.getAttributeName()).is().equalTo().text(update.getKey().toString()));
transactionRequest.getUpdateActions().add(new UpdateAction(metacard, insertTypeName, null));
}
try {
TransactionResponseType response = csw.transaction(transactionRequest);
if (response.getTransactionSummary().getTotalUpdated().longValue() != updateRequest.getUpdates().size()) {
errors.add(new ProcessingDetailsImpl(this.getId(), null, "One or more updates failed"));
}
} catch (CswException e) {
throw new IngestException("Csw Transaction Failed.", e);
}
try {
updatedMetacards.addAll(transactionQuery(updatedMetacardFilters, subject));
} catch (UnsupportedQueryException e) {
errors.add(new ProcessingDetailsImpl(this.getId(), e, "Failed to retrieve updated metacards"));
}
return new UpdateResponseImpl(updateRequest, properties, updatedMetacards, new ArrayList(opTrans.getPreviousStateMetacards()), errors);
}
use of ddf.catalog.operation.ProcessingDetails 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);
}
Aggregations