Search in sources :

Example 1 with Json

use of com.sequenceiq.cloudbreak.common.json.Json in project cloudbreak by hortonworks.

the class UserSyncService method asyncSynchronizeStack.

private Future<SyncStatusDetail> asyncSynchronizeStack(Stack stack, UmsUsersState umsUsersState, UmsEventGenerationIds umsEventGenerationIds, UserSyncOptions options, String operationId, String accountId) {
    return asyncTaskExecutor.submit(() -> {
        SyncStatusDetail statusDetail = internalSynchronizeStack(stack, umsUsersState, options);
        if (options.isFullSync() && statusDetail.getStatus() == SynchronizationStatus.COMPLETED) {
            UserSyncStatus userSyncStatus = userSyncStatusService.getOrCreateForStack(stack);
            userSyncStatus.setUmsEventGenerationIds(new Json(umsEventGenerationIds));
            userSyncStatus.setLastSuccessfulFullSync(operationService.getOperationForAccountIdAndOperationId(accountId, operationId));
            userSyncStatusService.save(userSyncStatus);
        }
        return statusDetail;
    });
}
Also used : SyncStatusDetail(com.sequenceiq.freeipa.service.freeipa.user.model.SyncStatusDetail) UserSyncStatus(com.sequenceiq.freeipa.entity.UserSyncStatus) Json(com.sequenceiq.cloudbreak.common.json.Json)

Example 2 with Json

use of com.sequenceiq.cloudbreak.common.json.Json in project cloudbreak by hortonworks.

the class UserSyncStatusService method getOrCreateForStack.

public UserSyncStatus getOrCreateForStack(Stack stack) {
    return userSyncStatusRepository.getByStack(stack).orElseGet(() -> {
        UserSyncStatus userSyncStatus = new UserSyncStatus();
        userSyncStatus.setStack(stack);
        userSyncStatus.setUmsEventGenerationIds(new Json(new UmsEventGenerationIds()));
        return userSyncStatusRepository.save(userSyncStatus);
    });
}
Also used : UmsEventGenerationIds(com.sequenceiq.freeipa.service.freeipa.user.model.UmsEventGenerationIds) UserSyncStatus(com.sequenceiq.freeipa.entity.UserSyncStatus) Json(com.sequenceiq.cloudbreak.common.json.Json)

Example 3 with Json

use of com.sequenceiq.cloudbreak.common.json.Json in project cloudbreak by hortonworks.

the class SshJClientActions method checkNoEphemeralDisksMounted.

