io.lettuce.core.RedisURI Java Examples

The following examples show how to use io.lettuce.core.RedisURI. 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: RedisBackedJobServiceTest.java    From feast with Apache License 2.0 7 votes vote down vote up
@Test
public void shouldRecoverIfRedisConnectionIsLost() {
  RedisClient client = RedisClient.create(RedisURI.create("localhost", REDIS_PORT));
  RedisBackedJobService jobService =
      new RedisBackedJobService(client.connect(new ByteArrayCodec()));
  jobService.get("does not exist");
  redis.stop();
  try {
    jobService.get("does not exist");
  } catch (Exception e) {
    // pass, this should fail, and return a broken connection to the pool
  }
  redis.start();
  jobService.get("does not exist");
  client.shutdown();
}
 
Example #2
Source File: RedisClientConstructorInterceptor.java    From pinpoint with Apache License 2.0 6 votes vote down vote up
private boolean validate(final Object target, final Object[] args) {
    if (args == null || args.length < 2 || args[1] == null) {
        if (isDebug) {
            logger.debug("Invalid arguments. Null or not found args({}).", args);
        }
        return false;
    }

    if (!(target instanceof EndPointAccessor)) {
        if (isDebug) {
            logger.debug("Invalid target object. Need field accessor({}).", EndPointAccessor.class.getName());
        }
        return false;
    }

    if (!(args[1] instanceof RedisURI)) {
        if (isDebug) {
            logger.debug("Invalid args[1] object. args[1]={}", args[1]);
        }
        return false;
    }
    return true;
}
 
Example #3
Source File: RedisDataSource.java    From Sentinel-Dashboard-Nacos with Apache License 2.0 6 votes vote down vote up
private RedisClient getRedisStandaloneClient(RedisConnectionConfig connectionConfig) {
    char[] password = connectionConfig.getPassword();
    String clientName = connectionConfig.getClientName();
    RedisURI.Builder redisUriBuilder = RedisURI.builder();
    redisUriBuilder.withHost(connectionConfig.getHost())
        .withPort(connectionConfig.getPort())
        .withDatabase(connectionConfig.getDatabase())
        .withTimeout(Duration.ofMillis(connectionConfig.getTimeout()));
    if (password != null) {
        redisUriBuilder.withPassword(connectionConfig.getPassword());
    }
    if (StringUtil.isNotEmpty(connectionConfig.getClientName())) {
        redisUriBuilder.withClientName(clientName);
    }
    return RedisClient.create(redisUriBuilder.build());
}
 
Example #4
Source File: RedisDataSource.java    From Sentinel-Dashboard-Nacos with Apache License 2.0 6 votes vote down vote up
private RedisClient getRedisSentinelClient(RedisConnectionConfig connectionConfig) {
    char[] password = connectionConfig.getPassword();
    String clientName = connectionConfig.getClientName();
    RedisURI.Builder sentinelRedisUriBuilder = RedisURI.builder();
    for (RedisConnectionConfig config : connectionConfig.getRedisSentinels()) {
        sentinelRedisUriBuilder.withSentinel(config.getHost(), config.getPort());
    }
    if (password != null) {
        sentinelRedisUriBuilder.withPassword(connectionConfig.getPassword());
    }
    if (StringUtil.isNotEmpty(connectionConfig.getClientName())) {
        sentinelRedisUriBuilder.withClientName(clientName);
    }
    sentinelRedisUriBuilder.withSentinelMasterId(connectionConfig.getRedisSentinelMasterId())
        .withTimeout(connectionConfig.getTimeout(), TimeUnit.MILLISECONDS);
    return RedisClient.create(sentinelRedisUriBuilder.build());
}
 
Example #5
Source File: StandaloneRedisDataSourceTest.java    From Sentinel-Dashboard-Nacos with Apache License 2.0 6 votes vote down vote up
@Before
public void buildResource() {
    try {
        // Bind to a random port.
        server = RedisServer.newRedisServer();
        server.start();
    } catch (IOException e) {
        e.printStackTrace();
    }
    Converter<String, List<FlowRule>> flowConfigParser = buildFlowConfigParser();
    client = RedisClient.create(RedisURI.create(server.getHost(), server.getBindPort()));
    RedisConnectionConfig config = RedisConnectionConfig.builder()
        .withHost(server.getHost())
        .withPort(server.getBindPort())
        .build();
    initRedisRuleData();
    ReadableDataSource<String, List<FlowRule>> redisDataSource = new RedisDataSource<List<FlowRule>>(config,
        ruleKey, channel, flowConfigParser);
    FlowRuleManager.register2Property(redisDataSource.getProperty());
}
 
