use of io.lettuce.core.models.role.RedisNodeDescription in project LinkAgent by shulieTech.
the class MasterSlaveTopologyRefreshGetconnectionInteceptor method doBefore.
@Override
public void doBefore(Advice advice) throws Throwable {
try {
Iterable<RedisNodeDescription> iterable = (Iterable) advice.getParameterArray()[0];
Iterator iterator = iterable.iterator();
while (iterator.hasNext()) {
RedisNodeDescription next = (RedisNodeDescription) iterator.next();
RedisURI uri = next.getUri();
LettuceUtils.cachePressureNode(uri);
}
} catch (Throwable t) {
logger.error(Throwables.getStackTraceAsString(t));
}
}
use of io.lettuce.core.models.role.RedisNodeDescription in project lettuce-core by lettuce-io.
the class MasterReplicaTopologyProviderUnitTests method shouldParseMaster.
@Test
void shouldParseMaster() {
String info = "# Replication\r\n" + "role:master\r\n" + "connected_slaves:1\r\n" + "master_repl_offset:56276\r\n" + "repl_backlog_active:1\r\n";
List<RedisNodeDescription> result = sut.getNodesFromInfo(info);
assertThat(result).hasSize(1);
RedisNodeDescription redisNodeDescription = result.get(0);
assertThat(redisNodeDescription.getRole().isUpstream()).isTrue();
assertThat(redisNodeDescription.getUri().getHost()).isEqualTo(TestSettings.host());
assertThat(redisNodeDescription.getUri().getPort()).isEqualTo(TestSettings.port());
}
use of io.lettuce.core.models.role.RedisNodeDescription in project lettuce-core by lettuce-io.
the class MasterReplicaTopologyProviderUnitTests method shouldParseMasterAndReplica.
@Test
void shouldParseMasterAndReplica() {
String info = "# Replication\r\n" + "role:slave\r\n" + "connected_slaves:1\r\n" + "master_host:127.0.0.1\r\n" + "master_port:1234\r\n" + "master_repl_offset:56276\r\n" + "repl_backlog_active:1\r\n";
List<RedisNodeDescription> result = sut.getNodesFromInfo(info);
assertThat(result).hasSize(2);
RedisNodeDescription replica = result.get(0);
assertThat(replica.getRole().isReplica()).isTrue();
RedisNodeDescription upstream = result.get(1);
assertThat(upstream.getRole().isUpstream()).isTrue();
assertThat(upstream.getUri().getHost()).isEqualTo("127.0.0.1");
}
use of io.lettuce.core.models.role.RedisNodeDescription in project lettuce-core by lettuce-io.
the class MasterReplicaTopologyProviderUnitTests method shouldParseReplicas.
@Test
void shouldParseReplicas() {
String info = "# Replication\r\n" + "role:master\r\n" + "slave0:ip=127.0.0.1,port=6483,state=online,offset=56276,lag=0\r\n" + "slave1:ip=127.0.0.1,port=6484,state=online,offset=56276,lag=0\r\n" + "master_repl_offset:56276\r\n" + "repl_backlog_active:1\r\n";
List<RedisNodeDescription> result = sut.getNodesFromInfo(info);
assertThat(result).hasSize(3);
RedisNodeDescription replica1 = result.get(1);
assertThat(replica1.getRole()).isEqualTo(RedisInstance.Role.SLAVE);
assertThat(replica1.getUri().getHost()).isEqualTo("127.0.0.1");
assertThat(replica1.getUri().getPort()).isEqualTo(6483);
RedisNodeDescription replica2 = result.get(2);
assertThat(replica2.getRole()).isEqualTo(RedisInstance.Role.SLAVE);
assertThat(replica2.getUri().getHost()).isEqualTo("127.0.0.1");
assertThat(replica2.getUri().getPort()).isEqualTo(6484);
}
use of io.lettuce.core.models.role.RedisNodeDescription in project lettuce-core by lettuce-io.
the class MasterReplicaTopologyProviderUnitTests method shouldParseIPv6UpstreamAddress.
@Test
void shouldParseIPv6UpstreamAddress() {
String info = "# Replication\r\n" + "role:slave\r\n" + "connected_slaves:1\r\n" + "master_host:::20f8:1400:0:0\r\n" + "master_port:1234\r\n" + "master_repl_offset:56276\r\n" + "repl_backlog_active:1\r\n";
List<RedisNodeDescription> result = sut.getNodesFromInfo(info);
assertThat(result).hasSize(2);
RedisNodeDescription replica = result.get(0);
assertThat(replica.getRole().isReplica()).isTrue();
RedisNodeDescription upstream = result.get(1);
assertThat(upstream.getRole().isUpstream()).isTrue();
assertThat(upstream.getUri().getHost()).isEqualTo("::20f8:1400:0:0");
}
Aggregations