Provide option to disable distributed lock (#2350)
by setting hawkbit.lock=inMemory the distributed lock could be disabled, e.g. on DDI/DMF servers Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -63,6 +63,7 @@ spring.flyway.enabled=false
|
|||||||
## No Schedulers - START
|
## No Schedulers - START
|
||||||
hawkbit.autoassign.scheduler.enabled=false
|
hawkbit.autoassign.scheduler.enabled=false
|
||||||
hawkbit.rollout.scheduler.enabled=false
|
hawkbit.rollout.scheduler.enabled=false
|
||||||
|
hawkbit.lock=inMemory
|
||||||
## No Schedulers - END
|
## No Schedulers - END
|
||||||
|
|
||||||
# Disable discovery client of spring-cloud-commons
|
# Disable discovery client of spring-cloud-commons
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ spring.flyway.enabled=false
|
|||||||
## No Schedulers - START
|
## No Schedulers - START
|
||||||
hawkbit.autoassign.scheduler.enabled=false
|
hawkbit.autoassign.scheduler.enabled=false
|
||||||
hawkbit.rollout.scheduler.enabled=false
|
hawkbit.rollout.scheduler.enabled=false
|
||||||
|
hawkbit.lock=inMemory
|
||||||
## No Schedulers - END
|
## No Schedulers - END
|
||||||
|
|
||||||
# Disable discovery client of spring-cloud-commons
|
# Disable discovery client of spring-cloud-commons
|
||||||
|
|||||||
@@ -194,6 +194,7 @@ import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
|||||||
import org.springframework.integration.jdbc.lock.DefaultLockRepository;
|
import org.springframework.integration.jdbc.lock.DefaultLockRepository;
|
||||||
import org.springframework.integration.jdbc.lock.JdbcLockRegistry;
|
import org.springframework.integration.jdbc.lock.JdbcLockRegistry;
|
||||||
import org.springframework.integration.jdbc.lock.LockRepository;
|
import org.springframework.integration.jdbc.lock.LockRepository;
|
||||||
|
import org.springframework.integration.support.locks.DefaultLockRegistry;
|
||||||
import org.springframework.integration.support.locks.LockRegistry;
|
import org.springframework.integration.support.locks.LockRegistry;
|
||||||
import org.springframework.lang.NonNull;
|
import org.springframework.lang.NonNull;
|
||||||
import org.springframework.retry.annotation.EnableRetry;
|
import org.springframework.retry.annotation.EnableRetry;
|
||||||
@@ -274,9 +275,9 @@ public class RepositoryApplicationConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ConditionalOnProperty(name = "hawkbit.lock", havingValue = "distributed", matchIfMissing = true)
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
LockRepository lockRepository(
|
LockRepository lockRepository(final DataSource dataSource, final LockProperties lockProperties, final PlatformTransactionManager txManager) {
|
||||||
final DataSource dataSource, final LockProperties lockProperties, final PlatformTransactionManager txManager) {
|
|
||||||
final DefaultLockRepository repository = new DistributedLockRepository(dataSource, lockProperties, txManager);
|
final DefaultLockRepository repository = new DistributedLockRepository(dataSource, lockProperties, txManager);
|
||||||
repository.setPrefix("SP_");
|
repository.setPrefix("SP_");
|
||||||
return repository;
|
return repository;
|
||||||
@@ -284,14 +285,15 @@ public class RepositoryApplicationConfiguration {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
public LockRegistry lockRegistry(final LockRepository lockRepository) {
|
public LockRegistry lockRegistry(final Optional<LockRepository> lockRepository) {
|
||||||
return new JdbcLockRegistry(lockRepository);
|
return lockRepository.<LockRegistry>map(JdbcLockRegistry::new).orElseGet(DefaultLockRegistry::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
PauseRolloutGroupAction pauseRolloutGroupAction(final RolloutManagement rolloutManagement,
|
PauseRolloutGroupAction pauseRolloutGroupAction(
|
||||||
final RolloutGroupRepository rolloutGroupRepository, final SystemSecurityContext systemSecurityContext) {
|
final RolloutManagement rolloutManagement, final RolloutGroupRepository rolloutGroupRepository,
|
||||||
|
final SystemSecurityContext systemSecurityContext) {
|
||||||
return new PauseRolloutGroupAction(rolloutManagement, rolloutGroupRepository, systemSecurityContext);
|
return new PauseRolloutGroupAction(rolloutManagement, rolloutGroupRepository, systemSecurityContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,8 +302,7 @@ public class RepositoryApplicationConfiguration {
|
|||||||
StartNextGroupRolloutGroupSuccessAction startNextRolloutGroupAction(
|
StartNextGroupRolloutGroupSuccessAction startNextRolloutGroupAction(
|
||||||
final RolloutGroupRepository rolloutGroupRepository, final DeploymentManagement deploymentManagement,
|
final RolloutGroupRepository rolloutGroupRepository, final DeploymentManagement deploymentManagement,
|
||||||
final SystemSecurityContext systemSecurityContext) {
|
final SystemSecurityContext systemSecurityContext) {
|
||||||
return new StartNextGroupRolloutGroupSuccessAction(rolloutGroupRepository, deploymentManagement,
|
return new StartNextGroupRolloutGroupSuccessAction(rolloutGroupRepository, deploymentManagement, systemSecurityContext);
|
||||||
systemSecurityContext);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|||||||
Reference in New Issue
Block a user