Example #6
Source File: RedisHelper.java    From cassandana with Apache License 2.0 6 votes vote down vote up
private RedisHelper(String host, int port, String password) {

		String connectionString = null;
		if(password == null)
			connectionString = "redis://" + host + ":" + port;
		else
			connectionString = "redis://" + password + "@" + host + ":" + port;
		
		redisClient = RedisClient.create(RedisURI.create(connectionString));
		connection = redisClient.connect();
		sync = connection.sync();
		async = connection.async();
		
		asyncKey = connection.async();
		syncKey = connection.sync();

		Runtime.getRuntime().addShutdownHook(new Thread() {
			@Override
			public void run() {
				close();
			}
		});
	}
 
Example #7
Source File: Client.java    From sherlock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @param hostname Redis hostname
 * @param port     Redis port
 * @param ssl      whether to use SSL
 * @param password Redis password
 * @param timeout  Redis timeout
 * @return a Redis URI used to create clients
 */
protected static RedisURI produceURI(
        String hostname,
        String port,
        String ssl,
        String password,
        String timeout
) {
    validateHostname(hostname);
    RedisURI.Builder builder = RedisURI.Builder
            .redis(hostname, getPortNumber(port))
            .withSsl(getSSL(ssl))
            .withTimeout(getTimeout(timeout), TimeUnit.MILLISECONDS);
    if (null != password && !password.isEmpty()) {
        builder.withPassword(password);
    }
    return builder.build();
}
 
Example #8
Source File: RedisPositionsConfiguration.java    From liiklus with MIT License 6 votes vote down vote up
@Override
public void initialize(GenericApplicationContext applicationContext) {
    var environment = applicationContext.getEnvironment();

    var type = environment.getRequiredProperty("storage.positions.type");
    if(!"REDIS".equals(type)) {
        return;
    }

    var redisProperties = PropertiesUtil.bind(environment, new RedisProperties());

    applicationContext.registerBean(RedisPositionsStorage.class, () -> {
        var redisURI = RedisURI.builder()
                .withHost(redisProperties.getHost())
                .withPort(redisProperties.getPort())
                .build();

        return new RedisPositionsStorage(
                Mono
                        .fromCompletionStage(() -> RedisClient.create().connectAsync(StringCodec.UTF8, redisURI))
                        .cache(),
                redisProperties.getPositionsProperties().getPrefix()
        );
    });
}
 
Example #9
Source File: RedisClusterIngestionClient.java    From feast with Apache License 2.0 6 votes vote down vote up
public RedisClusterIngestionClient(StoreProto.Store.RedisClusterConfig redisClusterConfig) {
  this.uriList =
      Arrays.stream(redisClusterConfig.getConnectionString().split(","))
          .map(
              hostPort -> {
                String[] hostPortSplit = hostPort.trim().split(":");
                return RedisURI.create(hostPortSplit[0], Integer.parseInt(hostPortSplit[1]));
              })
          .collect(Collectors.toList());

  long backoffMs =
      redisClusterConfig.getInitialBackoffMs() > 0 ? redisClusterConfig.getInitialBackoffMs() : 1;
  this.backOffExecutor =
      new BackOffExecutor(redisClusterConfig.getMaxRetries(), Duration.millis(backoffMs));
  this.clusterClient = RedisClusterClient.create(uriList);
}
 
Example #10
Source File: RedisFeatureSink.java    From feast with Apache License 2.0 6 votes vote down vote up
@Override
public PCollection<FeatureSetReference> prepareWrite(
    PCollection<KV<FeatureSetReference, FeatureSetProto.FeatureSetSpec>> featureSetSpecs) {
  if (getRedisConfig() != null) {
    RedisClient redisClient =
        RedisClient.create(
            RedisURI.create(getRedisConfig().getHost(), getRedisConfig().getPort()));
    try {
      redisClient.connect();
    } catch (RedisConnectionException e) {
      throw new RuntimeException(
          String.format(
              "Failed to connect to Redis at host: '%s' port: '%d'. Please check that your Redis is running and accessible from Feast.",
              getRedisConfig().getHost(), getRedisConfig().getPort()));
    }
    redisClient.shutdown();
  } else if (getRedisClusterConfig() == null) {
    throw new RuntimeException(
        "At least one RedisConfig or RedisClusterConfig must be provided to Redis Sink");
  }
  specsView = featureSetSpecs.apply(ParDo.of(new ReferenceToString())).apply(View.asMultimap());
  return featureSetSpecs.apply(Keys.create());
}
 
