use of ddf.catalog.operation.CreateResponse in project ddf by codice.
the class CatalogBackupPluginTest method getCreateResponse.
private CreateResponse getCreateResponse(String[] ids) {
CreateResponse mockCreateResponse = mock(CreateResponse.class);
when(mockCreateResponse.getCreatedMetacards()).thenReturn(getMetacards(ids, BASE_OLD_TITLE));
when(mockCreateResponse.getRequest()).thenReturn(mock(CreateRequest.class));
return mockCreateResponse;
}
use of ddf.catalog.operation.CreateResponse in project ddf by codice.
the class Historian method version.
/**
* Versions metacards being updated based off of the {@link Update#getOldMetacard} method on
* {@link UpdateResponse}
*
* @param updateResponse Versioned metacards created from any old metacards
* @return The original UpdateResponse
*/
public UpdateResponse version(UpdateResponse updateResponse) {
if (doSkip(updateResponse)) {
return updateResponse;
}
setSkipFlag(updateResponse);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Versioning updated metacards: {}", updateResponse.getUpdatedMetacards());
}
List<Metacard> inputMetacards = updateResponse.getUpdatedMetacards().stream().map(Update::getOldMetacard).filter(isNotVersionNorDeleted).collect(Collectors.toList());
if (inputMetacards.isEmpty()) {
LOGGER.trace("No updated metacards applicable to versioning");
return updateResponse;
}
final Map<String, Metacard> versionedMetacards = getVersionMetacards(inputMetacards, id -> Action.VERSIONED, (Subject) updateResponse.getRequest().getProperties().get(SecurityConstants.SECURITY_SUBJECT));
CreateResponse response = storeVersionMetacards(versionedMetacards);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Successfully created metacard versions under ids: {}", response.getCreatedMetacards().stream().map(Metacard::getId).collect(TO_A_STRING));
}
return updateResponse;
}
use of ddf.catalog.operation.CreateResponse in project ddf by codice.
the class CreateOperations method create.
//
// Delegate methods
//
public CreateResponse create(CreateRequest createRequest) throws IngestException, SourceUnavailableException {
CreateResponse createResponse = doCreate(createRequest);
createResponse = doPostIngest(createResponse);
return createResponse;
}
use of ddf.catalog.operation.CreateResponse in project ddf by codice.
the class CatalogMetricsTest method catalogPostCreateLatencyMetric.
@Test
public void catalogPostCreateLatencyMetric() throws Exception {
Iterable<Tag> tags = Tags.of("successful", "true");
CreateRequest request = mock(CreateRequest.class);
CreateResponse response = mock(CreateResponse.class);
when(response.getRequest()).thenReturn(request);
when(request.getPropertyValue("metrics.catalog.operation.start")).thenReturn(System.currentTimeMillis() - 1000);
catalogMetrics.process(response);
assertThat(meterRegistry.summary("ddf.catalog.create.latency", tags).count(), is(1L));
assertThat(meterRegistry.summary("ddf.catalog.create.latency", tags).max(), greaterThanOrEqualTo(1000.0));
}
use of ddf.catalog.operation.CreateResponse 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));
}
Aggregations