use of io.lettuce.core.masterreplica.SentinelTopologyRefresh.PubSubMessageHandler in project lettuce-core by lettuce-io.
the class SentinelTopologyRefreshUnitTests method shouldProcessSlaveDown.
@Test
void shouldProcessSlaveDown() {
PubSubMessageHandler adapter = getMessageHandler();
sut.bind(refreshRunnable);
adapter.handle("*", "+sdown", "replica 127.0.0.1:6483 127.0.0.1 6483-2020 @ mymaster 127.0.0.1 6482");
verify(eventExecutors, times(1)).schedule(captor.capture(), anyLong(), any());
captor.getValue().run();
verify(refreshRunnable, times(1)).run();
}
use of io.lettuce.core.masterreplica.SentinelTopologyRefresh.PubSubMessageHandler in project lettuce-core by lettuce-io.
the class SentinelTopologyRefreshUnitTests method shouldProcessSwitchMaster.
@Test
void shouldProcessSwitchMaster() {
PubSubMessageHandler adapter = getMessageHandler();
sut.bind(refreshRunnable);
adapter.handle("*", "+switch-master", "mymaster 127.0.0.1");
verify(eventExecutors, times(1)).schedule(captor.capture(), anyLong(), any());
captor.getValue().run();
verify(refreshRunnable, times(1)).run();
}
use of io.lettuce.core.masterreplica.SentinelTopologyRefresh.PubSubMessageHandler in project lettuce-core by lettuce-io.
the class SentinelTopologyRefreshUnitTests method shouldProcessConvertToSlave.
@Test
void shouldProcessConvertToSlave() {
PubSubMessageHandler adapter = getMessageHandler();
sut.bind(refreshRunnable);
adapter.handle("*", "+convert-to-slave", "@ mymaster 127.0.0.1");
verify(eventExecutors, times(1)).schedule(captor.capture(), anyLong(), any());
captor.getValue().run();
verify(refreshRunnable, times(1)).run();
}
use of io.lettuce.core.masterreplica.SentinelTopologyRefresh.PubSubMessageHandler in project lettuce-core by lettuce-io.
the class SentinelTopologyRefreshUnitTests method shouldNotProcessIfExecutorIsShuttingDown.
@Test
void shouldNotProcessIfExecutorIsShuttingDown() {
PubSubMessageHandler adapter = getMessageHandler();
sut.bind(refreshRunnable);
when(eventExecutors.isShuttingDown()).thenReturn(true);
adapter.handle("*", "failover-end-for-timeout", "");
verify(redisClient).connectPubSubAsync(any(), any());
verify(eventExecutors, never()).schedule(any(Runnable.class), anyLong(), any());
}
use of io.lettuce.core.masterreplica.SentinelTopologyRefresh.PubSubMessageHandler in project lettuce-core by lettuce-io.
the class SentinelTopologyRefreshUnitTests method bindWithSentinelRecovery.
@Test
void bindWithSentinelRecovery() {
StatefulRedisPubSubConnection<String, String> connection2 = mock(StatefulRedisPubSubConnection.class);
RedisPubSubAsyncCommands<String, String> async2 = mock(RedisPubSubAsyncCommands.class);
when(connection2.async()).thenReturn(async2);
AsyncCommand<String, String, Void> command = new AsyncCommand<>(new Command<>(CommandType.PSUBSCRIBE, null));
command.complete();
when(async2.psubscribe(anyString())).thenReturn(command);
sut = new SentinelTopologyRefresh(redisClient, "mymaster", Arrays.asList(host1, host2));
when(redisClient.connectPubSubAsync(any(StringCodec.class), eq(host2))).thenReturn(ConnectionFuture.from(null, Futures.failed(new RedisConnectionException("err")))).thenReturn(ConnectionFuture.completed(null, connection2));
sut.bind(refreshRunnable);
verify(redisClient).connectPubSubAsync(any(), eq(host1));
verify(redisClient).connectPubSubAsync(any(), eq(host2));
Map<RedisURI, StatefulRedisPubSubConnection<String, String>> connections = (Map) ReflectionTestUtils.getField(sut, "pubSubConnections");
PubSubMessageHandler adapter = getMessageHandler();
adapter.handle("*", "+sentinel", "sentinel c14cc895bb0479c91312cee0e0440b7d99ad367b 127.0.0.1 26380 @ mymaster 127.0.0.1 6483");
verify(eventExecutors, times(1)).schedule(captor.capture(), anyLong(), any());
captor.getValue().run();
verify(redisClient, times(2)).connectPubSubAsync(any(), eq(host2));
assertThat(connections).containsKey(host1).containsKey(host2).hasSize(2);
verify(refreshRunnable, never()).run();
}
Aggregations