Example #11
Source File: RedisDataSource.java    From Sentinel with Apache License 2.0 6 votes vote down vote up
private RedisClient getRedisStandaloneClient(RedisConnectionConfig connectionConfig) {
    char[] password = connectionConfig.getPassword();
    String clientName = connectionConfig.getClientName();
    RedisURI.Builder redisUriBuilder = RedisURI.builder();
    redisUriBuilder.withHost(connectionConfig.getHost())
        .withPort(connectionConfig.getPort())
        .withDatabase(connectionConfig.getDatabase())
        .withTimeout(Duration.ofMillis(connectionConfig.getTimeout()));
    if (password != null) {
        redisUriBuilder.withPassword(connectionConfig.getPassword());
    }
    if (StringUtil.isNotEmpty(connectionConfig.getClientName())) {
        redisUriBuilder.withClientName(clientName);
    }
    return RedisClient.create(redisUriBuilder.build());
}
 
Example #12
Source File: StandaloneRedisDataSourceTest.java    From Sentinel with Apache License 2.0 6 votes vote down vote up
@Before
public void buildResource() {
    try {
        // Bind to a random port.
        server = RedisServer.newRedisServer();
        server.start();
    } catch (IOException e) {
        e.printStackTrace();
    }
    Converter<String, List<FlowRule>> flowConfigParser = buildFlowConfigParser();
    client = RedisClient.create(RedisURI.create(server.getHost(), server.getBindPort()));
    RedisConnectionConfig config = RedisConnectionConfig.builder()
        .withHost(server.getHost())
        .withPort(server.getBindPort())
        .build();
    initRedisRuleData();
    ReadableDataSource<String, List<FlowRule>> redisDataSource = new RedisDataSource<List<FlowRule>>(config,
        ruleKey, channel, flowConfigParser);
    FlowRuleManager.register2Property(redisDataSource.getProperty());
}
 
Example #13
Source File: LettuceCluster5Driver.java    From hazelcast-simulator with Apache License 2.0 6 votes vote down vote up
@Override
    public void startVendorInstance() throws Exception {
        String workerType = get("WORKER_TYPE");
        if ("javaclient".equals(workerType)) {
            String[] uris = get("URI").split(",");

            DefaultClientResources clientResources = DefaultClientResources.builder() //
                    .dnsResolver(new DirContextDnsResolver()) // Does not cache DNS lookups
                    .build();

            List<RedisURI> nodes = new LinkedList<>();
            for (String uri : uris) {
                nodes.add(RedisURI.create(uri));
            }

//            client = RedisClient.create();
//
//            StatefulRedisMasterReplicaConnection<String, String> connection = MasterReplica
//                    .connect(client, new Utf8StringCodec(), nodes);
//            connection.setReadFrom(ReadFrom.MASTER_PREFERRED);

            client = RedisClusterClient.create(nodes);

            // client = RedisClient.create(clientResources, get("URI"));
        }
    }
 
Example #14
Source File: RedisClientConstructorInterceptor.java    From pinpoint with Apache License 2.0 6 votes vote down vote up
@Override
public void before(Object target, Object[] args) {
    if (isDebug) {
        logger.beforeInterceptor(target, args);
    }

    try {
        if (!validate(target, args)) {
            return;
        }

        final RedisURI redisURI = (RedisURI) args[1];
        final String endPoint = HostAndPort.toHostAndPortString(redisURI.getHost(), redisURI.getPort());
        ((EndPointAccessor) target)._$PINPOINT$_setEndPoint(endPoint);
    } catch (Throwable t) {
        if (logger.isWarnEnabled()) {
            logger.warn("Failed to BEFORE process. {}", t.getMessage(), t);
        }
    }
}
 
