org.springframework.integration.support.locks.LockRegistry Java Examples

The following examples show how to use org.springframework.integration.support.locks.LockRegistry. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KinesisBinderConfiguration.java    From spring-cloud-stream-binder-aws-kinesis with Apache License 2.0 6 votes vote down vote up
@Bean
@ConditionalOnMissingBean
@ConditionalOnBean(AmazonDynamoDBAsync.class)
@ConditionalOnProperty(name = "spring.cloud.stream.kinesis.binder.kpl-kcl-enabled", havingValue = "false",
		matchIfMissing = true)
public LockRegistry dynamoDBLockRegistry(@Autowired(required = false) AmazonDynamoDBAsync dynamoDB) {
	if (dynamoDB != null) {
		KinesisBinderConfigurationProperties.Locks locks = this.configurationProperties.getLocks();
		DynamoDbLockRegistry dynamoDbLockRegistry = new DynamoDbLockRegistry(dynamoDB, locks.getTable());
		dynamoDbLockRegistry.setRefreshPeriod(locks.getRefreshPeriod());
		dynamoDbLockRegistry.setHeartbeatPeriod(locks.getHeartbeatPeriod());
		dynamoDbLockRegistry.setLeaseDuration(locks.getLeaseDuration());
		dynamoDbLockRegistry.setPartitionKey(locks.getPartitionKey());
		dynamoDbLockRegistry.setSortKeyName(locks.getSortKeyName());
		dynamoDbLockRegistry.setSortKey(locks.getSortKey());
		dynamoDbLockRegistry.setReadCapacity(locks.getReadCapacity());
		dynamoDbLockRegistry.setWriteCapacity(locks.getWriteCapacity());
		return dynamoDbLockRegistry;
	}
	else {
		return null;
	}
}
 
Example #2
Source File: AbstractRolloutManagement.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
protected AbstractRolloutManagement(final TargetManagement targetManagement,
        final DeploymentManagement deploymentManagement, final RolloutGroupManagement rolloutGroupManagement,
        final DistributionSetManagement distributionSetManagement, final ApplicationContext context,
        final VirtualPropertyReplacer virtualPropertyReplacer, final PlatformTransactionManager txManager,
        final TenantAware tenantAware, final LockRegistry lockRegistry,
        final RolloutApprovalStrategy rolloutApprovalStrategy,
        final TenantConfigurationManagement tenantConfigurationManagement,
        final SystemSecurityContext systemSecurityContext) {
    this.targetManagement = targetManagement;
    this.deploymentManagement = deploymentManagement;
    this.rolloutGroupManagement = rolloutGroupManagement;
    this.distributionSetManagement = distributionSetManagement;
    this.context = context;
    this.virtualPropertyReplacer = virtualPropertyReplacer;
    this.txManager = txManager;
    this.tenantAware = tenantAware;
    this.lockRegistry = lockRegistry;
    this.rolloutApprovalStrategy = rolloutApprovalStrategy;
    this.tenantConfigurationManagement = tenantConfigurationManagement;
    this.systemSecurityContext = systemSecurityContext;
}
 
Example #3
Source File: JpaRolloutManagement.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
JpaRolloutManagement(final TargetManagement targetManagement, final DeploymentManagement deploymentManagement,
        final RolloutGroupManagement rolloutGroupManagement,
        final DistributionSetManagement distributionSetManagement, final ApplicationContext context,
        final EventPublisherHolder eventPublisherHolder, final VirtualPropertyReplacer virtualPropertyReplacer,
        final PlatformTransactionManager txManager, final TenantAware tenantAware, final LockRegistry lockRegistry,
        final Database database, final RolloutApprovalStrategy rolloutApprovalStrategy,
        final TenantConfigurationManagement tenantConfigurationManagement,
        final SystemSecurityContext systemSecurityContext) {
    super(targetManagement, deploymentManagement, rolloutGroupManagement, distributionSetManagement, context,
            virtualPropertyReplacer, txManager, tenantAware, lockRegistry, rolloutApprovalStrategy,
            tenantConfigurationManagement, systemSecurityContext);
    this.eventPublisherHolder = eventPublisherHolder;
    this.database = database;
}
 
Example #4
Source File: RepositoryApplicationConfiguration.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
RolloutManagement rolloutManagement(final TargetManagement targetManagement,
        final DeploymentManagement deploymentManagement, final RolloutGroupManagement rolloutGroupManagement,
        final DistributionSetManagement distributionSetManagement, final ApplicationContext context,
        final EventPublisherHolder eventPublisherHolder, final VirtualPropertyReplacer virtualPropertyReplacer,
        final PlatformTransactionManager txManager, final TenantAware tenantAware, final LockRegistry lockRegistry,
        final JpaProperties properties, final RolloutApprovalStrategy rolloutApprovalStrategy,
        final TenantConfigurationManagement tenantConfigurationManagement,
        final SystemSecurityContext systemSecurityContext) {
    return new JpaRolloutManagement(targetManagement, deploymentManagement, rolloutGroupManagement,
            distributionSetManagement, context, eventPublisherHolder, virtualPropertyReplacer, txManager,
            tenantAware, lockRegistry, properties.getDatabase(), rolloutApprovalStrategy,
            tenantConfigurationManagement, systemSecurityContext);
}
 
Example #5
Source File: SingleInstanceTaskListener.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
public SingleInstanceTaskListener(LockRegistry lockRegistry,
		TaskNameResolver taskNameResolver, TaskProperties taskProperties,
		ApplicationEventPublisher applicationEventPublisher) {
	this.lockRegistry = lockRegistry;
	this.taskNameResolver = taskNameResolver;
	this.taskProperties = taskProperties;
	this.lockRegistryLeaderInitiator = new LockRegistryLeaderInitiator(
			this.lockRegistry);
	this.applicationEventPublisher = applicationEventPublisher;
}
 
