Feature - getCountDownLatch, getSemaphore, getPermitExpirableSemaphore, getFairLock methods added to RMap #1783

pull/1792/head
Nikita Koksharov 6 years ago
parent cbafc09d2b
commit fae3ad84fb

@ -124,6 +124,10 @@ public class Redisson implements RedissonClient {
evictionScheduler = new EvictionScheduler(connectionManager.getCommandExecutor());
}
public SemaphorePubSub getSemaphorePubSub() {
return semaphorePubSub;
}
public EvictionScheduler getEvictionScheduler() {
return evictionScheduler;
}

@ -45,7 +45,7 @@ public class RedissonFairLock extends RedissonLock implements RLock {
private final String threadsQueueName;
private final String timeoutSetName;
protected RedissonFairLock(CommandAsyncExecutor commandExecutor, String name) {
public RedissonFairLock(CommandAsyncExecutor commandExecutor, String name) {
super(commandExecutor, name);
this.commandExecutor = commandExecutor;
threadsQueueName = prefixName("redisson_lock_queue", name);

@ -33,11 +33,14 @@ import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicInteger;
import org.redisson.api.MapOptions;
import org.redisson.api.RCountDownLatch;
import org.redisson.api.MapOptions.WriteMode;
import org.redisson.api.RFuture;
import org.redisson.api.RLock;
import org.redisson.api.RMap;
import org.redisson.api.RPermitExpirableSemaphore;
import org.redisson.api.RReadWriteLock;
import org.redisson.api.RSemaphore;
import org.redisson.api.RedissonClient;
import org.redisson.api.mapreduce.RMapReduce;
import org.redisson.client.RedisClient;
@ -106,7 +109,31 @@ public class RedissonMap<K, V> extends RedissonExpirable implements RMap<K, V> {
public <KOut, VOut> RMapReduce<K, V, KOut, VOut> mapReduce() {
return new RedissonMapReduce<K, V, KOut, VOut>(this, redisson, commandExecutor.getConnectionManager());
}
@Override
public RPermitExpirableSemaphore getPermitExpirableSemaphore(K key) {
String lockName = getLockName(key, "permitexpirablesemaphore");
return new RedissonPermitExpirableSemaphore(commandExecutor, lockName, ((Redisson)redisson).getSemaphorePubSub());
}
@Override
public RSemaphore getSemaphore(K key) {
String lockName = getLockName(key, "semaphore");
return new RedissonSemaphore(commandExecutor, lockName, ((Redisson)redisson).getSemaphorePubSub());
}
@Override
public RCountDownLatch getCountDownLatch(K key) {
String lockName = getLockName(key, "countdownlatch");
return new RedissonCountDownLatch(commandExecutor, lockName);
}
@Override
public RLock getFairLock(K key) {
String lockName = getLockName(key, "fairlock");
return new RedissonFairLock(commandExecutor, lockName);
}
@Override
public RLock getLock(K key) {
String lockName = getLockName(key, "lock");

@ -103,6 +103,38 @@ public interface RMap<K, V> extends ConcurrentMap<K, V>, RExpirable, RMapAsync<K
* @return MapReduce instance
*/
<KOut, VOut> RMapReduce<K, V, KOut, VOut> mapReduce();
/**
* Returns <code>RCountDownLatch</code> instance associated with key
*
* @param key - map key
* @return readWriteLock
*/
RCountDownLatch getCountDownLatch(K key);
/**
* Returns <code>RPermitExpirableSemaphore</code> instance associated with key
*
* @param key - map key
* @return readWriteLock
*/
RPermitExpirableSemaphore getPermitExpirableSemaphore(K key);
/**
* Returns <code>RSemaphore</code> instance associated with key
*
* @param key - map key
* @return readWriteLock
*/
RSemaphore getSemaphore(K key);
/**
* Returns <code>RReadWriteLock</code> instance associated with key
*
* @param key - map key
* @return readWriteLock
*/
RLock getFairLock(K key);
/**
* Returns <code>RReadWriteLock</code> instance associated with key

@ -24,10 +24,13 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import org.redisson.RedissonMap;
import org.redisson.api.RCountDownLatch;
import org.redisson.api.RFuture;
import org.redisson.api.RLock;
import org.redisson.api.RMap;
import org.redisson.api.RPermitExpirableSemaphore;
import org.redisson.api.RReadWriteLock;
import org.redisson.api.RSemaphore;
import org.redisson.api.mapreduce.RMapReduce;
import org.redisson.client.RedisClient;
import org.redisson.client.codec.Codec;
@ -272,6 +275,26 @@ public class RedissonTransactionalMap<K, V> extends RedissonMap<K, V> {
throw new UnsupportedOperationException("loadAll method is not supported in transaction");
}
@Override
public RLock getFairLock(K key) {
throw new UnsupportedOperationException("getFairLock method is not supported in transaction");
}
@Override
public RCountDownLatch getCountDownLatch(K key) {
throw new UnsupportedOperationException("getCountDownLatch method is not supported in transaction");
}
@Override
public RPermitExpirableSemaphore getPermitExpirableSemaphore(K key) {
throw new UnsupportedOperationException("getPermitExpirableSemaphore method is not supported in transaction");
}
@Override
public RSemaphore getSemaphore(K key) {
throw new UnsupportedOperationException("getSemaphore method is not supported in transaction");
}
@Override
public RLock getLock(K key) {
throw new UnsupportedOperationException("getLock method is not supported in transaction");

@ -24,9 +24,12 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import org.redisson.RedissonMapCache;
import org.redisson.api.RCountDownLatch;
import org.redisson.api.RFuture;
import org.redisson.api.RLock;
import org.redisson.api.RPermitExpirableSemaphore;
import org.redisson.api.RReadWriteLock;
import org.redisson.api.RSemaphore;
import org.redisson.api.mapreduce.RMapReduce;
import org.redisson.client.RedisClient;
import org.redisson.client.codec.Codec;
@ -298,6 +301,26 @@ public class RedissonTransactionalMapCache<K, V> extends RedissonMapCache<K, V>
throw new UnsupportedOperationException("loadAll method is not supported in transaction");
}
@Override
public RLock getFairLock(K key) {
throw new UnsupportedOperationException("getFairLock method is not supported in transaction");
}
@Override
public RCountDownLatch getCountDownLatch(K key) {
throw new UnsupportedOperationException("getCountDownLatch method is not supported in transaction");
}
@Override
public RPermitExpirableSemaphore getPermitExpirableSemaphore(K key) {
throw new UnsupportedOperationException("getPermitExpirableSemaphore method is not supported in transaction");
}
@Override
public RSemaphore getSemaphore(K key) {
throw new UnsupportedOperationException("getSemaphore method is not supported in transaction");
}
@Override
public RLock getLock(K key) {
throw new UnsupportedOperationException("getLock method is not supported in transaction");

Loading…
Cancel
Save