use of org.apache.heron.spi.uploader.UploaderException in project heron by twitter.
the class SubmitterMainTest method testSubmitTopologyUploaderException.
@Test(expected = UploaderException.class)
public void testSubmitTopologyUploaderException() throws Exception {
SubmitterMain submitterMain = spy(new SubmitterMain(config, topology));
doNothing().when(submitterMain).validateSubmit(any(SchedulerStateManagerAdaptor.class), anyString());
doThrow(new UploaderException("")).when(submitterMain).uploadPackage(eq(uploader));
try {
submitterMain.submitTopology();
} finally {
verify(uploader, never()).undo();
verify(uploader).close();
verify(launcher).close();
verify(statemgr).close();
}
}
use of org.apache.heron.spi.uploader.UploaderException in project heron by twitter.
the class S3Uploader method uploadPackage.
@Override
public URI uploadPackage() throws UploaderException {
// Backup any existing files incase we need to undo this action
if (s3Client.doesObjectExist(bucket, remoteFilePath)) {
s3Client.copyObject(bucket, remoteFilePath, bucket, previousVersionFilePath);
}
// Attempt to write the topology package to s3
try {
s3Client.putObject(bucket, remoteFilePath, packageFileHandler);
} catch (SdkClientException e) {
throw new UploaderException(String.format("Error writing topology package to %s %s", bucket, remoteFilePath), e);
}
// Ask s3 for the url to the topology package we just uploaded
final URL resourceUrl = s3Client.getUrl(bucket, remoteFilePath);
LOG.log(Level.INFO, "Package URL: {0}", resourceUrl);
// This will happen if the package does not actually exist in the place where we uploaded it to.
if (resourceUrl == null) {
throw new UploaderException(String.format("Resource not found for bucket %s and path %s", bucket, remoteFilePath));
}
try {
return resourceUrl.toURI();
} catch (URISyntaxException e) {
throw new UploaderException(String.format("Could not convert URL %s to URI", resourceUrl), e);
}
}
Aggregations