use of com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformNoSqlTablesRequest in project cloudbreak by hortonworks.
the class GetPlatformNoSqlTablesHandler method accept.
@Override
public void accept(Event<GetPlatformNoSqlTablesRequest> event) {
LOGGER.debug("Received event: {}", event);
GetPlatformNoSqlTablesRequest request = event.getData();
try {
CloudPlatformVariant cloudPlatformVariant = new CloudPlatformVariant(Platform.platform(request.getExtendedCloudCredential().getCloudPlatform()), Variant.variant(request.getVariant()));
CloudNoSqlTables cloudNoSqlTables = cloudPlatformConnectors.get(cloudPlatformVariant).platformResources().noSqlTables(request.getExtendedCloudCredential(), Region.region(request.getRegion()), request.getFilters());
GetPlatformNoSqlTablesResult result = new GetPlatformNoSqlTablesResult(request.getResourceId(), cloudNoSqlTables);
request.getResult().onNext(result);
LOGGER.debug("Query platform NoSQL tables finished.");
} catch (RuntimeException e) {
request.getResult().onNext(new GetPlatformNoSqlTablesResult(e.getMessage(), e, request.getResourceId()));
}
}
use of com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformNoSqlTablesRequest in project cloudbreak by hortonworks.
the class CloudParameterServiceTest method getNoSqlTables.
@Test
void getNoSqlTables() {
CloudNoSqlTables expected = new CloudNoSqlTables(List.of(new CloudNoSqlTable("a"), new CloudNoSqlTable("b")));
GetPlatformNoSqlTablesResult response = new GetPlatformNoSqlTablesResult(1L, expected);
doAnswer(invocation -> {
Event<GetPlatformNoSqlTablesRequest> ev = invocation.getArgument(1);
ev.getData().getResult().onNext(response);
return null;
}).when(eventBus).notify(anyString(), any(Event.class));
CloudNoSqlTables noSqlTables = underTest.getNoSqlTables(new ExtendedCloudCredential(new CloudCredential("id", "name", "acc"), "aws", "desc", "crn", "account", new ArrayList<>()), "region", "aws", null);
assertEquals(expected, noSqlTables);
}
use of com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformNoSqlTablesRequest in project cloudbreak by hortonworks.
the class CloudParameterService method getNoSqlTables.
@Retryable(value = GetCloudParameterException.class, maxAttempts = 5, backoff = @Backoff(delay = 1000, multiplier = 2, maxDelay = 10000))
public CloudNoSqlTables getNoSqlTables(ExtendedCloudCredential cloudCredential, String region, String platformVariant, Map<String, String> filters) {
LOGGER.debug("Get platform noSqlTables");
GetPlatformNoSqlTablesRequest request = new GetPlatformNoSqlTablesRequest(cloudCredential, cloudCredential, platformVariant, region, null);
eventBus.notify(request.selector(), Event.wrap(request));
try {
GetPlatformNoSqlTablesResult result = request.await();
LOGGER.debug("Platform NoSqlTablesResult result: {}", result);
if (result.getStatus().equals(EventStatus.FAILED)) {
LOGGER.debug("Failed to get platform NoSqlTablesResult", result.getErrorDetails());
throw new GetCloudParameterException(String.format("Failed to get NoSQL tables for the cloud provider: %s. %s", result.getStatusReason(), getCauseMessages(result.getErrorDetails())), result.getErrorDetails());
}
return result.getNoSqlTables();
} catch (InterruptedException e) {
LOGGER.error("Error while getting the platform NoSqlTablesResult", e);
throw new OperationException(e);
}
}
use of com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformNoSqlTablesRequest in project cloudbreak by hortonworks.
the class GetPlatformNoSqlTablesHandlerTest method accept.
@Test
void accept() {
when(cloudPlatformConnectors.get(any(CloudPlatformVariant.class))).thenReturn(cloudConnector);
when(cloudConnector.platformResources()).thenReturn(platformResources);
CloudCredential cloudCredential = new CloudCredential("id", "name", "acc");
ExtendedCloudCredential extendedCloudCredential = new ExtendedCloudCredential(cloudCredential, "aws", "desc", "crn", "account", new ArrayList<>());
GetPlatformNoSqlTablesRequest request = spy(new GetPlatformNoSqlTablesRequest(cloudCredential, extendedCloudCredential, "aws", "region", null));
underTest.accept(new Event<>(request));
verify(platformResources).noSqlTables(eq(extendedCloudCredential), eq(Region.region("region")), isNull());
verify(request).getResult();
}
Aggregations