use of com.amazonaws.services.elasticfilesystem.model.CreateFileSystemResult in project cloudbreak by hortonworks.
the class AwsEfsResourceBuilder method build.
@Override
public List<CloudResource> build(AwsContext context, CloudInstance instance, long privateId, AuthenticatedContext auth, Group group, List<CloudResource> buildableResource, CloudStack cloudStack) throws Exception {
LOGGER.debug("Create EFS on provider" + buildableResource.stream().map(CloudResource::getName).collect(Collectors.toList()));
AmazonEfsClient client = getAmazonEfsClient(auth);
Map<String, CloudEfsAttributes> efsSetMap = Collections.synchronizedMap(new HashMap<>());
List<Future<?>> futures = new ArrayList<>();
List<CloudResource> requestedResources = buildableResource.stream().filter(cloudResource -> CommonStatus.REQUESTED.equals(cloudResource.getStatus())).collect(Collectors.toList());
LOGGER.debug("Start creating EFS for stack: '{}' group: '{}'", auth.getCloudContext().getName(), group.getName());
futures.addAll(requestedResources.stream().map(requestedResource -> creatEfsRequest(requestedResource, cloudStack, efsSetMap)).map(request -> intermediateBuilderExecutor.submit(() -> {
CreateFileSystemResult result = client.createFileSystem(request);
CloudEfsAttributes resultAttributes = getResultEfsAttributes(request, result, efsSetMap);
efsSetMap.put(resultAttributes.getName(), resultAttributes);
})).collect(Collectors.toList()));
LOGGER.debug("Waiting for EFS creation requests");
for (Future<?> future : futures) {
future.get();
}
LOGGER.debug("EFS creation requests sent");
return buildableResource.stream().peek(resource -> {
CloudEfsAttributes resultEfsAttributes = efsSetMap.getOrDefault(resource.getName(), null);
if (resultEfsAttributes != null) {
CloudEfsAttributes resourceEfsAttributes = resource.getParameter(CloudResource.ATTRIBUTES, CloudEfsAttributes.class);
resourceEfsAttributes.setFileSystemId(resultEfsAttributes.getFileSystemId());
resourceEfsAttributes.setFileState(resultEfsAttributes.getFileState());
}
}).map(copyResourceWithCreatedStatus()).collect(Collectors.toList());
}
use of com.amazonaws.services.elasticfilesystem.model.CreateFileSystemResult in project cloudbreak by hortonworks.
the class AwsLaunchTest method setupCreateFileSystem.
private void setupCreateFileSystem() {
String fileSystemId = EFS_FILESYSTEM_ID + efsIdIndex;
efsIdIndex++;
CreateFileSystemResult createFileSystemResult = new CreateFileSystemResult().withFileSystemId(fileSystemId).withName(fileSystemId).withLifeCycleState("creating");
when(amazonElasticFileSystemClient.createFileSystem(any())).thenReturn(createFileSystemResult);
when(amazonEfsClient.createFileSystem(any())).thenReturn(createFileSystemResult);
}
Aggregations