use of com.amazonaws.services.elasticmapreduce.model.ListClustersResult in project iep by Netflix.
the class PaginationTest method emr.
@Test
public void emr() throws Exception {
SortedSet<String> pages = newPageSet(5);
final Iterator<String> reqIt = pages.iterator();
final Iterator<String> resIt = pages.iterator();
Function<ListClustersRequest, ListClustersResult> f = r -> {
if (r.getMarker() != null) {
Assert.assertEquals(reqIt.next(), r.getMarker());
}
return new ListClustersResult().withMarker(resIt.hasNext() ? resIt.next() : null);
};
Publisher<ListClustersResult> publisher = Pagination.createPublisher(new ListClustersRequest(), f);
Iterable<String> iter = Flowable.fromPublisher(publisher).filter(r -> r.getMarker() != null).map(ListClustersResult::getMarker).blockingIterable();
SortedSet<String> results = new TreeSet<>();
for (String s : iter) {
results.add(s);
}
Assert.assertEquals(pages, results);
Assert.assertFalse(reqIt.hasNext());
}
use of com.amazonaws.services.elasticmapreduce.model.ListClustersResult in project herd by FINRAOS.
the class MockEmrOperationsImpl method listEmrClusters.
@Override
public ListClustersResult listEmrClusters(AmazonElasticMapReduceClient emrClient, ListClustersRequest listClustersRequest) {
List<ClusterSummary> clusterSummaryList = new ArrayList<>();
for (MockEmrJobFlow cluster : emrClusters.values()) {
if (!listClustersRequest.getClusterStates().isEmpty() && listClustersRequest.getClusterStates().contains(cluster.getStatus())) {
ClusterSummary clusterSummary = new ClusterSummary();
clusterSummary.withId(cluster.getJobFlowId()).withName(cluster.getJobFlowName()).withStatus(new ClusterStatus().withState(cluster.getStatus()).withStateChangeReason(new ClusterStateChangeReason().withCode(cluster.getStatusChangeReason().getCode()).withMessage(cluster.getStatusChangeReason().getMessage())).withTimeline(new ClusterTimeline().withCreationDateTime(cluster.getStatusTimeline().getCreationTime() != null ? cluster.getStatusTimeline().getCreationTime().toGregorianCalendar().getTime() : null).withEndDateTime(cluster.getStatusTimeline().getEndTime() != null ? cluster.getStatusTimeline().getEndTime().toGregorianCalendar().getTime() : null).withReadyDateTime(cluster.getStatusTimeline().getReadyTime() != null ? cluster.getStatusTimeline().getReadyTime().toGregorianCalendar().getTime() : null)));
clusterSummaryList.add(clusterSummary);
}
}
if (StringUtils.isBlank(listClustersRequest.getMarker())) {
return new ListClustersResult().withClusters(clusterSummaryList).withMarker(MOCK_EMR_MAKER);
} else {
return new ListClustersResult().withClusters(clusterSummaryList);
}
}
use of com.amazonaws.services.elasticmapreduce.model.ListClustersResult in project herd by FINRAOS.
the class EmrDaoTest method addEmrMasterSecurityGroupsCallsEc2AddSecurityGroup.
@Test
public void addEmrMasterSecurityGroupsCallsEc2AddSecurityGroup() throws Exception {
String clusterName = "clusterName";
List<String> securityGroups = Arrays.asList("securityGroup");
AwsParamsDto awsParams = new AwsParamsDto();
String ec2InstanceId = "ec2InstanceId";
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);
ListInstancesResult listInstancesResult = new ListInstancesResult();
listInstancesResult.setInstances(new ArrayList<>());
Instance instance = new Instance();
instance.setEc2InstanceId(ec2InstanceId);
listInstancesResult.getInstances().add(instance);
when(mockEmrOperations.listClusterInstancesRequest(any(), any())).thenReturn(listInstancesResult);
emrDao.addEmrMasterSecurityGroups(clusterName, securityGroups, awsParams);
verify(mockEc2Dao).addSecurityGroupsToEc2Instance(eq(ec2InstanceId), eq(securityGroups), any());
verifyNoMoreInteractions(mockEc2Dao);
}
use of com.amazonaws.services.elasticmapreduce.model.ListClustersResult in project herd by FINRAOS.
the class EmrDaoTest method getActiveEmrClusterByNameAssertReturnNullWhenClusterNameIsBlank.
@Test
public void getActiveEmrClusterByNameAssertReturnNullWhenClusterNameIsBlank() throws Exception {
String clusterName = "";
when(mockEmrOperations.listEmrClusters(any(), any())).thenReturn(new ListClustersResult());
assertNull(emrDao.getActiveEmrClusterByName(clusterName, new AwsParamsDto()));
}
use of com.amazonaws.services.elasticmapreduce.model.ListClustersResult in project herd by FINRAOS.
the class EmrDaoTest method getActiveEmrClusterByNameAssertOnlyReturnClusterWithMatchingName.
@Test
public void getActiveEmrClusterByNameAssertOnlyReturnClusterWithMatchingName() throws Exception {
String clusterName = "clusterName";
String expectedClusterId = "clusterId3";
ListClustersResult listClustersResult = new ListClustersResult();
listClustersResult.setClusters(new ArrayList<>());
{
ClusterSummary clusterSummary = new ClusterSummary();
clusterSummary.setId("clusterId1");
clusterSummary.setName("not_matching");
listClustersResult.getClusters().add(clusterSummary);
}
{
ClusterSummary clusterSummary = new ClusterSummary();
clusterSummary.setId("clusterId2");
clusterSummary.setName("");
listClustersResult.getClusters().add(clusterSummary);
}
{
ClusterSummary clusterSummary = new ClusterSummary();
clusterSummary.setId(expectedClusterId);
clusterSummary.setName(clusterName);
listClustersResult.getClusters().add(clusterSummary);
}
when(mockEmrOperations.listEmrClusters(any(), any())).thenReturn(listClustersResult);
ClusterSummary result = emrDao.getActiveEmrClusterByName(clusterName, new AwsParamsDto());
assertNotNull(result);
assertEquals(expectedClusterId, result.getId());
}
Aggregations