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