io.lettuce.core.RedisFuture Java Examples

The following examples show how to use io.lettuce.core.RedisFuture. 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: LettuceAsyncService.java    From uavstack with Apache License 2.0 6 votes vote down vote up
@Override
public Object send(String[] params) {
    // 同步异步都需要返回结果
    LettuceCommandResult lcr = new LettuceCommandResult();
    RedisAdvancedClusterAsyncCommands<String, String> commands = connect.async();
    RedisFuture<String> resultSync = commands.get(params[0]);
    String result = null;
    try {
        result = resultSync.get(expireTimeLong, TimeUnit.SECONDS);
        lcr.setResult(result);
        lcr.setRunState(true);
    }
    catch (Exception e) {
        lcr.setRunState(false);
    }

    return lcr;
}
 
Example #2
Source File: LettuceJobMetadataAccessor.java    From sherlock with GNU General Public License v3.0 6 votes vote down vote up
@Override
public List<JobMetadata> getRunningJobsAssociatedWithCluster(String clusterId) throws IOException {
    log.info("Getting running jobs associated with cluster [{}]", clusterId);
    try (RedisConnection<String> conn = connect()) {
        AsyncCommands<String> cmd = conn.async();
        cmd.setAutoFlushCommands(false);
        RedisFuture<Set<String>> running = cmd.smembers(index(jobStatusName, JobStatus.RUNNING.getValue()));
        RedisFuture<Set<String>> cluster = cmd.smembers(index(clusterIdName, clusterId));
        cmd.flushCommands();
        await(running, cluster);
        Set<String> ids = running.get();
        ids.retainAll(cluster.get());
        return getJobMetadata(ids);
    } catch (InterruptedException | ExecutionException e) {
        log.error("Error while getting jobs!", e);
        throw new IOException(e.getMessage(), e);
    }
}
 
Example #3
Source File: TracingRedisAsyncCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
@Deprecated
public RedisFuture<List<ScoredValue<V>>> zrevrangebyscoreWithScores(
    K key, double max, double min) {
  Span span = helper.buildSpan("zrevrangebyscoreWithScores", key);
  span.setTag("max", max);
  span.setTag("min", min);
  return prepareRedisFuture(commands.zrevrangebyscoreWithScores(key, max, min), span);
}
 
Example #4
Source File: TracingRedisAsyncCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public RedisFuture<Long> georadiusbymember(K key, V member, double distance,
    Unit unit, GeoRadiusStoreArgs<K> geoRadiusStoreArgs) {
  Span span = helper.buildSpan("georadiusbymember", key);
  span.setTag("unit", nullable(unit));
  span.setTag("distance", distance);
  return prepareRedisFuture(
      commands.georadiusbymember(key, member, distance, unit, geoRadiusStoreArgs), span);
}
 
Example #5
Source File: TracingRedisAdvancedClusterAsyncCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
@Deprecated
public RedisFuture<Long> zremrangebyscore(K key, String min, String max) {
  Span span = helper.buildSpan("zremrangebyscore", key);
  span.setTag("min", min);
  span.setTag("max", max);
  return prepareRedisFuture(commands.zremrangebyscore(key, min, max), span);
}
 
Example #6
Source File: TracingRedisAsyncCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public RedisFuture<Long> bitcount(K key, long start, long end) {
  Span span = helper.buildSpan("bitcount", key);
  span.setTag("start", start);
  span.setTag("end", end);
  return prepareRedisFuture(commands.bitcount(key, start, end), span);
}
 
Example #7
Source File: TracingRedisAsyncCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
@Deprecated
public RedisFuture<Long> zremrangebyscore(K key, double min, double max) {
  Span span = helper.buildSpan("zremrangebyscore", key);
  span.setTag("min", min);
  span.setTag("max", max);
  return prepareRedisFuture(commands.zremrangebyscore(key, min, max), span);
}
 
Example #8
Source File: TracingRedisAsyncCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public RedisFuture<String> migrate(String host, int port, K key, int db,
    long timeout) {
  Span span = helper.buildSpan("migrate", key);
  span.setTag("host", host);
  span.setTag("port", port);
  span.setTag("db", db);
  span.setTag("timeout", timeout);
  return prepareRedisFuture(commands.migrate(host, port, key, db, timeout), span);
}
 
Example #9
Source File: TracingRedisAdvancedClusterAsyncCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
@Deprecated
public RedisFuture<Long> zrevrangebyscore(
    ValueStreamingChannel<V> channel, K key, double max, double min,
    long offset, long count) {
  Span span = helper.buildSpan("zrevrangebyscore", key);
  span.setTag("max", max);
  span.setTag("min", min);
  span.setTag("offset", offset);
  span.setTag("count", count);
  return prepareRedisFuture(commands.zrevrangebyscore(channel, key, max, min, offset, count),
      span);
}
 
