Search in sources :

Example 1 with RedisAdvancedClusterCommands

use of io.lettuce.core.cluster.api.sync.RedisAdvancedClusterCommands in project hazelcast-simulator by hazelcast.

the class StringStringSyncTest method loadInitialData.

// loading the data is very inefficient. Needs some work in the future
@Prepare(global = true)
public void loadInitialData() {
    Random random = new Random();
    StatefulRedisClusterConnection<String, String> connection = redisClient.connect();
    RedisAdvancedClusterCommands sync = connection.sync();
    // get rid of all data.
    sync.flushall();
    for (int k = 0; k < keyDomain; k++) {
        int r = random.nextInt(valueCount);
        sync.set(Long.toString(k), values[r]);
    }
// connection.async().set()
}
Also used : Random(java.util.Random) RedisAdvancedClusterCommands(io.lettuce.core.cluster.api.sync.RedisAdvancedClusterCommands) Prepare(com.hazelcast.simulator.test.annotations.Prepare)

Example 2 with RedisAdvancedClusterCommands

use of io.lettuce.core.cluster.api.sync.RedisAdvancedClusterCommands in project lettuce-core by lettuce-io.

the class TopologyRefreshIntegrationTests method runReconnectTest.

private void runReconnectTest(BiFunction<RedisAdvancedClusterAsyncCommands<String, String>, RedisClusterNode, BaseRedisAsyncCommands> function) {
    ClusterTopologyRefreshOptions topologyRefreshOptions = // 
    ClusterTopologyRefreshOptions.builder().refreshTriggersReconnectAttempts(// 
    0).enableAllAdaptiveRefreshTriggers().build();
    clusterClient.setOptions(ClusterClientOptions.builder().topologyRefreshOptions(topologyRefreshOptions).build());
    RedisAdvancedClusterAsyncCommands<String, String> clusterConnection = clusterClient.connect().async();
    RedisClusterNode node = clusterClient.getPartitions().getPartition(0);
    BaseRedisAsyncCommands closeable = function.apply(clusterConnection, node);
    clusterClient.getPartitions().clear();
    closeable.quit();
    Wait.untilTrue(() -> {
        return !clusterClient.getPartitions().isEmpty();
    }).waitOrTimeout();
    if (closeable instanceof RedisAdvancedClusterCommands) {
        ((RedisAdvancedClusterCommands) closeable).getStatefulConnection().close();
    }
    clusterConnection.getStatefulConnection().close();
}
Also used : RedisClusterNode(io.lettuce.core.cluster.models.partitions.RedisClusterNode) RedisAdvancedClusterCommands(io.lettuce.core.cluster.api.sync.RedisAdvancedClusterCommands) ClusterTopologyRefreshOptions(io.lettuce.core.cluster.ClusterTopologyRefreshOptions) BaseRedisAsyncCommands(io.lettuce.core.api.async.BaseRedisAsyncCommands)

Aggregations

RedisAdvancedClusterCommands (io.lettuce.core.cluster.api.sync.RedisAdvancedClusterCommands)2 Prepare (com.hazelcast.simulator.test.annotations.Prepare)1 BaseRedisAsyncCommands (io.lettuce.core.api.async.BaseRedisAsyncCommands)1 ClusterTopologyRefreshOptions (io.lettuce.core.cluster.ClusterTopologyRefreshOptions)1 RedisClusterNode (io.lettuce.core.cluster.models.partitions.RedisClusterNode)1 Random (java.util.Random)1