Skip to content

Commit

Permalink
Merge GlobalLockPersistService and LockPersistService (#34171)
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu authored Dec 26, 2024
1 parent 470b013 commit e49c72f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 48 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,32 @@

import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.mode.lock.global.GlobalLockDefinition;
import org.apache.shardingsphere.mode.lock.LockPersistService;
import org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository;

/**
* Global lock persist service.
*/
@RequiredArgsConstructor
public final class GlobalLockPersistService implements LockPersistService<GlobalLockDefinition> {
public final class GlobalLockPersistService {

private final ClusterPersistRepository repository;

@Override
/**
* Try lock.
*
* @param lockDefinition lock definition
* @param timeoutMillis timeout millis
* @return is locked or not
*/
public boolean tryLock(final GlobalLockDefinition lockDefinition, final long timeoutMillis) {
return repository.getDistributedLockHolder().getDistributedLock(lockDefinition.getLockKey()).tryLock(timeoutMillis);
}

@Override
/**
* Unlock.
*
* @param lockDefinition lock definition
*/
public void unlock(final GlobalLockDefinition lockDefinition) {
repository.getDistributedLockHolder().getDistributedLock(lockDefinition.getLockKey()).unlock();
}
Expand Down

0 comments on commit e49c72f

Please sign in to comment.