Example #10
Source File: TracingRedisAdvancedClusterAsyncCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
@Deprecated
public RedisFuture<Long> zrevrangebyscoreWithScores(
    ScoredValueStreamingChannel<V> channel, K key, String max,
    String min, long offset, long count) {
  Span span = helper.buildSpan("zrevrangebyscoreWithScores", key);
  span.setTag("max", max);
  span.setTag("min", min);
  span.setTag("offset", offset);
  span.setTag("count", count);
  return prepareRedisFuture(
      commands.zrevrangebyscoreWithScores(channel, key, max, min, offset, count), span);
}
 
Example #11
Source File: LettuceJsonDumper.java    From sherlock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Method to write anomaly timestamps from ({@link com.yahoo.sherlock.model.AnomalyReport}) to redis.
 * @param anomalyTimestamps map : key - redis key, value - list of timestamps as {@link io.lettuce.core.ScoredValue}
 */
public void writeAnomalyTimestampsToRedis(Map<String, List<ScoredValue<byte[]>>> anomalyTimestamps) {
    RedisConnection<byte[]> conn = binary();
    List<RedisFuture> futures = new LinkedList<>();
    AsyncCommands<byte[]> cmd = conn.async();
    cmd.setAutoFlushCommands(false);
    log.info("Adding {} anomaly timestamps to redis", anomalyTimestamps.size());
    for (Map.Entry<String, List<ScoredValue<byte[]>>> anomalyTimestamp : anomalyTimestamps.entrySet()) {
        futures.add(cmd.zadd(encode(anomalyTimestamp.getKey()), anomalyTimestamp.getValue().toArray(new ScoredValue[anomalyTimestamp.getValue().size()])));
        futures.add(cmd.expire(encode(anomalyTimestamp.getKey()), expirationTime));
    }
    cmd.flushCommands();
    awaitRaw(futures);
    log.info("Added all anomaly timestamps to redis");
}
 
Example #12
Source File: TracingRedisAsyncCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public RedisFuture<String> swapdb(int db1, int db2) {
  Span span = helper.buildSpan("swapdb");
  span.setTag("db1", db1);
  span.setTag("db2", db2);
  return prepareRedisFuture(commands.swapdb(db1, db2), span);
}
 
Example #13
Source File: TracingRedisAsyncCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
@Deprecated
public RedisFuture<List<ScoredValue<V>>> zrangebyscoreWithScores(
    K key, double min, double max) {
  Span span = helper.buildSpan("zrangebyscoreWithScores", key);
  span.setTag("min", min);
  span.setTag("max", max);
  return prepareRedisFuture(commands.zrangebyscoreWithScores(key, min, max), span);
}
 
Example #14
Source File: TracingRedisAsyncCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public RedisFuture<StreamScanCursor> zscan(
    ScoredValueStreamingChannel<V> channel, K key,
    ScanCursor scanCursor) {
  Span span = helper.buildSpan("zscan", key);
  return prepareRedisFuture(commands.zscan(channel, key, scanCursor), span);
}
 
Example #15
Source File: TracingRedisAdvancedClusterAsyncCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public RedisFuture<Long> zrevrangebyscoreWithScores(
    ScoredValueStreamingChannel<V> channel, K key,
    Range<? extends Number> range, Limit limit) {
  Span span = helper.buildSpan("zrevrangebyscoreWithScores", key);
  span.setTag("range", nullable(range));
  span.setTag("limit", nullable(limit));
  return prepareRedisFuture(commands.zrevrangebyscoreWithScores(channel, key, range, limit),
      span);
}
 
Example #16
Source File: TracingRedisAsyncCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
@Deprecated
public RedisFuture<Long> zcount(K key, String min, String max) {
  Span span = helper.buildSpan("zcount", key);
  span.setTag("min", min);
  span.setTag("max", max);
  return prepareRedisFuture(commands.zcount(key, min, max), span);
}
 
Example #17
Source File: TracingRedisAdvancedClusterAsyncCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public RedisFuture<List<ScoredValue<V>>> zrangeWithScores(
    K key, long start, long stop) {
  Span span = helper.buildSpan("zrangeWithScores", key);
  span.setTag("start", start);
  span.setTag("stop", stop);
  return prepareRedisFuture(commands.zrangeWithScores(key, start, stop), span);
}
 
Example #18
Source File: TracingRedisAsyncCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public RedisFuture<List<V>> zrangebyscore(K key,
    Range<? extends Number> range) {
  Span span = helper.buildSpan("zrangebyscore", key);
  span.setTag("range", nullable(range));
  return prepareRedisFuture(commands.zrangebyscore(key, range), span);
}
 
Example #19
Source File: TracingRedisAsyncCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public RedisFuture<List<V>> zrevrangebylex(K key,
    Range<? extends V> range) {
  Span span = helper.buildSpan("zrevrangebylex", key);
  span.setTag("range", nullable(range));
  return prepareRedisFuture(commands.zrevrangebylex(key, range), span);
}
 
