org.springframework.data.redis.connection.RedisClusterNode Java Examples
The following examples show how to use
org.springframework.data.redis.connection.RedisClusterNode.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TracingRedisClusterConnectionTest.java From java-redis-client with Apache License 2.0 | 5 votes |
@Test public void invokingClusterAddSlots() { commandCreatesNewSpan(RedisCommand.CLUSTER_ADDSLOTS, () -> getConnection().clusterAddSlots(mockRedisClusterNode, 0)); verify(mockRedisClusterConnection).clusterAddSlots(mockRedisClusterNode, 0); RedisClusterNode.SlotRange range = new RedisClusterNode.SlotRange(0, 1); commandCreatesNewSpan(RedisCommand.CLUSTER_ADDSLOTS, () -> getConnection().clusterAddSlots(mockRedisClusterNode, range)); verify(mockRedisConnection()).clusterAddSlots(mockRedisClusterNode, range); }
Example #2
Source File: RedissonClusterConnection.java From redisson with Apache License 2.0 | 5 votes |
@Override public Properties getConfig(RedisClusterNode node, String pattern) { MasterSlaveEntry entry = getEntry(node); RFuture<List<String>> f = executorService.writeAsync(entry, StringCodec.INSTANCE, RedisCommands.CONFIG_GET, pattern); List<String> r = syncFuture(f); if (r != null) { return Converters.toProperties(r); } return null; }
Example #3
Source File: TracingRedisClusterConnectionTest.java From java-redis-client with Apache License 2.0 | 5 votes |
@Test public void invokingClusterDeleteSlotsInRange() { RedisClusterNode.SlotRange range = RedisClusterNode.SlotRange.empty(); commandCreatesNewSpan(RedisCommand.CLUSTER_DELSLOTS, () -> getConnection().clusterDeleteSlotsInRange(mockRedisClusterNode, range)); verify(mockRedisConnection()).clusterDeleteSlotsInRange(mockRedisClusterNode, range); }
Example #4
Source File: RedissonClusterConnection.java From redisson with Apache License 2.0 | 5 votes |
@Override public RedisClusterNode clusterGetNodeForSlot(int slot) { Iterable<RedisClusterNode> res = clusterGetNodes(); for (RedisClusterNode redisClusterNode : res) { if (redisClusterNode.isMaster() && redisClusterNode.getSlotRange().contains(slot)) { return redisClusterNode; } } return null; }
Example #5
Source File: RedissonClusterConnection.java From redisson with Apache License 2.0 | 5 votes |
@Override public List<RedisClientInfo> getClientList(RedisClusterNode node) { MasterSlaveEntry entry = getEntry(node); RFuture<List<String>> f = executorService.readAsync(entry, StringCodec.INSTANCE, RedisCommands.CLIENT_LIST); List<String> list = syncFuture(f); return CONVERTER.convert(list.toArray(new String[list.size()])); }
Example #6
Source File: RedissonClusterConnectionTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testClusterGetMasterSlaveMap() { Map<RedisClusterNode, Collection<RedisClusterNode>> map = connection.clusterGetMasterSlaveMap(); assertThat(map).hasSize(3); for (Collection<RedisClusterNode> slaves : map.values()) { assertThat(slaves).hasSize(1); } }
Example #7
Source File: RedissonReactiveClusterServerCommands.java From redisson with Apache License 2.0 | 5 votes |
@Override public Flux<RedisClientInfo> getClientList(RedisClusterNode node) { MasterSlaveEntry entry = getEntry(node); Mono<List<String>> m = executorService.reactive(() -> { return executorService.readAsync(entry, StringCodec.INSTANCE, RedisCommands.CLIENT_LIST); }); return m.flatMapMany(s -> Flux.fromIterable(CONVERTER.convert(s.toArray(new String[s.size()])))); }
Example #8
Source File: RedissonReactiveClusterServerCommands.java From redisson with Apache License 2.0 | 5 votes |
@Override public Flux<RedisClientInfo> getClientList(RedisClusterNode node) { MasterSlaveEntry entry = getEntry(node); Mono<List<String>> m = executorService.reactive(() -> { return executorService.readAsync(entry, StringCodec.INSTANCE, RedisCommands.CLIENT_LIST); }); return m.flatMapMany(s -> Flux.fromIterable(CONVERTER.convert(s.toArray(new String[s.size()])))); }
Example #9
Source File: RedissonClusterConnection.java From redisson with Apache License 2.0 | 5 votes |
@Override public void clusterDeleteSlots(RedisClusterNode node, int... slots) { MasterSlaveEntry entry = getEntry(node); List<Integer> params = convert(slots); RFuture<Long> f = executorService.writeAsync(entry, StringCodec.INSTANCE, RedisCommands.CLUSTER_DELSLOTS, params.toArray()); syncFuture(f); }
Example #10
Source File: RedissonReactiveClusterKeyCommands.java From redisson with Apache License 2.0 | 5 votes |
@Override public Mono<ByteBuffer> randomKey(RedisClusterNode node) { MasterSlaveEntry entry = getEntry(node); Mono<byte[]> m = executorService.reactive(() -> { return executorService.readRandomAsync(entry, ByteArrayCodec.INSTANCE, RedisCommands.RANDOM_KEY); }); return m.map(v -> ByteBuffer.wrap(v)); }
Example #11
Source File: RedissonClusterConnection.java From redisson with Apache License 2.0 | 5 votes |
@Override public void clusterMeet(RedisClusterNode node) { Assert.notNull(node, "Cluster node must not be null for CLUSTER MEET command!"); Assert.hasText(node.getHost(), "Node to meet cluster must have a host!"); Assert.isTrue(node.getPort() > 0, "Node to meet cluster must have a port greater 0!"); RFuture<Void> f = executorService.writeAsync((String)null, StringCodec.INSTANCE, RedisCommands.CLUSTER_MEET, node.getHost(), node.getPort()); syncFuture(f); }
Example #12
Source File: RedissonClusterConnection.java From redisson with Apache License 2.0 | 5 votes |
@Override public RedisClusterNode clusterGetNodeForSlot(int slot) { Iterable<RedisClusterNode> res = clusterGetNodes(); for (RedisClusterNode redisClusterNode : res) { if (redisClusterNode.isMaster() && redisClusterNode.getSlotRange().contains(slot)) { return redisClusterNode; } } return null; }
Example #13
Source File: RedissonClusterConnection.java From redisson with Apache License 2.0 | 5 votes |
@Override public RedisClusterNode clusterGetNodeForSlot(int slot) { Iterable<RedisClusterNode> res = clusterGetNodes(); for (RedisClusterNode redisClusterNode : res) { if (redisClusterNode.isMaster() && redisClusterNode.getSlotRange().contains(slot)) { return redisClusterNode; } } return null; }
Example #14
Source File: RedissonClusterConnectionTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testClusterGetNodesMaster() { Iterable<RedisClusterNode> nodes = connection.clusterGetNodes(); for (RedisClusterNode redisClusterNode : nodes) { if (redisClusterNode.getType() == NodeType.MASTER) { Collection<RedisClusterNode> slaves = connection.clusterGetSlaves(redisClusterNode); assertThat(slaves).hasSize(1); } } }
Example #15
Source File: RedissonClusterConnectionTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testClusterGetMasterSlaveMap() { Map<RedisClusterNode, Collection<RedisClusterNode>> map = connection.clusterGetMasterSlaveMap(); assertThat(map).hasSize(3); for (Collection<RedisClusterNode> slaves : map.values()) { assertThat(slaves).hasSize(1); } }
Example #16
Source File: RedissonClusterConnection.java From redisson with Apache License 2.0 | 5 votes |
@Override public void clusterDeleteSlots(RedisClusterNode node, int... slots) { MasterSlaveEntry entry = getEntry(node); List<Integer> params = convert(slots); RFuture<Long> f = executorService.writeAsync(entry, StringCodec.INSTANCE, RedisCommands.CLUSTER_DELSLOTS, params.toArray()); syncFuture(f); }
Example #17
Source File: RedissonClusterConnectionTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testClusterAddRemoveSlots() { RedisClusterNode master = getFirstMaster(); Integer slot = master.getSlotRange().getSlots().iterator().next(); connection.clusterDeleteSlots(master, slot); connection.clusterAddSlots(master, slot); }
Example #18
Source File: RedissonClusterConnection.java From redisson with Apache License 2.0 | 4 votes |
@Override public void clusterSetSlot(RedisClusterNode node, int slot, AddSlots mode) { MasterSlaveEntry entry = getEntry(node); RFuture<Map<String, String>> f = executorService.writeAsync(entry, StringCodec.INSTANCE, RedisCommands.CLUSTER_SETSLOT, slot, mode); syncFuture(f); }
Example #19
Source File: TracingRedisClusterConnection.java From java-redis-client with Apache License 2.0 | 4 votes |
@Override public void clusterDeleteSlotsInRange(RedisClusterNode node, SlotRange range) { helper.doInScope(CLUSTER_DELSLOTS, () -> connection.clusterDeleteSlotsInRange(node, range)); }
Example #20
Source File: RedissonClusterConnection.java From redisson with Apache License 2.0 | 4 votes |
@Override public void bgReWriteAof(RedisClusterNode node) { execute(node, RedisCommands.BGREWRITEAOF); }
Example #21
Source File: TracingRedisClusterConnection.java From java-redis-client with Apache License 2.0 | 4 votes |
@Override public void clusterMeet(RedisClusterNode node) { helper.doInScope(CLUSTER_MEET, () -> connection.clusterMeet(node)); }
Example #22
Source File: RedissonClusterConnectionTest.java From redisson with Apache License 2.0 | 4 votes |
protected RedisClusterNode getFirstMaster() { Map<RedisClusterNode, Collection<RedisClusterNode>> map = connection.clusterGetMasterSlaveMap(); RedisClusterNode master = map.keySet().iterator().next(); return master; }
Example #23
Source File: RedissonClusterConnection.java From redisson with Apache License 2.0 | 4 votes |
@Override public Long dbSize(RedisClusterNode node) { return execute(node, RedisCommands.DBSIZE); }
Example #24
Source File: RedissonClusterConnection.java From redisson with Apache License 2.0 | 4 votes |
@Override public Long dbSize(RedisClusterNode node) { return execute(node, RedisCommands.DBSIZE); }
Example #25
Source File: RedissonClusterConnectionTest.java From redisson with Apache License 2.0 | 4 votes |
@Test public void testGetClientList() { RedisClusterNode master = getFirstMaster(); List<RedisClientInfo> list = connection.getClientList(master); assertThat(list.size()).isGreaterThan(10); }
Example #26
Source File: RedissonClusterConnection.java From redisson with Apache License 2.0 | 4 votes |
@Override public void clusterAddSlots(RedisClusterNode node, SlotRange range) { clusterAddSlots(node, range.getSlotsArray()); }
Example #27
Source File: RedissonClusterConnectionTest.java From redisson with Apache License 2.0 | 4 votes |
@Test public void testDbSize() { RedisClusterNode master = getFirstMaster(); Long size = connection.dbSize(master); assertThat(size).isZero(); }
Example #28
Source File: RedissonClusterConnection.java From redisson with Apache License 2.0 | 4 votes |
@Override public void clusterReplicate(RedisClusterNode master, RedisClusterNode slave) { MasterSlaveEntry entry = getEntry(master); RFuture<Long> f = executorService.writeAsync(entry, StringCodec.INSTANCE, RedisCommands.CLUSTER_REPLICATE, slave.getId()); syncFuture(f); }
Example #29
Source File: RedissonClusterConnection.java From redisson with Apache License 2.0 | 4 votes |
@Override public Long time(RedisClusterNode node) { MasterSlaveEntry entry = getEntry(node); RFuture<Long> f = executorService.readAsync(entry, LongCodec.INSTANCE, RedisCommands.TIME_LONG); return syncFuture(f); }
Example #30
Source File: RedissonClusterConnection.java From redisson with Apache License 2.0 | 4 votes |
@Override public Long dbSize(RedisClusterNode node) { return execute(node, RedisCommands.DBSIZE); }