GH-3272: Add lease renewal for distributed locks

Fixes https://github.com/spring-projects/spring-integration/issues/3272

* Introduce a `RenewableLockRegistry` since not all `LockRegistry` implementations
provide a way to renew the lease for the lock
* Implement `RenewableLockRegistry` in the `JdbcLockRegistry`
* Test and document the feature
This commit is contained in:
Alexandre Strubel
2020-07-01 15:17:37 +02:00
committed by Artem Bilan
parent 381a071287
commit e2c6e77f2f
8 changed files with 250 additions and 30 deletions

View File

@@ -0,0 +1,37 @@
/*
* Copyright 2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.support.locks;
/**
* A {@link LockRegistry} implementing this interface supports the renewal
* of the time to live of a lock.
*
* @author Alexandre Strubel
* @author Artem Bilan
*
* @since 5.4
*/
public interface RenewableLockRegistry extends LockRegistry {
/**
* Renew the time to live of the lock is associated with the parameter object.
* The lock must be held by the current thread
* @param lockKey The object with which the lock is associated.
*/
void renewLock(Object lockKey);
}