Search in sources :

Example 6 with ExternalStorageLocation

use of com.netflix.conductor.common.run.ExternalStorageLocation in project conductor by Netflix.

the class ExternalPayloadStorageUtilsTest method testUploadHelper.

@Test
public void testUploadHelper() {
    AtomicInteger uploadCount = new AtomicInteger(0);
    String path = "some/test/path.json";
    ExternalStorageLocation location = new ExternalStorageLocation();
    location.setPath(path);
    when(externalPayloadStorage.getLocation(any(), any(), any())).thenReturn(location);
    doAnswer(invocation -> {
        uploadCount.incrementAndGet();
        return null;
    }).when(externalPayloadStorage).upload(anyString(), any(), anyLong());
    assertEquals(path, externalPayloadStorageUtils.uploadHelper(new byte[] {}, 10L, ExternalPayloadStorage.PayloadType.TASK_OUTPUT));
    assertEquals(1, uploadCount.get());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ExternalStorageLocation(com.netflix.conductor.common.run.ExternalStorageLocation) Test(org.junit.Test)

Example 7 with ExternalStorageLocation

use of com.netflix.conductor.common.run.ExternalStorageLocation in project conductor by Netflix.

the class ExternalPayloadStorageUtilsTest method setup.

@Before
public void setup() {
    externalPayloadStorage = mock(ExternalPayloadStorage.class);
    Configuration configuration = new TestConfiguration();
    objectMapper = new JsonMapperProvider().get();
    location = new ExternalStorageLocation();
    location.setPath("some/test/path");
    externalPayloadStorageUtils = new ExternalPayloadStorageUtils(externalPayloadStorage, configuration, objectMapper);
}
Also used : TestConfiguration(com.netflix.conductor.core.execution.TestConfiguration) Configuration(com.netflix.conductor.core.config.Configuration) TestConfiguration(com.netflix.conductor.core.execution.TestConfiguration) ExternalPayloadStorage(com.netflix.conductor.common.utils.ExternalPayloadStorage) ExternalStorageLocation(com.netflix.conductor.common.run.ExternalStorageLocation) JsonMapperProvider(com.netflix.conductor.common.utils.JsonMapperProvider) Before(org.junit.Before)

Example 8 with ExternalStorageLocation

use of com.netflix.conductor.common.run.ExternalStorageLocation in project conductor by Netflix.

the class MockExternalPayloadStorage method getLocation.

@Override
public ExternalStorageLocation getLocation(Operation operation, PayloadType payloadType, String path) {
    ExternalStorageLocation location = new ExternalStorageLocation();
    location.setUri("http://some/uri");
    switch(payloadType) {
        case TASK_INPUT:
        case WORKFLOW_INPUT:
            location.setPath(INPUT_PAYLOAD_PATH);
            break;
        case WORKFLOW_OUTPUT:
            location.setPath(WORKFLOW_OUTPUT_PATH);
            break;
        case TASK_OUTPUT:
            location.setPath(TASK_OUTPUT_PATH);
            break;
    }
    return location;
}
Also used : ExternalStorageLocation(com.netflix.conductor.common.run.ExternalStorageLocation)

Example 9 with ExternalStorageLocation

use of com.netflix.conductor.common.run.ExternalStorageLocation in project conductor by Netflix.

the class AzureBlobPayloadStorageTest method testGetLocationFixedPath.

@Test
public void testGetLocationFixedPath() {
    testConfiguration.setConnectionString(azuriteConnectionString);
    AzureBlobPayloadStorage azureBlobPayloadStorage = new AzureBlobPayloadStorage(testConfiguration);
    ExternalStorageLocation externalStorageLocation = azureBlobPayloadStorage.getLocation(ExternalPayloadStorage.Operation.READ, ExternalPayloadStorage.PayloadType.WORKFLOW_INPUT, path);
    assertNotNull(externalStorageLocation);
    assertEquals(path, externalStorageLocation.getPath());
    assertNotNull(externalStorageLocation.getUri());
}
Also used : ExternalStorageLocation(com.netflix.conductor.common.run.ExternalStorageLocation) Test(org.junit.Test)

Example 10 with ExternalStorageLocation

use of com.netflix.conductor.common.run.ExternalStorageLocation in project conductor by Netflix.

the class ClientBase method uploadToExternalPayloadStorage.

/**
 * Uses the {@link PayloadStorage} for storing large payloads.
 * Gets the uri for storing the payload from the server and then uploads to this location.
 *
 * @param payloadType  the {@link com.netflix.conductor.common.utils.ExternalPayloadStorage.PayloadType} to be uploaded
 * @param payloadBytes the byte array containing the payload
 * @param payloadSize  the size of the payload
 * @return the path where the payload is stored in external storage
 */
protected String uploadToExternalPayloadStorage(ExternalPayloadStorage.PayloadType payloadType, byte[] payloadBytes, long payloadSize) {
    Preconditions.checkArgument(payloadType.equals(ExternalPayloadStorage.PayloadType.WORKFLOW_INPUT) || payloadType.equals(ExternalPayloadStorage.PayloadType.TASK_OUTPUT), "Payload type must be workflow input or task output");
    ExternalStorageLocation externalStorageLocation = payloadStorage.getLocation(ExternalPayloadStorage.Operation.WRITE, payloadType, "");
    payloadStorage.upload(externalStorageLocation.getUri(), new ByteArrayInputStream(payloadBytes), payloadSize);
    return externalStorageLocation.getPath();
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ExternalStorageLocation(com.netflix.conductor.common.run.ExternalStorageLocation)

Aggregations

ExternalStorageLocation (com.netflix.conductor.common.run.ExternalStorageLocation)10 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ApplicationException (com.netflix.conductor.core.execution.ApplicationException)2 Test (org.junit.Test)2 HttpMethod (com.amazonaws.HttpMethod)1 SdkClientException (com.amazonaws.SdkClientException)1 GeneratePresignedUrlRequest (com.amazonaws.services.s3.model.GeneratePresignedUrlRequest)1 BlobStorageException (com.azure.storage.blob.models.BlobStorageException)1 BlobSasPermission (com.azure.storage.blob.sas.BlobSasPermission)1 BlobServiceSasSignatureValues (com.azure.storage.blob.sas.BlobServiceSasSignatureValues)1 BlockBlobClient (com.azure.storage.blob.specialized.BlockBlobClient)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ConductorClientException (com.netflix.conductor.client.exceptions.ConductorClientException)1 ExternalPayloadStorage (com.netflix.conductor.common.utils.ExternalPayloadStorage)1 JsonMapperProvider (com.netflix.conductor.common.utils.JsonMapperProvider)1 Configuration (com.netflix.conductor.core.config.Configuration)1 TestConfiguration (com.netflix.conductor.core.execution.TestConfiguration)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 URISyntaxException (java.net.URISyntaxException)1