io.lettuce.core.resource.DefaultClientResources Java Examples

The following examples show how to use io.lettuce.core.resource.DefaultClientResources. 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: RedisModule.java    From curiostack with MIT License 6 votes vote down vote up
@Provides
@Singleton
static RedisClusterClient redisClusterClient(
    RedisConfig config, MeterRegistry registry, Tracing tracing) {
  RedisClusterClient client =
      RedisClusterClient.create(
          DefaultClientResources.builder()
              .eventExecutorGroup(CommonPools.workerGroup())
              .eventLoopGroupProvider(ArmeriaEventLoopGroupProvider.INSTANCE)
              .commandLatencyCollector(
                  new MicrometerCommandLatencyCollector(DEFAULT_METER_ID_PREFIX, registry))
              .tracing(BraveTracing.create(tracing))
              .build(),
          config.getUrl());
  client.setOptions(ClusterClientOptions.builder().validateClusterNodeMembership(false).build());
  return client;
}
 
Example #2
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 #3
Source File: LettuceRedisInitializer.java    From spring-fu with Apache License 2.0 5 votes vote down vote up
private LettuceConnectionFactory getLettuceConnectionFactory(GenericApplicationContext context) {
    final LettuceConnectionConfiguration configuration = new LettuceConnectionConfiguration(redisProperties, context.getBeanProvider(RedisSentinelConfiguration.class), context.getBeanProvider(RedisClusterConfiguration.class));
    final ClientResources clientResources = DefaultClientResources.create();
    try {
        return configuration.redisConnectionFactory(context.getBeanProvider(LettuceClientConfigurationBuilderCustomizer.class), clientResources);
    } catch (UnknownHostException e) {
        throw new IllegalStateException(e);
    }
}
 
Example #4
Source File: RedisBackedJobService.java    From feast with Apache License 2.0 5 votes vote down vote up
public RedisBackedJobService(FeastProperties.JobStoreProperties jobStoreProperties) {
  RedisURI uri =
      RedisURI.create(jobStoreProperties.getRedisHost(), jobStoreProperties.getRedisPort());

  this.syncCommand =
      RedisClient.create(DefaultClientResources.create(), uri)
          .connect(new ByteArrayCodec())
          .sync();
}
 
Example #5
Source File: RedisModule.java    From curiostack with MIT License 5 votes vote down vote up
@Provides
@Singleton
static RedisClient redisClient(RedisConfig config, MeterRegistry registry, Tracing tracing) {
  return RedisClient.create(
      DefaultClientResources.builder()
          .eventExecutorGroup(CommonPools.workerGroup())
          .eventLoopGroupProvider(ArmeriaEventLoopGroupProvider.INSTANCE)
          .commandLatencyCollector(
              new MicrometerCommandLatencyCollector(DEFAULT_METER_ID_PREFIX, registry))
          .tracing(BraveTracing.create(tracing))
          .build(),
      config.getUrl());
}
 
Example #6
Source File: LettuceConnFactoryProvider.java    From sofa-dashboard-client with Apache License 2.0 4 votes vote down vote up
public DefaultClientResources lettuceClientResources() {
    return DefaultClientResources.create();
}
 
Example #7
Source File: RedisConfig.java    From jeesupport with MIT License 4 votes vote down vote up
@Bean( destroyMethod = "shutdown" )
public ClientResources clientResources(){
    return DefaultClientResources.create();
}
 
Example #8
Source File: SessionStorageRedisCacheImpl.java    From openbd-core with GNU General Public License v3.0 4 votes vote down vote up
public SessionStorageRedisCacheImpl( String appName, String _connectionUri ) throws Exception {
	super( "session:" + appName + ":" );

	this.uri = _connectionUri;

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

	rediscache = RedisClient.create( clientResources, _connectionUri );

	connection = rediscache.connect();
	asyncCommands = connection.async();

	cfEngine.log( "SessionStorageRedisCache: Created " + _connectionUri );
}
 
Example #9
Source File: RedisCacheImpl.java    From openbd-core with GNU General Public License v3.0 3 votes vote down vote up
private void connectToMaster() {
			
	DefaultClientResources clientResources = DefaultClientResources.builder() //
			.dnsResolver( new DirContextDnsResolver() ) // Does not cache DNS lookups (needed for ElasticCache)
			.build();

	redisClient = RedisClient.create( clientResources, server );
	connection = redisClient.connect();
	
}