use of org.finra.herd.model.dto.AwsParamsDto in project herd by FINRAOS.
the class UploadDownloadHelperServiceImpl method assertS3ObjectKeyDoesNotExist.
@Override
public void assertS3ObjectKeyDoesNotExist(String bucketName, String key) {
S3FileTransferRequestParamsDto s3FileTransferRequestParamsDto = new S3FileTransferRequestParamsDto();
s3FileTransferRequestParamsDto.setS3BucketName(bucketName);
s3FileTransferRequestParamsDto.setS3KeyPrefix(key);
AwsParamsDto awsParamsDto = awsHelper.getAwsParamsDto();
String httpProxyHost = awsParamsDto.getHttpProxyHost();
s3FileTransferRequestParamsDto.setHttpProxyHost(httpProxyHost);
Integer httpProxyPort = awsParamsDto.getHttpProxyPort();
s3FileTransferRequestParamsDto.setHttpProxyPort(httpProxyPort);
Assert.isTrue(!s3Dao.s3FileExists(s3FileTransferRequestParamsDto), String.format("A S3 object already exists in bucket \"%s\" and key \"%s\".", bucketName, key));
}
use of org.finra.herd.model.dto.AwsParamsDto in project herd by FINRAOS.
the class EmrServiceImpl method terminateClusterImpl.
/**
* Terminates the EMR Cluster.
*
* @param emrClusterAlternateKeyDto the EMR cluster alternate key
* @param overrideTerminationProtection parameter for whether to override termination protection
* @param emrClusterId The EMR cluster ID
* @param accountId The account Id
*
* @return the terminated EMR cluster object
* @throws Exception if there were any errors while terminating the cluster
*/
protected EmrCluster terminateClusterImpl(EmrClusterAlternateKeyDto emrClusterAlternateKeyDto, boolean overrideTerminationProtection, String emrClusterId, String accountId) throws Exception {
AwsParamsDto awsParamsDto = emrHelper.getAwsParamsDtoByAcccountId(accountId);
// Perform the request validation.
validateEmrClusterKey(emrClusterAlternateKeyDto);
// Get the namespace and ensure it exists.
NamespaceEntity namespaceEntity = namespaceDaoHelper.getNamespaceEntity(emrClusterAlternateKeyDto.getNamespace());
// Get the EMR cluster definition and ensure it exists.
EmrClusterDefinitionEntity emrClusterDefinitionEntity = emrClusterDefinitionDaoHelper.getEmrClusterDefinitionEntity(emrClusterAlternateKeyDto.getNamespace(), emrClusterAlternateKeyDto.getEmrClusterDefinitionName());
String clusterId = null;
String clusterName = emrHelper.buildEmrClusterName(namespaceEntity.getCode(), emrClusterDefinitionEntity.getName(), emrClusterAlternateKeyDto.getEmrClusterName());
try {
clusterId = emrHelper.getActiveEmrClusterId(emrClusterId, clusterName, accountId);
emrDao.terminateEmrCluster(clusterId, overrideTerminationProtection, awsParamsDto);
} catch (AmazonServiceException ex) {
handleAmazonException(ex, "An Amazon exception occurred while terminating EMR cluster with name \"" + clusterName + "\".");
}
return createEmrClusterFromRequest(clusterId, namespaceEntity.getCode(), emrClusterDefinitionEntity.getName(), emrClusterAlternateKeyDto.getEmrClusterName(), accountId, emrDao.getEmrClusterStatusById(clusterId, awsParamsDto), null, null, null);
}
use of org.finra.herd.model.dto.AwsParamsDto in project herd by FINRAOS.
the class EmrDaoTest method getEmrMasterInstanceThrowsWhenNoInstance.
@Test
public void getEmrMasterInstanceThrowsWhenNoInstance() throws Exception {
String clusterId = "clusterId";
when(mockEmrOperations.listClusterInstancesRequest(any(), any())).thenReturn(new ListInstancesResult());
try {
emrDao.getEmrMasterInstance(clusterId, new AwsParamsDto());
fail();
} catch (Exception e) {
assertEquals(IllegalArgumentException.class, e.getClass());
assertEquals("No master instances found for the cluster \"" + clusterId + "\".", e.getMessage());
}
}
use of org.finra.herd.model.dto.AwsParamsDto in project herd by FINRAOS.
the class EmrDaoTest method addEmrMasterSecurityGroupsThrowWhenNoInstancesFound.
@Test
public void addEmrMasterSecurityGroupsThrowWhenNoInstancesFound() throws Exception {
String clusterName = "clusterName";
List<String> securityGroups = Arrays.asList("securityGroup");
AwsParamsDto awsParams = new AwsParamsDto();
ListClustersResult listClustersResult = new ListClustersResult();
listClustersResult.setClusters(new ArrayList<>());
ClusterSummary clusterSummary = new ClusterSummary();
clusterSummary.setId("clusterId");
clusterSummary.setName(clusterName);
listClustersResult.getClusters().add(clusterSummary);
when(mockEmrOperations.listEmrClusters(any(), any())).thenReturn(listClustersResult);
when(mockEmrOperations.listClusterInstancesRequest(any(), any())).thenReturn(new ListInstancesResult());
try {
emrDao.addEmrMasterSecurityGroups(clusterName, securityGroups, awsParams);
fail();
} catch (Exception e) {
assertEquals(IllegalArgumentException.class, e.getClass());
assertEquals("No master instances found for the cluster \"" + clusterName + "\".", e.getMessage());
}
}
use of org.finra.herd.model.dto.AwsParamsDto in project herd by FINRAOS.
the class EmrDaoTest method getClusterActiveStepAssertReturnNullWhenStepListIsEmpty.
@Test
public void getClusterActiveStepAssertReturnNullWhenStepListIsEmpty() throws Exception {
String clusterId = "clusterId";
when(mockEmrOperations.listStepsRequest(any(), any())).thenReturn(new ListStepsResult());
assertNull(emrDao.getClusterActiveStep(clusterId, new AwsParamsDto()));
}
Aggregations