Example #15
Source File: RedisConnectorConfig.java    From kafka-connect-redis with Apache License 2.0 6 votes vote down vote up
public List<RedisURI> redisURIs() {
  List<RedisURI> result = new ArrayList<>();

  for (HostAndPort host : this.hosts) {
    RedisURI.Builder builder = RedisURI.builder();
    builder.withHost(host.getHost());
    builder.withPort(host.getPort());
    builder.withDatabase(this.database);
    if (!Strings.isNullOrEmpty(this.password)) {
      builder.withPassword(this.password);
    }
    builder.withSsl(this.sslEnabled);
    result.add(builder.build());
  }

  return result;
}
 
Example #16
Source File: RedisLettuceCacheTest.java    From jetcache with Apache License 2.0 6 votes vote down vote up
@Test
public void testCluster2() throws Exception {
    if (!checkOS()) {
        return;
    }
    RedisURI node1 = RedisURI.create("127.0.0.1", 7000);
    RedisURI node2 = RedisURI.create("127.0.0.1", 7001);
    RedisURI node3 = RedisURI.create("127.0.0.1", 7002);
    RedisClusterClient client = RedisClusterClient.create(Arrays.asList(node1, node2, node3));
    StatefulRedisClusterConnection con = client.connect(new JetCacheCodec());
    con.setReadFrom(ReadFrom.SLAVE_PREFERRED);
    cache = RedisLettuceCacheBuilder.createRedisLettuceCacheBuilder()
            .redisClient(client)
            .connection(con)
            .keyPrefix(new Random().nextInt() + "")
            .buildCache();
    cache.put("K1", "V1");
    Thread.sleep(100);
    Assert.assertEquals("V1", cache.get("K1"));
}
 
Example #17
Source File: RedisLettuceCacheTest.java    From jetcache with Apache License 2.0 6 votes vote down vote up
@Test
public void testSentinel2() throws Exception {
    RedisURI redisUri = RedisURI.Builder
            .sentinel("127.0.0.1", 26379, "mymaster")
            .withSentinel("127.0.0.1", 26380)
            .withSentinel("127.0.0.1", 26381)
            .build();
    RedisClient client = RedisClient.create();
    StatefulRedisMasterSlaveConnection con = MasterSlave.connect(
            client, new JetCacheCodec(), redisUri);
    con.setReadFrom(ReadFrom.SLAVE_PREFERRED);
    cache = RedisLettuceCacheBuilder.createRedisLettuceCacheBuilder()
            .redisClient(client)
            .connection(con)
            .keyPrefix(new Random().nextInt() + "")
            .buildCache();
    cache.put("K1", "V1");
    Thread.sleep(100);
    Assert.assertEquals("V1", cache.get("K1"));
}
 
Example #18
Source File: LettuceConnectionManagerTest.java    From jetcache with Apache License 2.0 6 votes vote down vote up
@Test
public void testCluster() {
    if (!RedisLettuceCacheTest.checkOS()) {
        return;
    }
    RedisURI node1 = RedisURI.create("127.0.0.1", 7000);
    RedisURI node2 = RedisURI.create("127.0.0.1", 7001);
    RedisURI node3 = RedisURI.create("127.0.0.1", 7002);
    RedisClusterClient client = RedisClusterClient.create(Arrays.asList(node1, node2, node3));
    LettuceConnectionManager m = LettuceConnectionManager.defaultManager();
    m.init(client, null);
    Assert.assertSame(m.commands(client), m.commands(client));
    Assert.assertSame(m.asyncCommands(client), m.asyncCommands(client));
    Assert.assertSame(m.reactiveCommands(client), m.reactiveCommands(client));
    m.removeAndClose(client);
}
 
Example #19
Source File: LettuceAsyncService.java    From uavstack with Apache License 2.0 6 votes vote down vote up
public LettuceAsyncService(String redisServerAddress, int minConcurrent, int maxConcurrent, int queueSize,
        String password) {
    String[] redisCluster = redisServerAddress.split(",");
    List<RedisURI> nodes = new ArrayList<RedisURI>();
    for (int i = 0; i < redisCluster.length; i++) {
        String[] uriArray = redisCluster[i].split(":");
        Integer port = Integer.valueOf(uriArray[1]);
        if (!StringHelper.isEmpty(password)) {
            nodes.add(RedisURI.Builder.redis(uriArray[0], port).withPassword(password).build());
        }
        else {
            nodes.add(RedisURI.create(uriArray[0], port));
        }
    }

    client = RedisClusterClient.create(nodes);

    connect = client.connect();

}
 
