Example usage for org.springframework.transaction.annotation Propagation NOT_SUPPORTED

List of usage examples for org.springframework.transaction.annotation Propagation NOT_SUPPORTED

Introduction

In this page you can find the example usage for org.springframework.transaction.annotation Propagation NOT_SUPPORTED.

Prototype

Propagation NOT_SUPPORTED

To view the source code for org.springframework.transaction.annotation Propagation NOT_SUPPORTED.

Click Source Link

Document

Execute non-transactionally, suspend the current transaction if one exists.

Usage

From source file:org.finra.herd.service.impl.Ec2OnDemandPricingUpdateServiceImpl.java

/**
 * {@inheritDoc}/*  ww w  . j  a v a 2 s.c o m*/
 * <p/>
 * This implementation executes non-transactionally, suspends the current transaction if one exists.
 */
@Override
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public List<Ec2OnDemandPricing> getEc2OnDemandPricing(String ec2PricingListUrl) {
    // Create a list of EC2 on-demand pricing entries.
    List<Ec2OnDemandPricing> ec2OnDemandPricingEntries = new ArrayList<>();

    // Get JSON object from the specified URL.
    JSONObject jsonObject = urlHelper.parseJsonObjectFromUrl(ec2PricingListUrl);

    // Get products from the JSON object.
    JSONObject products = jsonHelper.getKeyValue(jsonObject, JSON_KEY_NAME_PRODUCTS, JSONObject.class);

    // Create a set to validate uniqueness of EC2 on-demand pricing keys.
    Set<Ec2OnDemandPricingKey> uniqueEc2OnDemandPricingKeys = new HashSet<>();

    // Process all products.
    for (Object key : products.keySet()) {
        JSONObject current = jsonHelper.getKeyValue(products, key, JSONObject.class);
        String sku = jsonHelper.getKeyValue(current, JSON_KEY_NAME_SKU, String.class);
        JSONObject attributes = jsonHelper.getKeyValue(current, JSON_KEY_NAME_ATTRIBUTES, JSONObject.class);

        Object location = attributes.get(JSON_ATTRIBUTE_NAME_LOCATION);
        Object operatingSystem = attributes.get(JSON_ATTRIBUTE_NAME_OPERATING_SYSTEM);
        Object instanceType = attributes.get(JSON_ATTRIBUTE_NAME_INSTANCE_TYPE);
        Object tenancy = attributes.get(JSON_ATTRIBUTE_NAME_TENANCY);
        Object usageType = attributes.get(JSON_ATTRIBUTE_NAME_USAGE_TYPE);
        Object preInstalledSoftware = attributes.get(JSON_ATTRIBUTE_NAME_PRE_INSTALLED_SOFTWARE);

        // Validate the parameters and create an EC2 on-demand pricing entry.
        Ec2OnDemandPricing ec2OnDemandPricing = createEc2OnDemandPricingEntry(sku, location, operatingSystem,
                instanceType, tenancy, usageType, preInstalledSoftware);

        // Check if this EC2 on-demand pricing entry got created (the relative parameters passed validation checks).
        if (ec2OnDemandPricing != null) {
            // Get the EC2 on-demand pricing key.
            Ec2OnDemandPricingKey ec2OnDemandPricingKey = ec2OnDemandPricing.getEc2OnDemandPricingKey();

            // Validate that this key is unique.
            if (!uniqueEc2OnDemandPricingKeys.add(ec2OnDemandPricingKey)) {
                throw new IllegalArgumentException(String.format(
                        "Found duplicate EC2 on-demand pricing entry for \"%s\" AWS region and \"%s\" EC2 instance type.",
                        ec2OnDemandPricingKey.getRegionName(), ec2OnDemandPricingKey.getInstanceType()));
            }

            // Add this EC2 on-demand pricing entry to the result list.
            ec2OnDemandPricingEntries.add(ec2OnDemandPricing);
        }
    }

    // Continue the processing only when the result list is not empty.
    if (CollectionUtils.isNotEmpty(ec2OnDemandPricingEntries)) {
        // Get terms from the JSON object.
        JSONObject terms = jsonHelper.getKeyValue(jsonObject, JSON_KEY_NAME_TERMS, JSONObject.class);

        // Get on-demand information from the terms.
        JSONObject onDemand = jsonHelper.getKeyValue(terms, JSON_KEY_NAME_ON_DEMAND, JSONObject.class);

        // Populate pricing information.
        for (Ec2OnDemandPricing ec2OnDemandPricing : ec2OnDemandPricingEntries) {
            String sku = ec2OnDemandPricing.getSku();
            JSONObject current = jsonHelper.getKeyValue(onDemand, sku, JSONObject.class);
            JSONObject pricingWrapper = jsonHelper.getKeyValue(current, sku + JSON_SKU_WRAPPER_SUFFIX,
                    JSONObject.class);
            JSONObject priceDimensions = jsonHelper.getKeyValue(pricingWrapper, JSON_KEY_NAME_PRICE_DIMENSIONS,
                    JSONObject.class);
            JSONObject innerPricingWrapper = jsonHelper.getKeyValue(priceDimensions,
                    sku + JSON_SKU_WRAPPER_SUFFIX + JSON_PRICE_DIMENSIONS_WRAPPER_SUFFIX, JSONObject.class);
            JSONObject pricePerUnit = jsonHelper.getKeyValue(innerPricingWrapper, JSON_KEY_NAME_PRICE_PER_UNIT,
                    JSONObject.class);
            String pricePerUnitValue = jsonHelper.getKeyValue(pricePerUnit, JSON_PRICE_PER_UNIT_WRAPPER,
                    String.class);

            try {
                ec2OnDemandPricing.setPricePerHour(new BigDecimal(pricePerUnitValue));
            } catch (NumberFormatException e) {
                throw new IllegalArgumentException(String.format("Failed to convert \"%s\" value to %s.",
                        pricePerUnitValue, BigDecimal.class.getName()), e);
            }
        }
    }

    return ec2OnDemandPricingEntries;
}

