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:
Avgustin Marinov
2025-04-09 15:36:57 +03:00
committed by GitHub
parent 7c881587b6
commit 2b270ddad7
3 changed files with 11 additions and 8 deletions

View File

@@ -63,6 +63,7 @@ spring.flyway.enabled=false
## No Schedulers - START
hawkbit.autoassign.scheduler.enabled=false
hawkbit.rollout.scheduler.enabled=false
hawkbit.lock=inMemory
## No Schedulers - END
# Disable discovery client of spring-cloud-commons

View File

@@ -42,6 +42,7 @@ spring.flyway.enabled=false
## No Schedulers - START
hawkbit.autoassign.scheduler.enabled=false
hawkbit.rollout.scheduler.enabled=false
hawkbit.lock=inMemory
## No Schedulers - END
# Disable discovery client of spring-cloud-commons

View File

@@ -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.JdbcLockRegistry;
import org.springframework.integration.jdbc.lock.LockRepository;
import org.springframework.integration.support.locks.DefaultLockRegistry;
import org.springframework.integration.support.locks.LockRegistry;
import org.springframework.lang.NonNull;
import org.springframework.retry.annotation.EnableRetry;
@@ -274,9 +275,9 @@ public class RepositoryApplicationConfiguration {
}
@Bean
@ConditionalOnProperty(name = "hawkbit.lock", havingValue = "distributed", matchIfMissing = true)
@ConditionalOnMissingBean
LockRepository lockRepository(
final DataSource dataSource, final LockProperties lockProperties, final PlatformTransactionManager txManager) {
LockRepository lockRepository(final DataSource dataSource, final LockProperties lockProperties, final PlatformTransactionManager txManager) {
final DefaultLockRepository repository = new DistributedLockRepository(dataSource, lockProperties, txManager);
repository.setPrefix("SP_");
return repository;
@@ -284,14 +285,15 @@ public class RepositoryApplicationConfiguration {
@Bean
@ConditionalOnMissingBean
public LockRegistry lockRegistry(final LockRepository lockRepository) {
return new JdbcLockRegistry(lockRepository);
public LockRegistry lockRegistry(final Optional<LockRepository> lockRepository) {
return lockRepository.<LockRegistry>map(JdbcLockRegistry::new).orElseGet(DefaultLockRegistry::new);
}
@Bean
@ConditionalOnMissingBean
PauseRolloutGroupAction pauseRolloutGroupAction(final RolloutManagement rolloutManagement,
final RolloutGroupRepository rolloutGroupRepository, final SystemSecurityContext systemSecurityContext) {
PauseRolloutGroupAction pauseRolloutGroupAction(
final RolloutManagement rolloutManagement, final RolloutGroupRepository rolloutGroupRepository,
final SystemSecurityContext systemSecurityContext) {
return new PauseRolloutGroupAction(rolloutManagement, rolloutGroupRepository, systemSecurityContext);
}
@@ -300,8 +302,7 @@ public class RepositoryApplicationConfiguration {
StartNextGroupRolloutGroupSuccessAction startNextRolloutGroupAction(
final RolloutGroupRepository rolloutGroupRepository, final DeploymentManagement deploymentManagement,
final SystemSecurityContext systemSecurityContext) {
return new StartNextGroupRolloutGroupSuccessAction(rolloutGroupRepository, deploymentManagement,
systemSecurityContext);
return new StartNextGroupRolloutGroupSuccessAction(rolloutGroupRepository, deploymentManagement, systemSecurityContext);
}
@Bean