public void checkNoEphemeralDisksMounted(List<InstanceGroupV4Response> instanceGroups, List<String> hostGroupNames) {
    Map<String, Pair<Integer, String>> deviceMountPointMappingsByIp = getDeviceMountPointMappingsByIp(instanceGroups, hostGroupNames);
    Map<String, Pair<Integer, String>> deviceDiskTypeMappingsByIp = getDeviceDiskTypeMappingsByIp(instanceGroups, hostGroupNames);
    for (Entry<String, Pair<Integer, String>> node : deviceDiskTypeMappingsByIp.entrySet()) {
        Map<String, String> ephemeralDisks = new Json(node.getValue().getValue()).getMap().entrySet().stream().filter(e -> String.valueOf(e.getValue()).contains("Amazon EC2 NVMe Instance Storage")).collect(Collectors.toMap(Entry::getKey, x -> String.valueOf(x.getValue())));
        if (!ephemeralDisks.isEmpty()) {
            LOGGER.error("Instance store volume unintentionally present on node with IP {}!", node.getKey());
            throw new TestFailException(String.format("Instance store volume unintentionally present on node with IP %s!", node.getKey()));
        }
    }
    for (Entry<String, Pair<Integer, String>> node : deviceMountPointMappingsByIp.entrySet()) {
        Map<String, String> ephemeralMounts = new Json(node.getValue().getValue()).getMap().entrySet().stream().filter(e -> String.valueOf(e.getValue()).contains("ephfs")).collect(Collectors.toMap(Entry::getKey, x -> String.valueOf(x.getValue())));
        if (!ephemeralMounts.isEmpty()) {
            LOGGER.error("Device incorrectly mounted to /hadoopfs/ephfsN on node with IP {}!", node.getKey());
            throw new TestFailException(String.format("Device incorrectly mounted to /hadoopfs/ephfsN on node with IP %s!", node.getKey()));
        }
    }
}
Also used : FreeIpaTestDto(com.sequenceiq.it.cloudbreak.dto.freeipa.FreeIpaTestDto) SshJClient(com.sequenceiq.it.cloudbreak.util.ssh.client.SshJClient) LoggerFactory(org.slf4j.LoggerFactory) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) InstanceMetaDataV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.instancemetadata.InstanceMetaDataV4Response) Pair(org.apache.commons.lang3.tuple.Pair) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) Map(java.util.Map) FreeIpaClient(com.sequenceiq.it.cloudbreak.FreeIpaClient) SdxTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxTestDto) Logger(org.slf4j.Logger) Collection(java.util.Collection) Log(com.sequenceiq.it.cloudbreak.log.Log) Set(java.util.Set) InstanceGroupV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.InstanceGroupV4Response) InstanceMetaDataResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceMetaDataResponse) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) Objects(java.util.Objects) Json(com.sequenceiq.cloudbreak.common.json.Json) AtomicLong(java.util.concurrent.atomic.AtomicLong) List(java.util.List) Component(org.springframework.stereotype.Component) Stream(java.util.stream.Stream) AbstractSdxTestDto(com.sequenceiq.it.cloudbreak.dto.AbstractSdxTestDto) SSHClient(net.schmizz.sshj.SSHClient) Entry(java.util.Map.Entry) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) Json(com.sequenceiq.cloudbreak.common.json.Json) Pair(org.apache.commons.lang3.tuple.Pair)

Example 4 with Json

use of com.sequenceiq.cloudbreak.common.json.Json in project cloudbreak by hortonworks.

the class ClusterToClusterV4ResponseConverter method convertCustomQueue.

private void convertCustomQueue(Cluster source, ClusterV4Response clusterResponse) {
    if (source.getAttributes() != null) {
        Json fromVault = new Json(source.getAttributes());
        Map<String, Object> attributes = fromVault.getMap();
        Object customQueue = attributes.get(CUSTOM_QUEUE.name());
        if (customQueue != null) {
            clusterResponse.setCustomQueue(customQueue.toString());
        } else {
            clusterResponse.setCustomQueue("default");
        }
    }
}
Also used : Json(com.sequenceiq.cloudbreak.common.json.Json)

Example 5 with Json

use of com.sequenceiq.cloudbreak.common.json.Json in project cloudbreak by hortonworks.

the class ClusterToClusterV4ResponseConverter method convertNullableProperties.

private void convertNullableProperties(Cluster source, ClusterV4Response clusterResponse) {
    if (source.getGateway() != null) {
        GatewayV4Response gatewayV4Response = gatewayToGatewayV4ResponseConverter.convert(source.getGateway());
        clusterResponse.setGateway(gatewayV4Response);
    }
    if (source.getAttributes() != null) {
        Json fromVault = new Json(source.getAttributes());
        clusterResponse.setAttributes(fromVault.getMap());
    }
}
Also used : GatewayV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.GatewayV4Response) Json(com.sequenceiq.cloudbreak.common.json.Json)

Aggregations

Json (com.sequenceiq.cloudbreak.common.json.Json)266 Test (org.junit.jupiter.api.Test)95 HashMap (java.util.HashMap)49 InstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate)31 Template (com.sequenceiq.freeipa.entity.Template)26 AwsInstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.instance.AwsInstanceTemplate)25 List (java.util.List)24 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)24 AzureInstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.instance.AzureInstanceTemplate)23 Map (java.util.Map)22 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)21 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)21 ArrayList (java.util.ArrayList)21 Test (org.junit.Test)21 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)20 IOException (java.io.IOException)20 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)18 RestRequestDetails (com.sequenceiq.cloudbreak.structuredevent.event.rest.RestRequestDetails)16 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)16 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)14