diff --git a/redisson/pom.xml b/redisson/pom.xml index b3405bd00..47682b349 100644 --- a/redisson/pom.xml +++ b/redisson/pom.xml @@ -439,14 +439,14 @@ com.google.protobuf protobuf-java - 4.27.5 + 4.29.3 provided true com.google.protobuf protobuf-java-util - 4.28.3 + 4.29.3 provided true diff --git a/redisson/src/main/java/org/redisson/RedissonBitSet.java b/redisson/src/main/java/org/redisson/RedissonBitSet.java index 527130a57..356c006f6 100644 --- a/redisson/src/main/java/org/redisson/RedissonBitSet.java +++ b/redisson/src/main/java/org/redisson/RedissonBitSet.java @@ -278,6 +278,24 @@ public class RedissonBitSet extends RedissonExpirable implements RBitSet { return commandExecutor.readAsync(getRawName(), LongCodec.INSTANCE, RedisCommands.GETBIT, getRawName(), bitIndex); } + @Override + public boolean[] get(long... bitIndexes) { + return get(getAsync(bitIndexes)); + } + + @Override + public RFuture getAsync(long... bitIndexes) { + Object[] indexes = new Object[bitIndexes.length * 3 + 1]; + int j = 0; + indexes[j++] = getRawName(); + for (long l : bitIndexes) { + indexes[j++] = "get"; + indexes[j++] = "u1"; + indexes[j++] = l; + } + return commandExecutor.readAsync(getRawName(), LongCodec.INSTANCE, RedisCommands.BITFIELD_BOOLEANS, indexes); + } + @Override public boolean set(long bitIndex) { return get(setAsync(bitIndex, true)); diff --git a/redisson/src/main/java/org/redisson/RedissonBlockingDeque.java b/redisson/src/main/java/org/redisson/RedissonBlockingDeque.java index cd8ceb71f..df1a3b5fe 100644 --- a/redisson/src/main/java/org/redisson/RedissonBlockingDeque.java +++ b/redisson/src/main/java/org/redisson/RedissonBlockingDeque.java @@ -151,6 +151,11 @@ public class RedissonBlockingDeque extends RedissonDeque implements RBlock return blockingQueue.pollLastFromAny(duration, count, queueNames); } + @Override + public Entry pollLastFromAnyWithName(Duration duration, String... queueNames) throws InterruptedException { + return blockingQueue.pollLastFromAnyWithName(duration, queueNames); + } + @Override public RFuture>> pollFirstFromAnyAsync(Duration duration, int count, String... queueNames) { return blockingQueue.pollFirstFromAnyAsync(duration, count, queueNames); @@ -161,6 +166,11 @@ public class RedissonBlockingDeque extends RedissonDeque implements RBlock return blockingQueue.pollLastFromAnyAsync(duration, count, queueNames); } + @Override + public RFuture> pollLastFromAnyWithNameAsync(Duration duration, String... queueNames) { + return blockingQueue.pollLastFromAnyWithNameAsync(duration, queueNames); + } + @Override public V takeLastAndOfferFirstTo(String queueName) throws InterruptedException { return commandExecutor.getInterrupted(takeLastAndOfferFirstToAsync(queueName)); diff --git a/redisson/src/main/java/org/redisson/RedissonBlockingQueue.java b/redisson/src/main/java/org/redisson/RedissonBlockingQueue.java index 869087324..b827e826c 100644 --- a/redisson/src/main/java/org/redisson/RedissonBlockingQueue.java +++ b/redisson/src/main/java/org/redisson/RedissonBlockingQueue.java @@ -183,6 +183,20 @@ public class RedissonBlockingQueue extends RedissonQueue implements RBlock return commandExecutor.writeAsync(getRawName(), codec, RedisCommands.BLMPOP, params.toArray()); } + @Override + public Entry pollLastFromAnyWithName(Duration duration, String... queueNames) throws InterruptedException { + return commandExecutor.getInterrupted(pollLastFromAnyWithNameAsync(duration, queueNames)); + } + + @Override + public RFuture> pollLastFromAnyWithNameAsync(Duration timeout, String... queueNames) { + if (timeout.toMillis() < 0) { + return new CompletableFutureWrapper<>((Entry) null); + } + return commandExecutor.pollFromAnyAsync(getRawName(), codec, RedisCommands.BRPOP_NAME, + toSeconds(timeout.toMillis(), TimeUnit.MILLISECONDS), queueNames); + } + @Override public RFuture pollLastAndOfferFirstToAsync(String queueName, long timeout, TimeUnit unit) { if (timeout < 0) { diff --git a/redisson/src/main/java/org/redisson/RedissonBoundedBlockingQueue.java b/redisson/src/main/java/org/redisson/RedissonBoundedBlockingQueue.java index 7baec34f8..700fda40d 100644 --- a/redisson/src/main/java/org/redisson/RedissonBoundedBlockingQueue.java +++ b/redisson/src/main/java/org/redisson/RedissonBoundedBlockingQueue.java @@ -235,6 +235,17 @@ public class RedissonBoundedBlockingQueue extends RedissonQueue implements return wrapTakeFuture(takeFuture); } + @Override + public Entry pollLastFromAnyWithName(Duration timeout, String... queueNames) throws InterruptedException { + return commandExecutor.getInterrupted(pollLastFromAnyWithNameAsync(timeout, queueNames)); + } + + @Override + public RFuture> pollLastFromAnyWithNameAsync(Duration timeout, String... queueNames) { + RFuture> takeFuture = blockingQueue.pollLastFromAnyWithNameAsync(timeout, queueNames); + return wrapTakeFuture(takeFuture); + } + @Override public Map> pollFirstFromAny(Duration duration, int count, String... queueNames) { return get(pollFirstFromAnyAsync(duration, count, queueNames)); diff --git a/redisson/src/main/java/org/redisson/RedissonPriorityBlockingDeque.java b/redisson/src/main/java/org/redisson/RedissonPriorityBlockingDeque.java index d38bd7c14..2b2c80359 100644 --- a/redisson/src/main/java/org/redisson/RedissonPriorityBlockingDeque.java +++ b/redisson/src/main/java/org/redisson/RedissonPriorityBlockingDeque.java @@ -101,6 +101,16 @@ public class RedissonPriorityBlockingDeque extends RedissonPriorityDeque i throw new UnsupportedOperationException("use poll method"); } + @Override + public Entry pollLastFromAnyWithName(Duration timeout, String... queueNames) throws InterruptedException { + throw new UnsupportedOperationException("use poll method"); + } + + @Override + public RFuture> pollLastFromAnyWithNameAsync(Duration timeout, String... queueNames) { + throw new UnsupportedOperationException("use poll method"); + } + @Override public Map> pollFirstFromAny(Duration duration, int count, String... queueNames) throws InterruptedException { throw new UnsupportedOperationException("use poll method"); diff --git a/redisson/src/main/java/org/redisson/RedissonPriorityBlockingQueue.java b/redisson/src/main/java/org/redisson/RedissonPriorityBlockingQueue.java index 790c5543c..76d39ea78 100644 --- a/redisson/src/main/java/org/redisson/RedissonPriorityBlockingQueue.java +++ b/redisson/src/main/java/org/redisson/RedissonPriorityBlockingQueue.java @@ -156,6 +156,11 @@ public class RedissonPriorityBlockingQueue extends RedissonPriorityQueue i throw new UnsupportedOperationException("use poll method"); } + @Override + public Entry pollLastFromAnyWithName(Duration timeout, String... queueNames) throws InterruptedException { + throw new UnsupportedOperationException("use poll method"); + } + @Override public RFuture>> pollFirstFromAnyAsync(Duration duration, int count, String... queueNames) { throw new UnsupportedOperationException("use poll method"); @@ -291,6 +296,11 @@ public class RedissonPriorityBlockingQueue extends RedissonPriorityQueue i throw new UnsupportedOperationException("use poll method"); } + @Override + public RFuture> pollLastFromAnyWithNameAsync(Duration timeout, String... queueNames) { + throw new UnsupportedOperationException("use poll method"); + } + @Override public RFuture putAsync(V e) { throw new UnsupportedOperationException("use add method"); diff --git a/redisson/src/main/java/org/redisson/RedissonTransferQueue.java b/redisson/src/main/java/org/redisson/RedissonTransferQueue.java index 3525624b0..a58e7489a 100644 --- a/redisson/src/main/java/org/redisson/RedissonTransferQueue.java +++ b/redisson/src/main/java/org/redisson/RedissonTransferQueue.java @@ -611,6 +611,16 @@ public class RedissonTransferQueue extends RedissonExpirable implements RTran throw new UnsupportedOperationException(); } + @Override + public Entry pollLastFromAnyWithName(Duration timeout, String... queueNames) throws InterruptedException { + throw new UnsupportedOperationException(); + } + + @Override + public RFuture> pollLastFromAnyWithNameAsync(Duration timeout, String... queueNames) { + throw new UnsupportedOperationException(); + } + @Override public Map> pollFirstFromAny(Duration duration, int count, String... queueNames) throws InterruptedException { throw new UnsupportedOperationException(); diff --git a/redisson/src/main/java/org/redisson/api/RBitSet.java b/redisson/src/main/java/org/redisson/api/RBitSet.java index 260bb7a70..79868308b 100644 --- a/redisson/src/main/java/org/redisson/api/RBitSet.java +++ b/redisson/src/main/java/org/redisson/api/RBitSet.java @@ -275,6 +275,14 @@ public interface RBitSet extends RExpirable, RBitSetAsync { * @return true if bit set to one and false overwise. */ boolean get(long bitIndex); + + /** + * Returns a boolean array where each element of the array corresponds to the query result of the input parameters. + * + * @param bitIndexes indexes of bit + * @return Returns a boolean array where each element of the array corresponds to the query result of the input parameters. + */ + boolean[] get(long... bitIndexes); /** * Set bit to one at specified bitIndex diff --git a/redisson/src/main/java/org/redisson/api/RBitSetAsync.java b/redisson/src/main/java/org/redisson/api/RBitSetAsync.java index 9b2608144..45d3ca101 100644 --- a/redisson/src/main/java/org/redisson/api/RBitSetAsync.java +++ b/redisson/src/main/java/org/redisson/api/RBitSetAsync.java @@ -274,6 +274,14 @@ public interface RBitSetAsync extends RExpirableAsync { * @return true if bit set to one and false overwise. */ RFuture getAsync(long bitIndex); + + /** + * Returns a boolean array where each element of the array corresponds to the query result of the input parameters. + * + * @param bitIndexes indexes of bit + * @return Returns a boolean array where each element of the array corresponds to the query result of the input parameters. + */ + RFuture getAsync(long... bitIndexes); /** * Set bit to one at specified bitIndex diff --git a/redisson/src/main/java/org/redisson/api/RBitSetReactive.java b/redisson/src/main/java/org/redisson/api/RBitSetReactive.java index 709602e9e..ad701a1ac 100644 --- a/redisson/src/main/java/org/redisson/api/RBitSetReactive.java +++ b/redisson/src/main/java/org/redisson/api/RBitSetReactive.java @@ -276,6 +276,14 @@ public interface RBitSetReactive extends RExpirableReactive { * @return true if bit set to one and false overwise. */ Mono get(long bitIndex); + + /** + * Returns a boolean array where each element of the array corresponds to the query result of the input parameters. + * + * @param bitIndexes indexes of bit + * @return Returns a boolean array where each element of the array corresponds to the query result of the input parameters. + */ + Mono get(long... bitIndexes); /** * Set bit to one at specified bitIndex diff --git a/redisson/src/main/java/org/redisson/api/RBitSetRx.java b/redisson/src/main/java/org/redisson/api/RBitSetRx.java index 06b00e84c..8771da49d 100644 --- a/redisson/src/main/java/org/redisson/api/RBitSetRx.java +++ b/redisson/src/main/java/org/redisson/api/RBitSetRx.java @@ -278,6 +278,14 @@ public interface RBitSetRx extends RExpirableRx { * @return true if bit set to one and false overwise. */ Single get(long bitIndex); + + /** + * Returns a boolean array where each element of the array corresponds to the query result of the input parameters. + * + * @param bitIndexes indexes of bit + * @return Returns a boolean array where each element of the array corresponds to the query result of the input parameters. + */ + Single get(long... bitIndexes); /** * Set bit to one at specified bitIndex diff --git a/redisson/src/main/java/org/redisson/api/RBlockingQueue.java b/redisson/src/main/java/org/redisson/api/RBlockingQueue.java index 31ca70b47..b75710e49 100644 --- a/redisson/src/main/java/org/redisson/api/RBlockingQueue.java +++ b/redisson/src/main/java/org/redisson/api/RBlockingQueue.java @@ -92,6 +92,20 @@ public interface RBlockingQueue extends BlockingQueue, RQueue, RBlockin */ Map> pollLastFromAny(Duration duration, int count, String... queueNames) throws InterruptedException; + /** + * Retrieves and removes first available tail element of any queue, + * waiting up to the specified wait time if necessary for an element to become available + * in any of defined queues including queue itself. + * + * @param queueNames queue names. Queue name itself is always included + * @param timeout how long to wait before giving up, in units of + * {@code unit} + * @return the tail of this queue, or {@code null} if the + * specified waiting time elapses before an element is available + * @throws InterruptedException if interrupted while waiting + */ + Entry pollLastFromAnyWithName(Duration timeout, String... queueNames) throws InterruptedException; + /** * Retrieves and removes last available tail element of this queue and adds it at the head of queueName, * waiting up to the specified wait time if necessary for an element to become available. diff --git a/redisson/src/main/java/org/redisson/api/RBlockingQueueAsync.java b/redisson/src/main/java/org/redisson/api/RBlockingQueueAsync.java index 568fd2454..42297b331 100644 --- a/redisson/src/main/java/org/redisson/api/RBlockingQueueAsync.java +++ b/redisson/src/main/java/org/redisson/api/RBlockingQueueAsync.java @@ -87,6 +87,18 @@ public interface RBlockingQueueAsync extends RQueueAsync { */ RFuture>> pollLastFromAnyAsync(Duration duration, int count, String... queueNames); + /** + * Retrieves and removes first available tail element of any queue in async mode, + * waiting up to the specified wait time if necessary for an element to become available + * in any of defined queues including queue itself. + * + * @param queueNames - queue names. Queue name itself is always included + * @param timeout how long to wait before giving up + * @return Future object with the tail of this queue, or {@code null} if the + * specified waiting time elapses before an element is available + */ + RFuture> pollLastFromAnyWithNameAsync(Duration timeout, String... queueNames); + /** * Removes at most the given number of available elements from * this queue and adds them to the given collection in async mode. A failure diff --git a/redisson/src/main/java/org/redisson/api/RBlockingQueueReactive.java b/redisson/src/main/java/org/redisson/api/RBlockingQueueReactive.java index 48ff2ba01..89fdebef9 100644 --- a/redisson/src/main/java/org/redisson/api/RBlockingQueueReactive.java +++ b/redisson/src/main/java/org/redisson/api/RBlockingQueueReactive.java @@ -61,6 +61,21 @@ public interface RBlockingQueueReactive extends RQueueReactive { */ Mono> pollFromAnyWithName(Duration timeout, String... queueNames); + /** + * Retrieves and removes first available tail element of any queue, + * waiting up to the specified wait time if necessary for an element to become available + * in any of defined queues including queue itself. + * + * @param queueNames queue names. Queue name itself is always included + * @param timeout how long to wait before giving up, in units of + * {@code unit} + * @return the tail of this queue, or {@code null} if the + * specified waiting time elapses before an element is available + * @throws InterruptedException if interrupted while waiting + */ + Mono> pollLastFromAnyWithName(Duration timeout, String... queueNames); + + /** * Retrieves and removes first available head elements of any queue, * waiting up to the specified wait time if necessary for an element to become available diff --git a/redisson/src/main/java/org/redisson/api/RBlockingQueueRx.java b/redisson/src/main/java/org/redisson/api/RBlockingQueueRx.java index b5f9f7824..69188b92a 100644 --- a/redisson/src/main/java/org/redisson/api/RBlockingQueueRx.java +++ b/redisson/src/main/java/org/redisson/api/RBlockingQueueRx.java @@ -63,6 +63,20 @@ public interface RBlockingQueueRx extends RQueueRx { */ Maybe> pollFromAnyWithName(Duration timeout, String... queueNames) throws InterruptedException; + /** + * Retrieves and removes first available tail element of any queue, + * waiting up to the specified wait time if necessary for an element to become available + * in any of defined queues including queue itself. + * + * @param queueNames queue names. Queue name itself is always included + * @param timeout how long to wait before giving up, in units of + * {@code unit} + * @return the tail of this queue, or {@code null} if the + * specified waiting time elapses before an element is available + * @throws InterruptedException if interrupted while waiting + */ + Maybe> pollLastFromAnyWithName(Duration timeout, String... queueNames) throws InterruptedException; + /** * Retrieves and removes first available head elements of any queue, * waiting up to the specified wait time if necessary for an element to become available diff --git a/redisson/src/main/java/org/redisson/client/protocol/RedisCommands.java b/redisson/src/main/java/org/redisson/client/protocol/RedisCommands.java index db4a8dacf..28716d4bc 100644 --- a/redisson/src/main/java/org/redisson/client/protocol/RedisCommands.java +++ b/redisson/src/main/java/org/redisson/client/protocol/RedisCommands.java @@ -64,6 +64,9 @@ public interface RedisCommands { RedisStrictCommand BITFIELD_SHORT = new RedisStrictCommand<>("BITFIELD", null, new ListFirstObjectDecoder(), new ShortReplayConvertor()); RedisStrictCommand BITFIELD_VOID = new RedisStrictCommand<>("BITFIELD", new VoidReplayConvertor()); + + RedisStrictCommand BITFIELD_BOOLEANS = new RedisStrictCommand<>("BITFIELD", null, + new ArrayBooleanDecoder(), new BooleanReplayConvertor()); RedisStrictCommand GETBIT = new RedisStrictCommand("GETBIT", new BooleanReplayConvertor()); RedisStrictCommand BITS_SIZE = new RedisStrictCommand("STRLEN", new BitsSizeReplayConvertor()); @@ -298,7 +301,7 @@ public interface RedisCommands { RedisCommand BZPOPMIN_VALUE = new RedisCommand("BZPOPMIN", new ScoredSortedSetPolledObjectDecoder()); RedisCommand BZPOPMAX_VALUE = new RedisCommand("BZPOPMAX", new ScoredSortedSetPolledObjectDecoder()); - RedisCommand>> BLPOP_NAME = new RedisCommand<>("BLPOP", + RedisCommand> BLPOP_NAME = new RedisCommand<>("BLPOP", new ListObjectDecoder(0) { @Override public Object decode(List parts, State state) { @@ -309,6 +312,17 @@ public interface RedisCommands { } }); + RedisCommand> BRPOP_NAME = new RedisCommand<>("BRPOP", + new ListObjectDecoder(0) { + @Override + public Object decode(List parts, State state) { + if (parts.isEmpty()) { + return null; + } + return new org.redisson.api.Entry<>(parts.get(0), parts.get(1)); + } + }); + RedisCommand>> BLMPOP = new RedisCommand<>("BLMPOP", new ListMultiDecoder2( new ObjectDecoder(StringCodec.INSTANCE.getValueDecoder()) { diff --git a/redisson/src/main/java/org/redisson/client/protocol/decoder/ArrayBooleanDecoder.java b/redisson/src/main/java/org/redisson/client/protocol/decoder/ArrayBooleanDecoder.java new file mode 100644 index 000000000..7ec0e2048 --- /dev/null +++ b/redisson/src/main/java/org/redisson/client/protocol/decoder/ArrayBooleanDecoder.java @@ -0,0 +1,46 @@ +/** + * Copyright (c) 2013-2024 Nikita Koksharov + * + * 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 + * + * http://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.redisson.client.protocol.decoder; + +import org.redisson.client.handler.State; + +import java.util.List; + +/** + * + * @author seakider + * + */ +public class ArrayBooleanDecoder implements MultiDecoder { + + @Override + public boolean[] decode(List parts, State state) { + if (parts.isEmpty()) { + return new boolean[0]; + } + + boolean[] result = new boolean[parts.size()]; + for (int i = 0; i < parts.size(); i++) { + Object part = parts.get(i); + if (part instanceof Boolean) { + result[i] = (boolean) part; + } else { + result[i] = false; + } + } + return result; + } +} diff --git a/redisson/src/main/java/org/redisson/spring/cache/CacheConfig.java b/redisson/src/main/java/org/redisson/spring/cache/CacheConfig.java index 5af54eda3..76a6ba01f 100644 --- a/redisson/src/main/java/org/redisson/spring/cache/CacheConfig.java +++ b/redisson/src/main/java/org/redisson/spring/cache/CacheConfig.java @@ -15,6 +15,7 @@ */ package org.redisson.spring.cache; +import org.redisson.api.EvictionMode; import org.redisson.api.map.event.MapEntryListener; import java.io.File; @@ -39,7 +40,9 @@ public class CacheConfig { private long maxIdleTime; private int maxSize; - + + private EvictionMode evictionMode = EvictionMode.LRU; + private final List listeners = new ArrayList<>(); /** @@ -79,7 +82,6 @@ public class CacheConfig { public void setTTL(long ttl) { this.ttl = ttl; } - public int getMaxSize() { return maxSize; @@ -95,6 +97,21 @@ public class CacheConfig { this.maxSize = maxSize; } + public EvictionMode getEvictionMode() { + return evictionMode; + } + + /** + * Set the eviction mode of the map. Superfluous elements are evicted using LRU or LFU algorithm. + * + * @param evictionMode - eviction mode (LRU, LFU) + * @return + */ + public CacheConfig setEvictionMode(EvictionMode evictionMode) { + this.evictionMode = evictionMode; + return this; + } + public long getMaxIdleTime() { return maxIdleTime; } diff --git a/redisson/src/main/java/org/redisson/spring/cache/RedissonSpringCacheManager.java b/redisson/src/main/java/org/redisson/spring/cache/RedissonSpringCacheManager.java index 9337dc0a2..9cca0757e 100644 --- a/redisson/src/main/java/org/redisson/spring/cache/RedissonSpringCacheManager.java +++ b/redisson/src/main/java/org/redisson/spring/cache/RedissonSpringCacheManager.java @@ -269,7 +269,7 @@ public class RedissonSpringCacheManager implements CacheManager, ResourceLoaderA if (oldCache != null) { cache = oldCache; } else { - map.setMaxSize(config.getMaxSize()); + map.setMaxSize(config.getMaxSize(), config.getEvictionMode()); for (MapEntryListener listener : config.getListeners()) { map.addListener(listener); } diff --git a/redisson/src/test/java/org/redisson/RedissonBitSetReactiveTest.java b/redisson/src/test/java/org/redisson/RedissonBitSetReactiveTest.java index 592c73e3f..1f6ae1be6 100644 --- a/redisson/src/test/java/org/redisson/RedissonBitSetReactiveTest.java +++ b/redisson/src/test/java/org/redisson/RedissonBitSetReactiveTest.java @@ -6,6 +6,8 @@ import org.redisson.api.RBitSetReactive; import java.util.BitSet; +import static org.assertj.core.api.Assertions.assertThat; + public class RedissonBitSetReactiveTest extends BaseReactiveTest { @Test @@ -112,6 +114,17 @@ public class RedissonBitSetReactiveTest extends BaseReactiveTest { Assertions.assertEquals(1, sync(bs1.cardinality()).intValue()); Assertions.assertEquals(16, sync(bs1.size()).intValue()); } - + + @Test + public void testGetWithIndexes() { + RBitSetReactive bitset = redisson.getBitSet("testbitset"); + + sync(bitset.set(4, 10)); + boolean[] result = sync(bitset.get(2, 4, 7, 8)); + assertThat(result[0]).isFalse(); + assertThat(result[1]).isTrue(); + assertThat(result[2]).isTrue(); + assertThat(result[3]).isTrue(); + } } diff --git a/redisson/src/test/java/org/redisson/RedissonBitSetTest.java b/redisson/src/test/java/org/redisson/RedissonBitSetTest.java index d1a550384..36303420b 100644 --- a/redisson/src/test/java/org/redisson/RedissonBitSetTest.java +++ b/redisson/src/test/java/org/redisson/RedissonBitSetTest.java @@ -210,5 +210,16 @@ public class RedissonBitSetTest extends RedisDockerTest { assertThat(bs1.size()).isEqualTo(16); } + @Test + public void testGetWithIndexes() { + RBitSet bitset = redisson.getBitSet("testbitset"); + + bitset.set(4, 10); + boolean[] result = bitset.get(2, 4, 7, 8); + assertThat(result[0]).isFalse(); + assertThat(result[1]).isTrue(); + assertThat(result[2]).isTrue(); + assertThat(result[3]).isTrue(); + } } diff --git a/redisson/src/test/java/org/redisson/RedissonBlockingQueueTest.java b/redisson/src/test/java/org/redisson/RedissonBlockingQueueTest.java index 50d2d8cc4..78aac3fc5 100644 --- a/redisson/src/test/java/org/redisson/RedissonBlockingQueueTest.java +++ b/redisson/src/test/java/org/redisson/RedissonBlockingQueueTest.java @@ -425,6 +425,33 @@ public class RedissonBlockingQueueTest extends RedissonQueueTest { Assertions.assertTrue(System.currentTimeMillis() - s > 2000); } + @Test + public void testPollLastFromAnyWithName() throws InterruptedException { + RBlockingQueue queue1 = redisson.getBlockingQueue("queue:polLast"); + RBlockingQueue queue2 = redisson.getBlockingQueue("queue:polLast1"); + RBlockingQueue queue3 = redisson.getBlockingQueue("queue:polLast2"); + queue3.put(1); + queue3.put(2); + queue3.put(3); + queue1.put(4); + queue1.put(5); + queue1.put(6); + queue2.put(7); + + Entry r = queue1.pollLastFromAnyWithName(Duration.ofSeconds(4), "queue:polLast1", "queue:polpolLast2"); + assertThat(r.getKey()).isEqualTo("queue:polLast"); + assertThat(r.getValue()).isEqualTo(6); + + Entry r2 = queue2.pollLastFromAnyWithName(Duration.ofSeconds(4), "queue:polLast", "queue:polLast2"); + assertThat(r2.getKey()).isEqualTo("queue:polLast1"); + assertThat(r2.getValue()).isEqualTo(7); + + Entry r3 = queue2.pollLastFromAnyWithName(Duration.ofSeconds(4), "queue:polLast2", "queue:polLast"); + assertThat(r3.getKey()).isEqualTo("queue:polLast2"); + assertThat(r3.getValue()).isEqualTo(3); + + } + @Test public void testPollFirstFromAny() throws InterruptedException { RBlockingQueue queue1 = redisson.getBlockingQueue("queue:pollany"); diff --git a/redisson/src/test/java/org/redisson/codec/protobuf/nativeData/Proto2AllTypes.java b/redisson/src/test/java/org/redisson/codec/protobuf/nativeData/Proto2AllTypes.java index cf2b096b8..1d2f11cf1 100644 --- a/redisson/src/test/java/org/redisson/codec/protobuf/nativeData/Proto2AllTypes.java +++ b/redisson/src/test/java/org/redisson/codec/protobuf/nativeData/Proto2AllTypes.java @@ -211,12 +211,12 @@ public final class Proto2AllTypes { * Protobuf type {@code AllTypes2} */ public static final class AllTypes2 extends - com.google.protobuf.GeneratedMessageV3 implements + com.google.protobuf.GeneratedMessage implements // @@protoc_insertion_point(message_implements:AllTypes2) AllTypes2OrBuilder { private static final long serialVersionUID = 0L; // Use AllTypes2.newBuilder() to construct. - private AllTypes2(com.google.protobuf.GeneratedMessageV3.Builder builder) { + private AllTypes2(com.google.protobuf.GeneratedMessage.Builder builder) { super(builder); } private AllTypes2() { @@ -238,7 +238,7 @@ public final class Proto2AllTypes { } @Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { return Proto2AllTypes.internal_static_org_redisson_codec_protobuf_raw_AllTypes2_fieldAccessorTable .ensureFieldAccessorsInitialized( @@ -641,7 +641,7 @@ public final class Proto2AllTypes { output.writeBool(13, boolType_); } if (((bitField0_ & 0x00001000) != 0)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 14, stringType_); + com.google.protobuf.GeneratedMessage.writeString(output, 14, stringType_); } if (((bitField0_ & 0x00002000) != 0)) { output.writeBytes(15, bytesType_); @@ -710,7 +710,7 @@ public final class Proto2AllTypes { .computeBoolSize(13, boolType_); } if (((bitField0_ & 0x00001000) != 0)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(14, stringType_); + size += com.google.protobuf.GeneratedMessage.computeStringSize(14, stringType_); } if (((bitField0_ & 0x00002000) != 0)) { size += com.google.protobuf.CodedOutputStream @@ -921,20 +921,20 @@ public final class Proto2AllTypes { } public static Proto2AllTypes.AllTypes2 parseFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessage .parseWithIOException(PARSER, input); } public static Proto2AllTypes.AllTypes2 parseFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessage .parseWithIOException(PARSER, input, extensionRegistry); } public static Proto2AllTypes.AllTypes2 parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessage .parseDelimitedWithIOException(PARSER, input); } @@ -942,20 +942,20 @@ public final class Proto2AllTypes { java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessage .parseDelimitedWithIOException(PARSER, input, extensionRegistry); } public static Proto2AllTypes.AllTypes2 parseFrom( com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessage .parseWithIOException(PARSER, input); } public static Proto2AllTypes.AllTypes2 parseFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessage .parseWithIOException(PARSER, input, extensionRegistry); } @@ -975,7 +975,7 @@ public final class Proto2AllTypes { @Override protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + com.google.protobuf.GeneratedMessage.BuilderParent parent) { Builder builder = new Builder(parent); return builder; } @@ -983,7 +983,7 @@ public final class Proto2AllTypes { * Protobuf type {@code AllTypes2} */ public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements + com.google.protobuf.GeneratedMessage.Builder implements // @@protoc_insertion_point(builder_implements:AllTypes2) Proto2AllTypes.AllTypes2OrBuilder { public static final com.google.protobuf.Descriptors.Descriptor @@ -992,7 +992,7 @@ public final class Proto2AllTypes { } @Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { return Proto2AllTypes.internal_static_org_redisson_codec_protobuf_raw_AllTypes2_fieldAccessorTable .ensureFieldAccessorsInitialized( @@ -1005,7 +1005,7 @@ public final class Proto2AllTypes { } private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + com.google.protobuf.GeneratedMessage.BuilderParent parent) { super(parent); } @@ -2141,7 +2141,7 @@ public final class Proto2AllTypes { private static final com.google.protobuf.Descriptors.Descriptor internal_static_org_redisson_codec_protobuf_raw_AllTypes2_descriptor; private static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_org_redisson_codec_protobuf_raw_AllTypes2_fieldAccessorTable; public static com.google.protobuf.Descriptors.FileDescriptor @@ -2171,7 +2171,7 @@ public final class Proto2AllTypes { internal_static_org_redisson_codec_protobuf_raw_AllTypes2_descriptor = getDescriptor().getMessageTypes().get(0); internal_static_org_redisson_codec_protobuf_raw_AllTypes2_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_org_redisson_codec_protobuf_raw_AllTypes2_descriptor, new String[] { "DoubleType", "FloatType", "Int32Type", "Int64Type", "Uint32Type", "Uint64Type", "Sint32Type", "Sint64Type", "Fixed32Type", "Fixed64Type", "Sfixed32Type", "Sfixed64Type", "BoolType", "StringType", "BytesType", }); } diff --git a/redisson/src/test/java/org/redisson/codec/protobuf/nativeData/Proto3AllTypes.java b/redisson/src/test/java/org/redisson/codec/protobuf/nativeData/Proto3AllTypes.java index 8c632f1ed..a87ff6ab3 100644 --- a/redisson/src/test/java/org/redisson/codec/protobuf/nativeData/Proto3AllTypes.java +++ b/redisson/src/test/java/org/redisson/codec/protobuf/nativeData/Proto3AllTypes.java @@ -146,12 +146,12 @@ public final class Proto3AllTypes { * Protobuf type {@code org.redisson.codec.protobuf.raw.AllTypes3} */ public static final class AllTypes3 extends - com.google.protobuf.GeneratedMessageV3 implements + com.google.protobuf.GeneratedMessage implements // @@protoc_insertion_point(message_implements:org.redisson.codec.protobuf.raw.AllTypes3) AllTypes3OrBuilder { private static final long serialVersionUID = 0L; // Use AllTypes3.newBuilder() to construct. - private AllTypes3(com.google.protobuf.GeneratedMessageV3.Builder builder) { + private AllTypes3(com.google.protobuf.GeneratedMessage.Builder builder) { super(builder); } private AllTypes3() { @@ -173,7 +173,7 @@ public final class Proto3AllTypes { } @Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { return Proto3AllTypes.internal_static_org_redisson_codec_protobuf_raw_AllTypes3_fieldAccessorTable .ensureFieldAccessorsInitialized( @@ -471,8 +471,8 @@ public final class Proto3AllTypes { if (boolType_ != false) { output.writeBool(13, boolType_); } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(stringType_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 14, stringType_); + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(stringType_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 14, stringType_); } if (!bytesType_.isEmpty()) { output.writeBytes(15, bytesType_); @@ -545,8 +545,8 @@ public final class Proto3AllTypes { size += com.google.protobuf.CodedOutputStream .computeBoolSize(13, boolType_); } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(stringType_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(14, stringType_); + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(stringType_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(14, stringType_); } if (!bytesType_.isEmpty()) { size += com.google.protobuf.CodedOutputStream @@ -692,20 +692,20 @@ public final class Proto3AllTypes { } public static Proto3AllTypes.AllTypes3 parseFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessage .parseWithIOException(PARSER, input); } public static Proto3AllTypes.AllTypes3 parseFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessage .parseWithIOException(PARSER, input, extensionRegistry); } public static Proto3AllTypes.AllTypes3 parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessage .parseDelimitedWithIOException(PARSER, input); } @@ -713,20 +713,20 @@ public final class Proto3AllTypes { java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessage .parseDelimitedWithIOException(PARSER, input, extensionRegistry); } public static Proto3AllTypes.AllTypes3 parseFrom( com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessage .parseWithIOException(PARSER, input); } public static Proto3AllTypes.AllTypes3 parseFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessage .parseWithIOException(PARSER, input, extensionRegistry); } @@ -746,7 +746,7 @@ public final class Proto3AllTypes { @Override protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + com.google.protobuf.GeneratedMessage.BuilderParent parent) { Builder builder = new Builder(parent); return builder; } @@ -754,7 +754,7 @@ public final class Proto3AllTypes { * Protobuf type {@code org.redisson.codec.protobuf.raw.AllTypes3} */ public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements + com.google.protobuf.GeneratedMessage.Builder implements // @@protoc_insertion_point(builder_implements:org.redisson.codec.protobuf.raw.AllTypes3) Proto3AllTypes.AllTypes3OrBuilder { public static final com.google.protobuf.Descriptors.Descriptor @@ -763,7 +763,7 @@ public final class Proto3AllTypes { } @Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { return Proto3AllTypes.internal_static_org_redisson_codec_protobuf_raw_AllTypes3_fieldAccessorTable .ensureFieldAccessorsInitialized( @@ -776,7 +776,7 @@ public final class Proto3AllTypes { } private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + com.google.protobuf.GeneratedMessage.BuilderParent parent) { super(parent); } @@ -1792,7 +1792,7 @@ public final class Proto3AllTypes { private static final com.google.protobuf.Descriptors.Descriptor internal_static_org_redisson_codec_protobuf_raw_AllTypes3_descriptor; private static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_org_redisson_codec_protobuf_raw_AllTypes3_fieldAccessorTable; public static com.google.protobuf.Descriptors.FileDescriptor @@ -1823,7 +1823,7 @@ public final class Proto3AllTypes { internal_static_org_redisson_codec_protobuf_raw_AllTypes3_descriptor = getDescriptor().getMessageTypes().get(0); internal_static_org_redisson_codec_protobuf_raw_AllTypes3_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_org_redisson_codec_protobuf_raw_AllTypes3_descriptor, new String[] { "DoubleType", "FloatType", "Int32Type", "Int64Type", "Uint32Type", "Uint64Type", "Sint32Type", "Sint64Type", "Fixed32Type", "Fixed64Type", "Sfixed32Type", "Sfixed64Type", "BoolType", "StringType", "BytesType", }); }