Search in sources :

Example 81 with CreateResponse

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;
}
Also used : CreateResponse(ddf.catalog.operation.CreateResponse) CreateRequest(ddf.catalog.operation.CreateRequest)

Example 82 with CreateResponse

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;
}
Also used : Metacard(ddf.catalog.data.Metacard) CreateResponse(ddf.catalog.operation.CreateResponse) Update(ddf.catalog.operation.Update)

Example 83 with CreateResponse

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;
}
Also used : CreateResponse(ddf.catalog.operation.CreateResponse)

Example 84 with 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));
}
Also used : CreateRequest(ddf.catalog.operation.CreateRequest) CreateResponse(ddf.catalog.operation.CreateResponse) Tag(io.micrometer.core.instrument.Tag) Test(org.junit.Test)

Example 85 with CreateResponse

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));
}
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)

Aggregations

CreateResponse (ddf.catalog.operation.CreateResponse)111 Test (org.junit.Test)82 Metacard (ddf.catalog.data.Metacard)76 CreateRequestImpl (ddf.catalog.operation.impl.CreateRequestImpl)44 ArrayList (java.util.ArrayList)42 CreateRequest (ddf.catalog.operation.CreateRequest)36 QueryImpl (ddf.catalog.operation.impl.QueryImpl)29 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)29 CreateResponseImpl (ddf.catalog.operation.impl.CreateResponseImpl)27 HashMap (java.util.HashMap)25 Serializable (java.io.Serializable)23 List (java.util.List)23 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)22 DeleteResponse (ddf.catalog.operation.DeleteResponse)22 UpdateResponse (ddf.catalog.operation.UpdateResponse)21 Filter (org.opengis.filter.Filter)21 IngestException (ddf.catalog.source.IngestException)20 SourceResponse (ddf.catalog.operation.SourceResponse)18 QueryRequest (ddf.catalog.operation.QueryRequest)17 MetacardType (ddf.catalog.data.MetacardType)16