Search in sources :

Example 6 with ClouderaManagerDto

use of com.sequenceiq.mock.clouderamanager.ClouderaManagerDto in project cloudbreak by hortonworks.

the class ClusterResourceOperation method startCommand.

public ResponseEntity<ApiCommand> startCommand(String mockUuid, String clusterName) {
    ClouderaManagerDto read = clouderaManagerStoreService.read(mockUuid);
    Map<String, ApiServiceState> newStates = new HashMap<>();
    read.getServiceStates().forEach((service, apiServiceState) -> newStates.put(service, ApiServiceState.STARTED));
    read.setServiceStates(newStates);
    read.setStatus(ApiServiceState.STARTED);
    return responseCreatorComponent.exec(new ApiCommand().id(CommandId.CLUSTER_START).active(Boolean.TRUE).name("Start"));
}
Also used : ClouderaManagerDto(com.sequenceiq.mock.clouderamanager.ClouderaManagerDto) ApiCommand(com.sequenceiq.mock.swagger.model.ApiCommand) ApiServiceState(com.sequenceiq.mock.swagger.model.ApiServiceState) HashMap(java.util.HashMap)

Example 7 with ClouderaManagerDto

use of com.sequenceiq.mock.clouderamanager.ClouderaManagerDto in project cloudbreak by hortonworks.

the class PgkVersionSaltResponse method run.

@Override
public Object run(String mockUuid, Map<String, List<String>> params) throws Exception {
    List<Map<String, String>> result = new ArrayList<>();
    PackageVersionResponse response = new PackageVersionResponse();
    ClouderaManagerDto cmDto = clouderaManagerStoreService.read(mockUuid);
    List<ApiClusterTemplateHostInfo> hosts = cmDto.getClusterTemplate().getInstantiator().getHosts();
    Map<String, String> pkgVersion = new HashMap<>();
    for (ApiClusterTemplateHostInfo host : hosts) {
        String hostName = host.getHostName();
        pkgVersion.put(hostName, cmDto.getClusterTemplate().getCmVersion());
    }
    result.add(pkgVersion);
    response.setResult(result);
    return response;
}
Also used : PackageVersionResponse(com.sequenceiq.cloudbreak.orchestrator.salt.domain.PackageVersionResponse) ClouderaManagerDto(com.sequenceiq.mock.clouderamanager.ClouderaManagerDto) HashMap(java.util.HashMap) ApiClusterTemplateHostInfo(com.sequenceiq.mock.swagger.model.ApiClusterTemplateHostInfo) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap)

Example 8 with ClouderaManagerDto

use of com.sequenceiq.mock.clouderamanager.ClouderaManagerDto in project cloudbreak by hortonworks.

the class ResponseModifierService method handleProfiles.

public void handleProfiles(String mockUuid, String path) {
    if (mockUuid != null && profileSupported(mockUuid, path) && clouderaManagerStoreService.exists(mockUuid)) {
        ClouderaManagerDto dto = clouderaManagerStoreService.read(mockUuid);
        Optional<CmProfile> http500 = dto.getActiveProfiles().stream().filter(p -> p.getProfile().equals("HTTP_500")).findFirst();
        if (http500.isPresent()) {
            int called = profileCalled.computeIfAbsent(path, key -> 0);
            profileCalled.put(path, called + 1);
            if (called < http500.get().getTimes()) {
                throw new HttpServerErrorException(HttpStatus.INTERNAL_SERVER_ERROR, "HTTP_500 profile set");
            }
        }
    }
}
Also used : Logger(org.slf4j.Logger) CmProfile(com.sequenceiq.mock.clouderamanager.CmProfile) HttpServerErrorException(org.springframework.web.client.HttpServerErrorException) ClouderaManagerStoreService(com.sequenceiq.mock.clouderamanager.ClouderaManagerStoreService) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) LoggerFactory(org.slf4j.LoggerFactory) MockResponse(com.sequenceiq.mock.spi.MockResponse) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) CheckedSupplier(com.sequenceiq.cloudbreak.util.CheckedSupplier) HttpStatus(org.springframework.http.HttpStatus) List(java.util.List) ClouderaManagerDto(com.sequenceiq.mock.clouderamanager.ClouderaManagerDto) Service(org.springframework.stereotype.Service) CollectionUtils(org.springframework.util.CollectionUtils) Gson(com.google.gson.Gson) Map(java.util.Map) Optional(java.util.Optional) ResponseEntity(org.springframework.http.ResponseEntity) ClouderaManagerDto(com.sequenceiq.mock.clouderamanager.ClouderaManagerDto) HttpServerErrorException(org.springframework.web.client.HttpServerErrorException) CmProfile(com.sequenceiq.mock.clouderamanager.CmProfile)

Aggregations

ClouderaManagerDto (com.sequenceiq.mock.clouderamanager.ClouderaManagerDto)8 HashMap (java.util.HashMap)4 ClouderaManagerStoreService (com.sequenceiq.mock.clouderamanager.ClouderaManagerStoreService)2 ApiCommand (com.sequenceiq.mock.swagger.model.ApiCommand)2 ApiExternalUserMapping (com.sequenceiq.mock.swagger.model.ApiExternalUserMapping)2 ApiServiceState (com.sequenceiq.mock.swagger.model.ApiServiceState)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Map (java.util.Map)2 Inject (javax.inject.Inject)2 ResponseEntity (org.springframework.http.ResponseEntity)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 TextNode (com.fasterxml.jackson.databind.node.TextNode)1 Gson (com.google.gson.Gson)1 ApplyResponse (com.sequenceiq.cloudbreak.orchestrator.salt.domain.ApplyResponse)1 PackageVersionResponse (com.sequenceiq.cloudbreak.orchestrator.salt.domain.PackageVersionResponse)1 CheckedSupplier (com.sequenceiq.cloudbreak.util.CheckedSupplier)1 CmProfile (com.sequenceiq.mock.clouderamanager.CmProfile)1 ResponseCreatorComponent (com.sequenceiq.mock.clouderamanager.ResponseCreatorComponent)1 MockResponse (com.sequenceiq.mock.spi.MockResponse)1