|
|
@ -142,8 +142,6 @@ public class MasterSlaveConnectionManager implements ConnectionManager {
|
|
|
|
|
|
|
|
|
|
|
|
private final ConnectionEventsHub connectionEventsHub = new ConnectionEventsHub();
|
|
|
|
private final ConnectionEventsHub connectionEventsHub = new ConnectionEventsHub();
|
|
|
|
|
|
|
|
|
|
|
|
private final AsyncSemaphore[] locks = new AsyncSemaphore[50];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final ExecutorService executor;
|
|
|
|
private final ExecutorService executor;
|
|
|
|
|
|
|
|
|
|
|
|
private final CommandSyncService commandExecutor;
|
|
|
|
private final CommandSyncService commandExecutor;
|
|
|
@ -156,12 +154,6 @@ public class MasterSlaveConnectionManager implements ConnectionManager {
|
|
|
|
|
|
|
|
|
|
|
|
private final Map<Object, RedisConnection> nodeConnections = PlatformDependent.newConcurrentHashMap();
|
|
|
|
private final Map<Object, RedisConnection> nodeConnections = PlatformDependent.newConcurrentHashMap();
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
for (int i = 0; i < locks.length; i++) {
|
|
|
|
|
|
|
|
locks[i] = new AsyncSemaphore(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public MasterSlaveConnectionManager(MasterSlaveServersConfig cfg, Config config, UUID id) {
|
|
|
|
public MasterSlaveConnectionManager(MasterSlaveServersConfig cfg, Config config, UUID id) {
|
|
|
|
this(config, id);
|
|
|
|
this(config, id);
|
|
|
|
this.config = cfg;
|
|
|
|
this.config = cfg;
|
|
|
@ -186,7 +178,7 @@ public class MasterSlaveConnectionManager implements ConnectionManager {
|
|
|
|
} else if (cfg.getTransportMode() == TransportMode.KQUEUE) {
|
|
|
|
} else if (cfg.getTransportMode() == TransportMode.KQUEUE) {
|
|
|
|
if (cfg.getEventLoopGroup() == null) {
|
|
|
|
if (cfg.getEventLoopGroup() == null) {
|
|
|
|
this.group = new KQueueEventLoopGroup(cfg.getNettyThreads(), new DefaultThreadFactory("redisson-netty"));
|
|
|
|
this.group = new KQueueEventLoopGroup(cfg.getNettyThreads(), new DefaultThreadFactory("redisson-netty"));
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
this.group = cfg.getEventLoopGroup();
|
|
|
|
this.group = cfg.getEventLoopGroup();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -219,6 +211,19 @@ public class MasterSlaveConnectionManager implements ConnectionManager {
|
|
|
|
this.commandExecutor = new CommandSyncService(this);
|
|
|
|
this.commandExecutor = new CommandSyncService(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* Remove it once https://github.com/netty/netty/issues/7882 get resolved
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
protected DnsAddressResolverGroup createResolverGroup() {
|
|
|
|
|
|
|
|
if (cfg.getTransportMode() == TransportMode.EPOLL) {
|
|
|
|
|
|
|
|
return cfg.getAddressResolverGroupFactory().create(EpollDatagramChannel.class, DnsServerAddressStreamProviders.platformDefault());
|
|
|
|
|
|
|
|
} else if (cfg.getTransportMode() == TransportMode.KQUEUE) {
|
|
|
|
|
|
|
|
return cfg.getAddressResolverGroupFactory().create(KQueueDatagramChannel.class, DnsServerAddressStreamProviders.platformDefault());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return cfg.getAddressResolverGroupFactory().create(NioDatagramChannel.class, DnsServerAddressStreamProviders.platformDefault());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected void closeNodeConnections() {
|
|
|
|
protected void closeNodeConnections() {
|
|
|
|
List<RFuture<Void>> futures = new ArrayList<RFuture<Void>>();
|
|
|
|
List<RFuture<Void>> futures = new ArrayList<RFuture<Void>>();
|
|
|
|
for (RedisConnection connection : nodeConnections.values()) {
|
|
|
|
for (RedisConnection connection : nodeConnections.values()) {
|
|
|
@ -499,7 +504,7 @@ public class MasterSlaveConnectionManager implements ConnectionManager {
|
|
|
|
for (MasterSlaveEntry entry : client2entry.values()) {
|
|
|
|
for (MasterSlaveEntry entry : client2entry.values()) {
|
|
|
|
if (URIBuilder.compare(entry.getClient().getAddr(), addr)) {
|
|
|
|
if (URIBuilder.compare(entry.getClient().getAddr(), addr)) {
|
|
|
|
return entry;
|
|
|
|
return entry;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (entry.hasSlave(addr)) {
|
|
|
|
if (entry.hasSlave(addr)) {
|
|
|
|
return entry;
|
|
|
|
return entry;
|
|
|
|
}
|
|
|
|
}
|
|
|
|