Search in sources :

Example 6 with SmartSenseSubscription

use of com.sequenceiq.cloudbreak.domain.SmartSenseSubscription in project cloudbreak by hortonworks.

the class SmartSenseSubscriptionController method createSmartSenseSubscription.

private SmartSenseSubscriptionJson createSmartSenseSubscription(SmartSenseSubscriptionJson json, boolean publicInAccount) {
    IdentityUser identityUser = authenticatedUserService.getCbUser();
    SmartSenseSubscription subscription = toSmartSenseSubscriptionConverter.convert(json);
    subscription.setAccount(identityUser.getAccount());
    subscription.setOwner(identityUser.getUserId());
    subscription.setPublicInAccount(publicInAccount);
    subscription = smartSenseSubService.create(subscription);
    return toJsonConverter.convert(subscription);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) SmartSenseSubscription(com.sequenceiq.cloudbreak.domain.SmartSenseSubscription)

Example 7 with SmartSenseSubscription

use of com.sequenceiq.cloudbreak.domain.SmartSenseSubscription in project cloudbreak by hortonworks.

the class StackToBlueprintPreparationObjectConverter method convert.

@Override
public BlueprintPreparationObject convert(Stack source) {
    try {
        Optional<SmartSenseSubscription> aDefault = smartSenseSubscriptionService.getDefault();
        Cluster cluster = clusterService.getById(source.getCluster().getId());
        FileSystem fileSystem = cluster.getFileSystem();
        LdapConfig ldapConfig = cluster.getLdapConfig();
        StackRepoDetails hdpRepo = clusterComponentConfigProvider.getHDPRepo(cluster.getId());
        String stackRepoDetailsHdpVersion = hdpRepo != null ? hdpRepo.getHdpVersion() : null;
        Map<String, List<InstanceMetaData>> groupInstances = instanceGroupMetadataCollector.collectMetadata(source);
        HdfConfigs hdfConfigs = hdfConfigProvider.createHdfConfig(cluster.getHostGroups(), groupInstances, cluster.getBlueprint().getBlueprintText());
        BlueprintStackInfo blueprintStackInfo = stackInfoService.blueprintStackInfo(cluster.getBlueprint().getBlueprintText());
        FileSystemConfigurationView fileSystemConfigurationView = null;
        if (source.getCluster().getFileSystem() != null) {
            fileSystemConfigurationView = new FileSystemConfigurationView(fileSystemConfigurationProvider.fileSystemConfiguration(fileSystem, source), fileSystem == null ? false : fileSystem.isDefaultFs());
        }
        IdentityUser identityUser = userDetailsService.getDetails(cluster.getOwner(), UserFilterField.USERID);
        return BlueprintPreparationObject.Builder.builder().withFlexSubscription(source.getFlexSubscription()).withRdsConfigs(postgresConfigService.createRdsConfigIfNeeded(source, cluster)).withHostgroups(hostGroupService.getByCluster(cluster.getId())).withGateway(cluster.getGateway()).withBlueprintView(new BlueprintView(cluster, blueprintStackInfo)).withStackRepoDetailsHdpVersion(stackRepoDetailsHdpVersion).withFileSystemConfigurationView(fileSystemConfigurationView).withGeneralClusterConfigs(generalClusterConfigsProvider.generalClusterConfigs(source, cluster, identityUser)).withSmartSenseSubscriptionId(aDefault.isPresent() ? aDefault.get().getSubscriptionId() : null).withLdapConfig(ldapConfig).withHdfConfigs(hdfConfigs).withKerberosConfig(cluster.isSecure() ? cluster.getKerberosConfig() : null).build();
    } catch (BlueprintProcessingException e) {
        throw new CloudbreakServiceException(e.getMessage(), e);
    } catch (IOException e) {
        throw new CloudbreakServiceException(e.getMessage(), e);
    }
}
Also used : BlueprintProcessingException(com.sequenceiq.cloudbreak.blueprint.BlueprintProcessingException) StackRepoDetails(com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails) HdfConfigs(com.sequenceiq.cloudbreak.blueprint.nifi.HdfConfigs) SmartSenseSubscription(com.sequenceiq.cloudbreak.domain.SmartSenseSubscription) BlueprintView(com.sequenceiq.cloudbreak.blueprint.template.views.BlueprintView) CloudbreakServiceException(com.sequenceiq.cloudbreak.service.CloudbreakServiceException) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) IOException(java.io.IOException) LdapConfig(com.sequenceiq.cloudbreak.domain.LdapConfig) IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) BlueprintStackInfo(com.sequenceiq.cloudbreak.blueprint.templates.BlueprintStackInfo) FileSystem(com.sequenceiq.cloudbreak.domain.FileSystem) FileSystemConfigurationView(com.sequenceiq.cloudbreak.blueprint.template.views.FileSystemConfigurationView) List(java.util.List)

