Merge branch 'master' into 3.0.0

pull/1303/head
Nikita 7 years ago
commit 8f1c3202e3

@ -68,14 +68,16 @@ Used by
[![OptionsHouse](https://redisson.org/assets/logos/client9.png "OptionsHouse")](https://www.optionshouse.com/)    
[![Invaluable](https://redisson.org/assets/logos/client13.png "Invaluable")](http://www.invaluable.com/)
[![Ticketmaster](https://redisson.org/assets/logos/client14.png "Ticketmaster")](http://www.ticketmaster.com/)   
[![PANDORA](https://redisson.org/assets/logos/client15.png "PANDORA")](http://www.pandora.com/)
[![PANDORA](https://redisson.org/assets/logos/client15.png "PANDORA")](http://www.pandora.com/)   
[![ContaAzul](https://redisson.org/assets/logos/client18.png "ContaAzul")](https://contaazul.com/)
[![SULAKE](https://redisson.org/assets/logos/client17.png "SULAKE")](http://www.sulake.com/)
Success stories
================================
[Moving from Hazelcast to Redis](https://engineering.datorama.com/moving-from-hazelcast-to-redis-b90a0769d1cb)
[Moving from Hazelcast to Redis / Datorama](https://engineering.datorama.com/moving-from-hazelcast-to-redis-b90a0769d1cb)
[Distributed Locking with Redis (Migration from Hazelcast) / ContaAzul](https://carlosbecker.com/posts/distributed-locks-redis/)
Quick start
===============================

@ -228,10 +228,11 @@ public class RedissonMapCache<K, V> extends RedissonMap<K, V> implements RMapCac
"local expireHead = redis.call('zrange', KEYS[2], 0, 0, 'withscores'); " +
"local currentTime = tonumber(table.remove(ARGV, 1)); " + // index is the first parameter
"local hasExpire = #expireHead == 2 and tonumber(expireHead[2]) <= currentTime; " +
"local map = redis.call('hmget', KEYS[1], unpack(ARGV)); " +
"local maxSize = tonumber(redis.call('hget', KEYS[5], 'max-size'));" +
"for i = #map, 1, -1 do " +
" local value = map[i]; " +
"local map = {}; " +
"for i = 1, #ARGV, 1 do " +
" local value = redis.call('hget', KEYS[1], ARGV[i]); " +
" map[i] = false;" +
" if value ~= false then " +
" local key = ARGV[i]; " +
" local t, val = struct.unpack('dLc0', value); " +

@ -57,7 +57,7 @@ public class RedisClient {
private final Bootstrap bootstrap;
private final Bootstrap pubSubBootstrap;
private final InetSocketAddress addr;
private final ChannelGroup channels = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);
private final ChannelGroup channels;
private ExecutorService executor;
private final long commandTimeout;
@ -81,6 +81,7 @@ public class RedisClient {
bootstrap = createBootstrap(config, Type.PLAIN);
pubSubBootstrap = createBootstrap(config, Type.PUBSUB);
channels = new DefaultChannelGroup(config.getGroup().next());
this.commandTimeout = config.getCommandTimeout();
}
@ -171,6 +172,7 @@ public class RedisClient {
bootstrap = createBootstrap(config, Type.PLAIN);
pubSubBootstrap = createBootstrap(config, Type.PUBSUB);
channels = new DefaultChannelGroup(config.getGroup().next());
this.commandTimeout = config.getCommandTimeout();
}

@ -1,48 +0,0 @@
/**
* Copyright 2016 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 java.util.List;
import org.redisson.client.handler.State;
import io.netty.buffer.ByteBuf;
import io.netty.util.CharsetUtil;
/**
*
* @author Nikita Koksharov
*
* @param <T> type
*/
public class TTLMapValueReplayDecoder<T> implements MultiDecoder<List<T>> {
@Override
public Object decode(ByteBuf buf, State state) {
return Long.valueOf(buf.toString(CharsetUtil.UTF_8));
}
@Override
public List<T> decode(List<Object> parts, State state) {
return (List<T>) parts;
}
@Override
public boolean isApplicable(int paramNum, State state) {
return paramNum == 0;
}
}

@ -56,7 +56,6 @@ import org.slf4j.LoggerFactory;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.FutureListener;
import io.netty.util.concurrent.GlobalEventExecutor;
import io.netty.util.concurrent.ScheduledFuture;
import io.netty.util.internal.PlatformDependent;
@ -298,7 +297,7 @@ public class ClusterConnectionManager extends MasterSlaveConnectionManager {
}
private void scheduleClusterChangeCheck(final ClusterServersConfig cfg, final Iterator<URI> iterator) {
monitorFuture = GlobalEventExecutor.INSTANCE.schedule(new Runnable() {
monitorFuture = group.schedule(new Runnable() {
@Override
public void run() {
AtomicReference<Throwable> lastException = new AtomicReference<Throwable>();

@ -30,7 +30,6 @@ import org.redisson.misc.URIBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.netty.util.concurrent.GlobalEventExecutor;
import io.netty.util.concurrent.ScheduledFuture;
/**
@ -83,7 +82,7 @@ public class DNSMonitor {
}
private void monitorDnsChange() {
dnsMonitorFuture = GlobalEventExecutor.INSTANCE.schedule(new Runnable() {
dnsMonitorFuture = connectionManager.getGroup().schedule(new Runnable() {
@Override
public void run() {
// As InetAddress.getByName call is blocking. Method should be run in dedicated thread

@ -39,7 +39,6 @@ import org.slf4j.LoggerFactory;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.FutureListener;
import io.netty.util.concurrent.GlobalEventExecutor;
import io.netty.util.concurrent.ScheduledFuture;
/**
@ -145,7 +144,7 @@ public class ReplicatedConnectionManager extends MasterSlaveConnectionManager {
}
private void scheduleMasterChangeCheck(final ReplicatedServersConfig cfg) {
monitorFuture = GlobalEventExecutor.INSTANCE.schedule(new Runnable() {
monitorFuture = group.schedule(new Runnable() {
@Override
public void run() {
final URI master = currentMaster.get();

@ -1,69 +0,0 @@
/**
* Copyright 2016 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.connection.decoder;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.redisson.client.codec.LongCodec;
import org.redisson.client.handler.State;
import org.redisson.client.protocol.decoder.MultiDecoder;
import io.netty.buffer.ByteBuf;
/**
*
* @author Nikita Koksharov
*
*/
public class CacheGetAllDecoder implements MultiDecoder<List<Object>> {
private final List<Object> args;
public CacheGetAllDecoder(List<Object> args) {
this.args = args;
}
@Override
public Object decode(ByteBuf buf, State state) throws IOException {
return LongCodec.INSTANCE.getValueDecoder().decode(buf, state);
}
@Override
public boolean isApplicable(int paramNum, State state) {
return paramNum == 0;
}
@Override
public List<Object> decode(List<Object> parts, State state) {
List<Object> result = new ArrayList<Object>();
Map<Object, Object> map = new HashMap<Object, Object>(parts.size());
for (int index = 0; index < args.size()-1; index++) {
Object value = parts.get(index+1);
if (value == null) {
continue;
}
map.put(args.get(index+1), value);
}
result.add(parts.get(0));
result.add(map);
return result;
}
}

@ -403,6 +403,23 @@ public class RedissonMapCacheTest extends BaseMapTest {
assertThat(map.values()).containsOnly("5678");
}
@Test
public void testGetAllBig() {
Map<Integer, String> joinMap = new HashMap<Integer, String>();
for (int i = 0; i < 10000; i++) {
joinMap.put(i, "" + i);
}
RMap<Integer, String> map = redisson.getMapCache("simple");
map.putAll(joinMap);
Map<Integer, String> s = map.getAll(joinMap.keySet());
assertThat(s).isEqualTo(joinMap);
assertThat(map.size()).isEqualTo(joinMap.size());
}
@Test
public void testGetAll() throws InterruptedException {
RMapCache<Integer, Integer> map = redisson.getMapCache("getAll");

Loading…
Cancel
Save