Example #20
Source File: RedisRateLimiterConfiguration.java    From daming with Apache License 2.0 6 votes vote down vote up
@Bean
@ConditionalOnMissingBean(value = RequestRateLimiterFactory.class)
public RedisRateLimiterFactory redisRateLimiterFactory(ClientResources redisClientResources, RedisProperties redisProperties) {
    RedisURI.Builder builder = RedisURI.builder()
            .withHost(redisProperties.getHost())
            .withPort(redisProperties.getPort());
    if (!StringUtils.isEmpty(redisProperties.getPassword())) {
        builder = builder.withPassword(redisProperties.getPassword());
    }
    if (null != redisProperties.getTimeout()) {
        builder = builder.withTimeout(redisProperties.getTimeout());
    }
    builder = builder.withDatabase(redisProperties.getDatabase())
            .withSsl(redisProperties.isSsl());
    RedisURI redisUri = builder.build();
    return new RedisRateLimiterFactory(RedisClient.create(redisClientResources, redisUri));
}
 
Example #21
Source File: RedisDataSource.java    From Sentinel with Apache License 2.0 6 votes vote down vote up
private RedisClient getRedisSentinelClient(RedisConnectionConfig connectionConfig) {
    char[] password = connectionConfig.getPassword();
    String clientName = connectionConfig.getClientName();
    RedisURI.Builder sentinelRedisUriBuilder = RedisURI.builder();
    for (RedisConnectionConfig config : connectionConfig.getRedisSentinels()) {
        sentinelRedisUriBuilder.withSentinel(config.getHost(), config.getPort());
    }
    if (password != null) {
        sentinelRedisUriBuilder.withPassword(connectionConfig.getPassword());
    }
    if (StringUtil.isNotEmpty(connectionConfig.getClientName())) {
        sentinelRedisUriBuilder.withClientName(clientName);
    }
    sentinelRedisUriBuilder.withSentinelMasterId(connectionConfig.getRedisSentinelMasterId())
        .withTimeout(connectionConfig.getTimeout(), TimeUnit.MILLISECONDS);
    return RedisClient.create(sentinelRedisUriBuilder.build());
}
 
Example #22
Source File: RedisSinks.java    From hazelcast-jet-contrib with Apache License 2.0 5 votes vote down vote up
SortedSetContext(RedisURI uri, K sortedSet, RedisCodec<K, V> codec, FunctionEx<T, Double> scoreFn,
                 FunctionEx<T, V> valueFn) {
    this.client = RedisClient.create(uri);
    this.connection = client.connect(codec);
    this.commands = connection.async();
    this.sortedSet = sortedSet;
    this.scoreFn = scoreFn;
    this.valueFn = valueFn;
}
 
Example #23
Source File: LettuceSessionManager.java    From redis-session-manager with Apache License 2.0 5 votes vote down vote up
private GenericObjectPool<StatefulRedisConnection<String, Object>> createPool(List<String> nodes, RedisCodec<String, Object> codec) {
    GenericObjectPoolConfig<StatefulRedisConnection<String, Object>> cfg = new GenericObjectPoolConfig<>();
    cfg.setTestOnBorrow(true);
    cfg.setMinEvictableIdleTimeMillis(TimeUnit.MINUTES.toMillis(5));
    cfg.setMaxTotal(getMaxConnPoolSize());
    cfg.setMinIdle(getMinConnPoolSize());

    if (nodes.size() == 1) {
        return ConnectionPoolSupport.createGenericObjectPool(
            () -> client.connect(codec, RedisURI.create(nodes.get(0))),
            cfg
        );
    } else {
        List<RedisURI> uris = nodes.stream()
            .map(RedisURI::create)
            .collect(Collectors.toList());
        return ConnectionPoolSupport.createGenericObjectPool(
            () -> {
                StatefulRedisMasterReplicaConnection<String, Object> connection =
                    MasterReplica.connect(client, codec, uris);
                connection.setReadFrom(ReadFrom.MASTER_PREFERRED);
                return connection;
            },
            cfg
        );
    }
}
 
Example #24
Source File: DisCalClient.java    From DisCal-Discord-Bot with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Creates the DisCal bot client.
 *
 * @return The client if successful, otherwise <code>null</code>.
 */