Example 8 with SmartSenseSubscription

use of com.sequenceiq.cloudbreak.domain.SmartSenseSubscription in project cloudbreak by hortonworks.

the class SmartSenseSubscriptionService method delete.

public void delete(String subscriptionId, IdentityUser cbUser) {
    SmartSenseSubscription subscription = repository.findBySubscriptionIdAndAccount(subscriptionId, cbUser.getAccount());
    delete(subscription);
}
Also used : SmartSenseSubscription(com.sequenceiq.cloudbreak.domain.SmartSenseSubscription)

Example 9 with SmartSenseSubscription

use of com.sequenceiq.cloudbreak.domain.SmartSenseSubscription in project cloudbreak by hortonworks.

the class SmartSenseSubscriptionService method delete.

public void delete(Long id) {
    SmartSenseSubscription subscription = repository.findOneById(id);
    delete(subscription);
}
Also used : SmartSenseSubscription(com.sequenceiq.cloudbreak.domain.SmartSenseSubscription)

Example 10 with SmartSenseSubscription

use of com.sequenceiq.cloudbreak.domain.SmartSenseSubscription in project cloudbreak by hortonworks.

the class AmbariSmartSenseCapturerTest method testCaptureWhenNoTriggerNeedsToBeDone.

@Test
public void testCaptureWhenNoTriggerNeedsToBeDone() {
    Optional<SmartSenseSubscription> smartSenseSubscription = Optional.empty();
    AmbariClient ambariClient = Mockito.mock(AmbariClient.class);
    when(smartSenseSubscriptionService.getDefault()).thenReturn(smartSenseSubscription);
    when(smartsenseConfigurationLocator.smartsenseConfigurable(smartSenseSubscription)).thenReturn(false);
    underTest.capture(1, ambariClient);
    verify(ambariClient, times(0)).smartSenseCapture(anyInt());
}
Also used : SmartSenseSubscription(com.sequenceiq.cloudbreak.domain.SmartSenseSubscription) AmbariClient(com.sequenceiq.ambari.client.AmbariClient) Test(org.junit.Test)

Aggregations

SmartSenseSubscription (com.sequenceiq.cloudbreak.domain.SmartSenseSubscription)24 Test (org.junit.Test)10 AmbariClient (com.sequenceiq.ambari.client.AmbariClient)3 IdentityUser (com.sequenceiq.cloudbreak.common.model.user.IdentityUser)3 SmartSenseSubscriptionJson (com.sequenceiq.cloudbreak.api.model.SmartSenseSubscriptionJson)2 FlexSubscription (com.sequenceiq.cloudbreak.domain.FlexSubscription)2 FlexUsageControllerJson (com.sequenceiq.cloudbreak.api.model.flex.FlexUsageControllerJson)1 BlueprintProcessingException (com.sequenceiq.cloudbreak.blueprint.BlueprintProcessingException)1 HdfConfigs (com.sequenceiq.cloudbreak.blueprint.nifi.HdfConfigs)1 BlueprintView (com.sequenceiq.cloudbreak.blueprint.template.views.BlueprintView)1 FileSystemConfigurationView (com.sequenceiq.cloudbreak.blueprint.template.views.FileSystemConfigurationView)1 BlueprintStackInfo (com.sequenceiq.cloudbreak.blueprint.templates.BlueprintStackInfo)1 StackRepoDetails (com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails)1 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)1 NotFoundException (com.sequenceiq.cloudbreak.controller.NotFoundException)1 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)1 FileSystem (com.sequenceiq.cloudbreak.domain.FileSystem)1 LdapConfig (com.sequenceiq.cloudbreak.domain.LdapConfig)1 CloudbreakServiceException (com.sequenceiq.cloudbreak.service.CloudbreakServiceException)1 IOException (java.io.IOException)1