Transaction handling refactoring (#771)

* unified new transaction handling in jpa repositories, extended Deployment Management and Action Repository

Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch-si.com>

* moved Deployment Helper to utilities package

Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch-si.com>

* removed superfluous utility method from Deployment Helper

Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch-si.com>

* refactored distribution set to target assignment, fixed PR review findings

Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch-si.com>

* fixed PR review findings

Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch-si.com>

* added additional validation of active flag and current status fields for action status update repository method

Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch-si.com>

* fixed timing issue in amqp message handler integration test, when validating target attributes update

Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch-si.com>
This commit is contained in:
Bondar Bogdan
2018-12-14 17:41:38 +01:00
committed by Dominic Schabel
parent b06928d089
commit a2c1e5f132
11 changed files with 277 additions and 201 deletions

View File

@@ -27,10 +27,6 @@ import org.springframework.integration.support.locks.LockRegistry;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import org.springframework.transaction.support.TransactionCallback;
import org.springframework.transaction.support.TransactionTemplate;
import org.springframework.util.concurrent.ListenableFuture;
/**
@@ -65,8 +61,8 @@ public abstract class AbstractRolloutManagement implements RolloutManagement {
final DeploymentManagement deploymentManagement, final RolloutGroupManagement rolloutGroupManagement,
final DistributionSetManagement distributionSetManagement, final ApplicationContext context,
final ApplicationEventPublisher eventPublisher, final VirtualPropertyReplacer virtualPropertyReplacer,
final PlatformTransactionManager txManager, final TenantAware tenantAware,
final LockRegistry lockRegistry, final RolloutApprovalStrategy rolloutApprovalStrategy) {
final PlatformTransactionManager txManager, final TenantAware tenantAware, final LockRegistry lockRegistry,
final RolloutApprovalStrategy rolloutApprovalStrategy) {
this.targetManagement = targetManagement;
this.deploymentManagement = deploymentManagement;
this.rolloutGroupManagement = rolloutGroupManagement;
@@ -80,14 +76,6 @@ public abstract class AbstractRolloutManagement implements RolloutManagement {
this.rolloutApprovalStrategy = rolloutApprovalStrategy;
}
protected Long runInNewTransaction(final String transactionName, final TransactionCallback<Long> action) {
final DefaultTransactionDefinition def = new DefaultTransactionDefinition();
def.setName(transactionName);
def.setReadOnly(false);
def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
return new TransactionTemplate(txManager, def).execute(action);
}
protected RolloutGroupsValidation validateTargetsInGroups(final List<RolloutGroup> groups, final String baseFilter,
final long totalTargets) {
final List<Long> groupTargetCounts = new ArrayList<>(groups.size());