private static DiscordClient createClient() {
	DiscordClientBuilder clientBuilder = new DiscordClientBuilder(BotSettings.TOKEN.get());
	//Handle shard count and index for multiple java instances
	clientBuilder.setShardIndex(Integer.valueOf(BotSettings.SHARD_INDEX.get()));
	clientBuilder.setShardCount(Integer.valueOf(BotSettings.SHARD_COUNT.get()));
	clientBuilder.setInitialPresence(Presence.online(Activity.playing("Booting Up!")));


	//Redis info + store service for caching
	if (BotSettings.USE_REDIS_STORES.get().equalsIgnoreCase("true")) {
		RedisURI uri = RedisURI.Builder
			.redis(BotSettings.REDIS_HOSTNAME.get(), Integer.valueOf(BotSettings.REDIS_PORT.get()))
			.withPassword(BotSettings.REDIS_PASSWORD.get())
			.build();

		RedisStoreService rss = new RedisStoreService(RedisClient.create(uri));

		MappingStoreService mss = MappingStoreService.create()
			.setMappings(rss, GuildBean.class, MessageBean.class)
			.setFallback(new JdkStoreService());

		clientBuilder.setStoreService(mss);
	} else {
		clientBuilder.setStoreService(new JdkStoreService());
	}

	return clientBuilder.build();
}
 
Example #25
Source File: RedisLettuceCacheTest.java    From jetcache with Apache License 2.0 5 votes vote down vote up
@Test
public void testCluster() throws Exception {
    if (!checkOS()) {
        return;
    }
    RedisURI node1 = RedisURI.create("127.0.0.1", 7000);
    RedisURI node2 = RedisURI.create("127.0.0.1", 7001);
    RedisURI node3 = RedisURI.create("127.0.0.1", 7002);
    RedisClusterClient client = RedisClusterClient.create(Arrays.asList(node1, node2, node3));
    test(client,null);
}
 
Example #26
Source File: RedisLettuceCacheTest.java    From jetcache with Apache License 2.0 5 votes vote down vote up
@Test
public void testSentinel() throws Exception {
    RedisURI redisUri = RedisURI.Builder
            .sentinel("127.0.0.1", 26379, "mymaster")
            .withSentinel("127.0.0.1", 26380)
            .withSentinel("127.0.0.1", 26381)
            .build();
    RedisClient client = RedisClient.create(redisUri);
    test(client, null);
}
 
Example #27
Source File: RedisPipeline.java    From NetDiscovery with Apache License 2.0 5 votes vote down vote up
public RedisPipeline(ClientResources resources, RedisURI redisURI, String key, long pipelineDelay) {

        super(pipelineDelay);
        if (null != resources) {
            this.redisClient = RedisClient.create(resources, redisURI);
        } else {
            this.redisClient = RedisClient.create(redisURI);
        }
        this.key = key;
    }
 
Example #28
Source File: RedisClusterOnlineRetriever.java    From feast with Apache License 2.0 5 votes vote down vote up
public static OnlineRetriever create(Map<String, String> config) {
  List<RedisURI> redisURIList =
      Arrays.stream(config.get("connection_string").split(","))
          .map(
              hostPort -> {
                String[] hostPortSplit = hostPort.trim().split(":");
                return RedisURI.create(hostPortSplit[0], Integer.parseInt(hostPortSplit[1]));
              })
          .collect(Collectors.toList());

  StatefulRedisClusterConnection<byte[], byte[]> connection =
      RedisClusterClient.create(redisURIList).connect(new ByteArrayCodec());

  return new RedisClusterOnlineRetriever(connection);
}
 
Example #29
Source File: RedisOnlineRetriever.java    From feast with Apache License 2.0 5 votes vote down vote up
public static OnlineRetriever create(Map<String, String> config) {

    StatefulRedisConnection<byte[], byte[]> connection =
        RedisClient.create(
                RedisURI.create(config.get("host"), Integer.parseInt(config.get("port"))))
            .connect(new ByteArrayCodec());

    return new RedisOnlineRetriever(connection);
  }
 
Example #30
Source File: RedisClientConstructorInterceptor.java    From skywalking with Apache License 2.0 5 votes vote down vote up
@Override
public void onConstruct(EnhancedInstance objInst, Object[] allArguments) {
    RedisURI redisURI = (RedisURI) allArguments[1];
    RedisClient redisClient = (RedisClient) objInst;
    EnhancedInstance optionsInst = (EnhancedInstance) redisClient.getOptions();
    optionsInst.setSkyWalkingDynamicField(redisURI.getHost() + ":" + redisURI.getPort());
}