From source file:org.finra.herd.service.impl.EmrServiceImpl.java

/**
 * {@inheritDoc}/* w w w .  ja  v a 2s  .  c om*/
 * <p/>
 * This implementation starts a new transaction.
 */
@NamespacePermission(fields = "#request?.namespace", permissions = NamespacePermissionEnum.EXECUTE)
@Override
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public EmrCluster createCluster(EmrClusterCreateRequest request) throws Exception {
    return createClusterImpl(request);
}

From source file:org.finra.herd.service.impl.JdbcServiceImpl.java

/**
 * This implementation uses a {@link DriverManagerDataSource} and {@link DefaultTransactionDefinition}. It suspends the existing transaction and purposely
 * runs this logic in "no transaction" to ensure we don't create a connection that would potentially become idle while all JDBC tasks execute. If the
 * underlying connection pool has an abandoned connection timeout, it would reclaim and close the connection. Then when all the JDBC tasks below finish,
 * this transaction would try to commit and would generate a "commit failed" exception because the connection is already closed. This approach is fine since
 * we are not actually doing any "herd" DB operations below. When all the below JDBC operations are finished, nothing would happen here except the callers
 * transaction would pick up where it left off which would be needed to write workflow variables, etc.
 *///from   w  w  w. j  a  v  a  2  s  .c  o  m
@Override
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public JdbcExecutionResponse executeJdbc(JdbcExecutionRequest jdbcExecutionRequest) {
    return executeJdbcImpl(jdbcExecutionRequest);
}

From source file:org.finra.herd.service.impl.NotificationMessagePublishingServiceImpl.java

/**
 * {@inheritDoc}//  ww w  . j  av a  2 s  .  c  o  m
 * <p/>
 * This implementation executes non-transactionally, suspends the current transaction if one exists.
 */
@Override
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public void publishNotificationMessage(NotificationMessage notificationMessage) {
    publishNotificationMessageImpl(notificationMessage);
}

From source file:org.finra.herd.service.impl.RelationalTableRegistrationHelperServiceImpl.java

@Override
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public List<SchemaColumn> retrieveRelationalTableColumns(
        RelationalStorageAttributesDto relationalStorageAttributesDto, String relationalSchemaName,
        String relationalTableName) {
    return retrieveRelationalTableColumnsImpl(relationalStorageAttributesDto, relationalSchemaName,
            relationalTableName);/*  w  w w. jav  a 2 s. c om*/
}

From source file:org.finra.herd.service.impl.RelationalTableRegistrationHelperServiceImpl.java

@Override
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public void validateAndTrimRelationalTableRegistrationCreateRequest(
        RelationalTableRegistrationCreateRequest relationalTableRegistrationCreateRequest) {
    validateAndTrimRelationalTableRegistrationCreateRequestImpl(relationalTableRegistrationCreateRequest);
}

From source file:org.finra.herd.service.impl.RelationalTableRegistrationServiceImpl.java

@PublishNotificationMessages
@NamespacePermission(fields = "#relationalTableRegistrationCreateRequest.namespace", permissions = NamespacePermissionEnum.WRITE)
@Override/* w w w  .  j a  va  2 s.  c o m*/
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public BusinessObjectData createRelationalTableRegistration(
        RelationalTableRegistrationCreateRequest relationalTableRegistrationCreateRequest,
        Boolean appendToExistingBusinessObjectDefinition) {
    return createRelationalTableRegistrationImpl(relationalTableRegistrationCreateRequest,
            appendToExistingBusinessObjectDefinition);
}

From source file:org.finra.herd.service.impl.RelationalTableRegistrationServiceImpl.java

@PublishNotificationMessages
@Override//w  w w  .jav a2 s  .co m
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public BusinessObjectData processRelationalTableRegistrationForSchemaUpdate(
        BusinessObjectDataStorageUnitKey storageUnitKey) {
    return processRelationalTableRegistrationForSchemaUpdateImpl(storageUnitKey);
}

From source file:org.finra.herd.service.impl.StoragePolicyProcessorHelperServiceImpl.java

@Override
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public void executeStoragePolicyTransition(StoragePolicyTransitionParamsDto storagePolicyTransitionParamsDto) {
    executeStoragePolicyTransitionImpl(storagePolicyTransitionParamsDto);
}

From source file:org.finra.herd.service.impl.UploadDownloadHelperServiceImpl.java

@Override
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public void performFileMove(CompleteUploadSingleParamsDto completeUploadSingleParamsDto) {
    performFileMoveImpl(completeUploadSingleParamsDto);
}