Example #6
Source File: SingleInstanceTaskListener.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
private LockRegistry getDefaultLockRegistry(long executionId) {
	DefaultLockRepository lockRepository = new DefaultLockRepository(this.dataSource,
			String.valueOf(executionId));
	lockRepository.setPrefix(this.taskProperties.getTablePrefix());
	lockRepository.setTimeToLive(this.taskProperties.getSingleInstanceLockTtl());
	lockRepository.afterPropertiesSet();
	return new JdbcLockRegistry(lockRepository);
}
 
Example #7
Source File: KinesisMessageChannelBinder.java    From spring-cloud-stream-binder-aws-kinesis with Apache License 2.0 4 votes vote down vote up
public void setLockRegistry(LockRegistry lockRegistry) {
	this.lockRegistry = lockRegistry;
}
 
Example #8
Source File: CloudStreamKinesisToWebfluxApplicationTests.java    From spring-cloud-stream-samples with Apache License 2.0 4 votes vote down vote up
@Bean
public LockRegistry lockRegistry() {
	return new DefaultLockRegistry();
}
 
Example #9
Source File: TestConfiguration.java    From hawkbit with Eclipse Public License 1.0 4 votes vote down vote up
@Bean
LockRegistry lockRegistry() {
    return new DefaultLockRegistry();
}
 
Example #10
Source File: JpaRepositoryAutoConfiguration.java    From hawkbit with Eclipse Public License 1.0 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public LockRegistry lockRegistry() {
    return new DefaultLockRegistry();
}
 
Example #11
Source File: AutoAssignScheduler.java    From hawkbit with Eclipse Public License 1.0 3 votes vote down vote up
/**
 * Instantiates a new AutoAssignScheduler
 * 
 * @param systemManagement
 *            to find all tenants
 * @param systemSecurityContext
 *            to run as system
 * @param autoAssignChecker
 *            to run a check as tenant
 * @param lockRegistry
 *            to acquire a lock per tenant
 */
public AutoAssignScheduler(final SystemManagement systemManagement,
        final SystemSecurityContext systemSecurityContext, final AutoAssignChecker autoAssignChecker,
        final LockRegistry lockRegistry) {
    this.systemManagement = systemManagement;
    this.systemSecurityContext = systemSecurityContext;
    this.autoAssignChecker = autoAssignChecker;
    this.lockRegistry = lockRegistry;
}
 
Example #12
Source File: RepositoryApplicationConfiguration.java    From hawkbit with Eclipse Public License 1.0 3 votes vote down vote up
/**
 * {@link AutoAssignScheduler} bean.
 * 
 * Note: does not activate in test profile, otherwise it is hard to test the
 * auto assign functionality.
 *
 * @param tenantAware
 *            to run as specific tenant
 * @param systemManagement
 *            to find all tenants
 * @param systemSecurityContext
 *            to run as system
 * @param autoAssignChecker
 *            to run a check as tenant
 * @param lockRegistry
 *            to lock the tenant for auto assignment
 * @return a new {@link AutoAssignChecker}
 */
@Bean
@ConditionalOnMissingBean
// don't active the auto assign scheduler in test, otherwise it is hard to
// test
@Profile("!test")
@ConditionalOnProperty(prefix = "hawkbit.autoassign.scheduler", name = "enabled", matchIfMissing = true)
AutoAssignScheduler autoAssignScheduler(final TenantAware tenantAware, final SystemManagement systemManagement,
        final SystemSecurityContext systemSecurityContext, final AutoAssignChecker autoAssignChecker,
        final LockRegistry lockRegistry) {
    return new AutoAssignScheduler(systemManagement, systemSecurityContext, autoAssignChecker, lockRegistry);
}
 
Example #13
Source File: RepositoryApplicationConfiguration.java    From hawkbit with Eclipse Public License 1.0 3 votes vote down vote up
/**
 * {@link AutoCleanupScheduler} bean.
 * 
 * @param systemManagement
 *            to find all tenants
 * @param systemSecurityContext
 *            to run as system
 * @param lockRegistry
 *            to lock the tenant for auto assignment
 * @param cleanupTasks
 *            a list of cleanup tasks
 * 
 * @return a new {@link AutoCleanupScheduler} bean
 */
@Bean
@ConditionalOnMissingBean
@Profile("!test")
@ConditionalOnProperty(prefix = "hawkbit.autocleanup.scheduler", name = "enabled", matchIfMissing = true)
AutoCleanupScheduler autoCleanupScheduler(final SystemManagement systemManagement,
        final SystemSecurityContext systemSecurityContext, final LockRegistry lockRegistry,
        final List<CleanupTask> cleanupTasks) {
    return new AutoCleanupScheduler(systemManagement, systemSecurityContext, lockRegistry, cleanupTasks);
}
 
Example #14
Source File: AutoCleanupScheduler.java    From hawkbit with Eclipse Public License 1.0 3 votes vote down vote up
/**
 * Constructs the cleanup schedulers and initializes it with a set of
 * cleanup handlers.
 * 
 * @param systemManagement
 *            Management APIs to invoke actions in a certain tenant context.
 * @param systemSecurityContext
 *            The system security context.
 * @param lockRegistry
 *            A registry for shared locks.
 * @param cleanupTasks
 *            A list of cleanup tasks.
 */
public AutoCleanupScheduler(final SystemManagement systemManagement,
        final SystemSecurityContext systemSecurityContext, final LockRegistry lockRegistry,
        final List<CleanupTask> cleanupTasks) {
    this.systemManagement = systemManagement;
    this.systemSecurityContext = systemSecurityContext;
    this.lockRegistry = lockRegistry;
    this.cleanupTasks = cleanupTasks;
}