Example #20
Source File: TracingRedisAdvancedClusterAsyncCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public RedisFuture<String> migrate(String host, int port, K key, int db,
    long timeout) {
  Span span = helper.buildSpan("migrate", key);
  span.setTag("host", host);
  span.setTag("port", port);
  span.setTag("db", db);
  span.setTag("timeout", timeout);
  return prepareRedisFuture(commands.migrate(host, port, key, db, timeout), span);
}
 
Example #21
Source File: TracingRedisAsyncCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
@Deprecated
public RedisFuture<Long> zremrangebylex(K key, String min, String max) {
  Span span = helper.buildSpan("zremrangebylex", key);
  span.setTag("min", min);
  span.setTag("max", max);
  return prepareRedisFuture(commands.zremrangebylex(key, min, max), span);
}
 
Example #22
Source File: TracingRedisAdvancedClusterAsyncCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
@Deprecated
public RedisFuture<List<ScoredValue<V>>> zrevrangebyscoreWithScores(
    K key, double max, double min) {
  Span span = helper.buildSpan("zrevrangebyscoreWithScores", key);
  span.setTag("max", max);
  span.setTag("min", min);
  return prepareRedisFuture(commands.zrevrangebyscoreWithScores(key, max, min), span);
}
 
Example #23
Source File: TracingRedisAdvancedClusterAsyncCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public RedisFuture<List<StreamMessage<K, V>>> xrevrange(K key, Range<String> range, Limit limit) {
  Span span = helper.buildSpan("xrevrange", key);
  span.setTag("range", nullable(range));
  span.setTag("limit", nullable(limit));
  return prepareRedisFuture(commands.xrevrange(key, range, limit), span);
}
 
Example #24
Source File: TracingRedisAdvancedClusterAsyncCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public RedisFuture<Set<V>> georadius(K key, double longitude,
    double latitude, double distance, Unit unit) {
  Span span = helper.buildSpan("georadius", key);
  span.setTag("longitude", longitude);
  span.setTag("latitude", latitude);
  span.setTag("unit", nullable(unit));
  span.setTag("distance", distance);
  return prepareRedisFuture(commands.georadius(key, longitude, latitude, distance, unit), span);
}
 
Example #25
Source File: TracingRedisAsyncCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
@Deprecated
public RedisFuture<Long> zrangebyscoreWithScores(
    ScoredValueStreamingChannel<V> channel, K key, String min,
    String max, long offset, long count) {
  Span span = helper.buildSpan("zrangebyscoreWithScores", key);
  span.setTag("min", min);
  span.setTag("max", max);
  span.setTag("offset", offset);
  span.setTag("count", count);
  return prepareRedisFuture(
      commands.zrangebyscoreWithScores(channel, key, min, max, offset, count), span);
}
 
Example #26
Source File: TracingRedisAdvancedClusterAsyncCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
@Deprecated
public RedisFuture<List<ScoredValue<V>>> zrangebyscoreWithScores(
    K key, String min, String max, long offset, long count) {
  Span span = helper.buildSpan("zrangebyscoreWithScores", key);
  span.setTag("min", min);
  span.setTag("max", max);
  span.setTag("offset", offset);
  span.setTag("count", count);
  return prepareRedisFuture(commands.zrangebyscoreWithScores(key, min, max, offset, count), span);
}
 
Example #27
Source File: TracingRedisAsyncCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
@Deprecated
public RedisFuture<Long> zrangebyscore(
    ValueStreamingChannel<V> channel, K key, double min, double max,
    long offset, long count) {
  Span span = helper.buildSpan("zrangebyscore", key);
  span.setTag("min", min);
  span.setTag("max", max);
  span.setTag("offset", offset);
  span.setTag("count", count);
  return prepareRedisFuture(commands.zrangebyscore(channel, key, min, max, offset, count), span);
}
 
Example #28
Source File: TracingRedisAdvancedClusterAsyncCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
@Deprecated
public RedisFuture<Long> zrangebyscoreWithScores(
    ScoredValueStreamingChannel<V> channel, K key, double min, double max,
    long offset, long count) {
  Span span = helper.buildSpan("zrangebyscoreWithScores", key);
  span.setTag("min", min);
  span.setTag("max", max);
  span.setTag("offset", offset);
  span.setTag("count", count);
  return prepareRedisFuture(
      commands.zrangebyscoreWithScores(channel, key, min, max, offset, count), span);
}
 
Example #29
Source File: TracingRedisAsyncCommands.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
@Deprecated
public RedisFuture<Long> zrevrangebyscore(
    ValueStreamingChannel<V> channel, K key, double max, double min) {
  Span span = helper.buildSpan("zrevrangebyscore", key);
  span.setTag("max", max);
  span.setTag("min", min);
  return prepareRedisFuture(commands.zrevrangebyscore(channel, key, max, min), span);
}
 
Example #30
Source File: TracingRedisAsyncCommands.java    From java-redis-client with Apache License 2.0 4 votes vote down vote up
@Override
public RedisFuture<Boolean> hexists(K key, K field) {
  Span span = helper.buildSpan("hexists", key);
  return prepareRedisFuture(commands.hexists(key, field), span);
}