本文整理汇总了Java中com.lambdaworks.redis.codec.Utf8StringCodec类的典型用法代码示例。如果您正苦于以下问题:Java Utf8StringCodec类的具体用法?Java Utf8StringCodec怎么用?Java Utf8StringCodec使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Utf8StringCodec类属于com.lambdaworks.redis.codec包,在下文中一共展示了Utf8StringCodec类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: start
import com.lambdaworks.redis.codec.Utf8StringCodec; //导入依赖的package包/类
@Override
public void start() {
try {
if ( config.isCluster() ) {
RedisClusterClient clusterClient = createClusterClient( config.getHosts() );
this.redisClient = clusterClient;
log.connectingToRedis( config.getHosts().toString(), config.getTimeout() );
connection = clusterClient.connect( new Utf8StringCodec() );
}
else {
RedisClient client = createClient( config.getHosts().getFirst() );
this.redisClient = client;
log.connectingToRedis( config.getHosts().toString(), config.getTimeout() );
connection = client.connect( new Utf8StringCodec() );
}
}
catch (RuntimeException e) {
// return a ServiceException to be stack trace friendly
throw log.unableToInitializeRedis( e );
}
}
开发者ID:hibernate,项目名称:hibernate-ogm-redis,代码行数:23,代码来源:RedisDatastoreProvider.java
示例2: init
import com.lambdaworks.redis.codec.Utf8StringCodec; //导入依赖的package包/类
@Override
public void init(AbstractConfiguration config) {
if (!config.getString("redis.type").equals("master_slave")) {
throw new IllegalStateException("RedisSyncSingleStorageImpl class can only be used with master slave redis setup, but redis.type value is " + config.getString("redis.type"));
}
List<String> address = parseRedisAddress(config.getString("redis.address"), 6379);
int databaseNumber = config.getInt("redis.database", 0);
String password = StringUtils.isNotEmpty(config.getString("redis.password")) ? config.getString("redis.password") + "@" : "";
// lettuce
RedisURI lettuceURI = RedisURI.create("redis://" + password + address.get(0) + "/" + databaseNumber);
this.lettuceMasterSlave = RedisClient.create(lettuceURI);
this.lettuceMasterSlaveConn = MasterSlave.connect(this.lettuceMasterSlave, new Utf8StringCodec(), lettuceURI);
this.lettuceMasterSlaveConn.setReadFrom(ReadFrom.valueOf(config.getString("redis.read")));
// params
initParams(config);
}
开发者ID:longkerdandy,项目名称:mithqtt,代码行数:20,代码来源:RedisSyncMasterSlaveStorageImpl.java
示例3: init
import com.lambdaworks.redis.codec.Utf8StringCodec; //导入依赖的package包/类
@Override
public void init(AbstractConfiguration config) {
if (!config.getString("redis.type").equals("sentinel")) {
throw new IllegalStateException("RedisSyncSingleStorageImpl class can only be used with sentinel redis setup, but redis.type value is " + config.getString("redis.type"));
}
List<String> address = parseRedisAddress(config.getString("redis.address"), 26379);
int databaseNumber = config.getInt("redis.database", 0);
String password = StringUtils.isNotEmpty(config.getString("redis.password")) ? config.getString("redis.password") + "@" : "";
String masterId = config.getString("redis.master");
// lettuce
RedisURI lettuceURI = RedisURI.create("redis-sentinel://" + password + String.join(",", address) + "/" + databaseNumber + "#" + masterId);
this.lettuceSentinel = RedisClient.create(lettuceURI);
this.lettuceSentinelConn = MasterSlave.connect(this.lettuceSentinel, new Utf8StringCodec(), lettuceURI);
this.lettuceSentinelConn.setReadFrom(ReadFrom.valueOf(config.getString("redis.read")));
// params
initParams(config);
}
开发者ID:longkerdandy,项目名称:mithqtt,代码行数:21,代码来源:RedisSyncSentinelStorageImpl.java
示例4: connectWithHelloClusterConnectionStrategy
import com.lambdaworks.redis.codec.Utf8StringCodec; //导入依赖的package包/类
@Test
public void connectWithHelloClusterConnectionStrategy() throws Exception {
DisqueURI disqueURI = DisqueURI.Builder.disque(host, port).build();
DisqueConnection<String, String> connect = client.connect(new Utf8StringCodec(), disqueURI,
SocketAddressSupplierFactory.Factories.HELLO_CLUSTER);
// initial address
assertThat(connect.sync().info("server")).contains("tcp_port:" + port);
connect.sync().quit();
// obtained from cluster, may be the same
assertThat(connect.sync().info("server")).contains("tcp_port:" + port);
connect.sync().quit();
// obtained from cluster, second cluster node
assertThat(connect.sync().info("server")).contains("tcp_port:" + TestSettings.port(1));
connect.close();
}
开发者ID:mp911de,项目名称:spinach,代码行数:22,代码来源:ClientTest.java
示例5: main
import com.lambdaworks.redis.codec.Utf8StringCodec; //导入依赖的package包/类
public static void main(String[] args) {
// Syntax: redis://[[email protected]]host[:port][/databaseNumber]
RedisClient redisClient = RedisClient.create();
List<RedisURI> nodes = Arrays.asList(RedisURI.create("redis://host1"),
RedisURI.create("redis://host2"),
RedisURI.create("redis://host3"));
StatefulRedisMasterSlaveConnection<String, String> connection = MasterSlave
.connect(redisClient, new Utf8StringCodec(), nodes);
connection.setReadFrom(ReadFrom.MASTER_PREFERRED);
System.out.println("Connected to Redis");
connection.close();
redisClient.shutdown();
}
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:19,代码来源:ConnectToMasterSlaveUsingElastiCacheCluster.java
示例6: testMasterSlaveSentinelConnectionCount
import com.lambdaworks.redis.codec.Utf8StringCodec; //导入依赖的package包/类
@Test
public void testMasterSlaveSentinelConnectionCount() throws Exception {
ChannelGroup channels = (ChannelGroup) ReflectionTestUtils.getField(sentinelClient, "channels");
int count = channels.size();
StatefulRedisMasterSlaveConnection<String, String> connection = MasterSlave.connect(sentinelClient,
new Utf8StringCodec(), sentinelUri);
connection.sync().ping();
connection.setReadFrom(ReadFrom.SLAVE);
slaveCall(connection);
assertThat(channels.size()).isEqualTo(count + 2 /* connections */ + 1 /* sentinel connections */);
connection.close();
}
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:18,代码来源:MasterSlaveSentinelTest.java
示例7: testMasterSlaveSentinelClosesSentinelConnections
import com.lambdaworks.redis.codec.Utf8StringCodec; //导入依赖的package包/类
@Test
public void testMasterSlaveSentinelClosesSentinelConnections() throws Exception {
ChannelGroup channels = (ChannelGroup) ReflectionTestUtils.getField(sentinelClient, "channels");
int count = channels.size();
StatefulRedisMasterSlaveConnection<String, String> connection = MasterSlave.connect(sentinelClient,
new Utf8StringCodec(), sentinelUri);
connection.sync().ping();
connection.setReadFrom(ReadFrom.SLAVE);
slaveCall(connection);
connection.close();
assertThat(channels.size()).isEqualTo(count);
}
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:17,代码来源:MasterSlaveSentinelTest.java
示例8: shouldWriteActiveCommandsInMixedBatch
import com.lambdaworks.redis.codec.Utf8StringCodec; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void shouldWriteActiveCommandsInMixedBatch() throws Exception {
when(promise.isSuccess()).thenReturn(true);
Command<String, String, String> command2 = new Command<>(CommandType.APPEND, new StatusOutput<>(new Utf8StringCodec()),
null);
command.cancel();
sut.write(context, Arrays.asList(command, command2), promise);
ArgumentCaptor<List> captor = ArgumentCaptor.forClass(List.class);
verify(context).write(captor.capture(), any());
assertThat(captor.getValue()).containsOnly(command2);
assertThat(stack).hasSize(1).allMatch(o -> o instanceof LatencyMeteredCommand)
.allMatch(o -> CommandWrapper.unwrap((RedisCommand) o) == command2);
}
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:20,代码来源:CommandHandlerTest.java
示例9: init
import com.lambdaworks.redis.codec.Utf8StringCodec; //导入依赖的package包/类
@Override
public void init(AbstractConfiguration config) {
if (!config.getString("redis.type").equals("master_slave")) {
throw new IllegalStateException("RedisSyncSingleStorage class can only be used with master slave redis setup, but redis.type value is " + config.getString("redis.type"));
}
List<String> address = parseRedisAddress(config.getString("redis.address"), 6379);
int databaseNumber = config.getInt("redis.database", 0);
String password = StringUtils.isNotEmpty(config.getString("redis.password")) ? config.getString("redis.password") + "@" : "";
// lettuce
RedisURI lettuceURI = RedisURI.create("redis://" + password + address.get(0) + "/" + databaseNumber);
this.lettuceMasterSlave = RedisClient.create(lettuceURI);
this.lettuceMasterSlaveConn = MasterSlave.connect(this.lettuceMasterSlave, new Utf8StringCodec(), lettuceURI);
this.lettuceMasterSlaveConn.setReadFrom(ReadFrom.valueOf(config.getString("redis.read")));
// redisson
String masterNode = address.get(0);
String[] slaveNodes = address.subList(1, address.size()).toArray(new String[address.size() - 1]);
Config redissonConfig = new Config();
redissonConfig.useMasterSlaveServers()
.setMasterAddress(masterNode)
.setLoadBalancer(new RoundRobinLoadBalancer())
.addSlaveAddress(slaveNodes)
.setReadMode(ReadMode.MASTER)
.setDatabase(databaseNumber)
.setPassword(StringUtils.isNotEmpty(password) ? password : null);
this.redisson = Redisson.create(redissonConfig);
// params
initParams(config);
}
开发者ID:12315jack,项目名称:j1st-mqtt,代码行数:33,代码来源:RedisSyncMasterSlaveStorage.java
示例10: init
import com.lambdaworks.redis.codec.Utf8StringCodec; //导入依赖的package包/类
@Override
public void init(AbstractConfiguration config) {
if (!config.getString("redis.type").equals("sentinel")) {
throw new IllegalStateException("RedisSyncSingleStorage class can only be used with sentinel redis setup, but redis.type value is " + config.getString("redis.type"));
}
List<String> address = parseRedisAddress(config.getString("redis.address"), 26379);
int databaseNumber = config.getInt("redis.database", 0);
String password = StringUtils.isNotEmpty(config.getString("redis.password")) ? config.getString("redis.password") + "@" : "";
String masterId = config.getString("redis.master");
// lettuce
RedisURI lettuceURI = RedisURI.create("redis-sentinel://" + password + String.join(",", address) + "/" + databaseNumber + "#" + masterId);
this.lettuceSentinel = RedisClient.create(lettuceURI);
this.lettuceSentinelConn = MasterSlave.connect(this.lettuceSentinel, new Utf8StringCodec(), lettuceURI);
this.lettuceSentinelConn.setReadFrom(ReadFrom.valueOf(config.getString("redis.read")));
// redisson
Config redissonConfig = new Config();
redissonConfig.useSentinelServers()
.setMasterName(masterId)
.addSentinelAddress(address.toArray(new String[address.size()]))
.setReadMode(ReadMode.MASTER)
.setDatabase(databaseNumber)
.setPassword(StringUtils.isNotEmpty(password) ? password : null);
this.redisson = Redisson.create(redissonConfig);
// params
initParams(config);
}
开发者ID:12315jack,项目名称:j1st-mqtt,代码行数:31,代码来源:RedisSyncSentinelStorage.java
示例11: getRedisCodec
import com.lambdaworks.redis.codec.Utf8StringCodec; //导入依赖的package包/类
private RedisCodec getRedisCodec() {
final String codec = cacheConfig.getCacheEntry().getCodec();
if (codec != null) {
return new Utf8StringCodec();
} else {
try {
return ReflectionHelper.newInstance(codec);
} catch (Exception e) {
throw new RuntimeException("Exception occurred creating codec", e);
}
}
}
开发者ID:hortonworks,项目名称:registry,代码行数:13,代码来源:RedisCacheServiceBuilder.java
示例12: sharedRedisClient
import com.lambdaworks.redis.codec.Utf8StringCodec; //导入依赖的package包/类
@Test
public void sharedRedisClient() throws Exception {
QueueListenerFactory sharedClientListener = QueueListenerFactory.create(client, Schedulers.io(), disqueURI0,
new Utf8StringCodec(), queue);
sharedClientListener.getjobs(10, TimeUnit.MILLISECONDS, 1).subscribe(subscriber);
createJobs(connection0);
waitForSomeReceivedJobs();
sharedClientListener.shutdown();
}
开发者ID:mp911de,项目名称:spinach,代码行数:13,代码来源:QueueListenerFactoryTest.java
示例13: main
import com.lambdaworks.redis.codec.Utf8StringCodec; //导入依赖的package包/类
public static void main(String[] args) {
// Syntax: redis-sentinel://[[email protected]]host[:port][,host2[:port2]][/databaseNumber]#sentinelMasterId
RedisClient redisClient = RedisClient.create();
StatefulRedisMasterSlaveConnection<String, String> connection = MasterSlave.connect(redisClient, new Utf8StringCodec(),
RedisURI.create("redis-sentinel://localhost:26379,localhost:26380/0#mymaster"));
connection.setReadFrom(ReadFrom.MASTER_PREFERRED);
System.out.println("Connected to Redis");
connection.close();
redisClient.shutdown();
}
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:14,代码来源:ConnectToMasterSlaveUsingRedisSentinel.java
示例14: before
import com.lambdaworks.redis.codec.Utf8StringCodec; //导入依赖的package包/类
@Before
public void before() throws Exception {
RedisURI node1 = RedisURI.Builder.redis(host, TestSettings.port(3)).withClientName("my-client").withDatabase(2).build();
RedisURI node2 = RedisURI.Builder.redis(host, TestSettings.port(4)).withClientName("my-client").withDatabase(2).build();
connectionToNode1 = client.connect(node1).async();
connectionToNode2 = client.connect(node2).async();
RedisInstance node1Instance = RoleParser.parse(connectionToNode1.role().get(2, TimeUnit.SECONDS));
RedisInstance node2Instance = RoleParser.parse(connectionToNode2.role().get(2, TimeUnit.SECONDS));
if (node1Instance.getRole() == RedisInstance.Role.MASTER && node2Instance.getRole() == RedisInstance.Role.SLAVE) {
master = node1;
slave = node2;
} else if (node2Instance.getRole() == RedisInstance.Role.MASTER
&& node1Instance.getRole() == RedisInstance.Role.SLAVE) {
master = node2;
slave = node1;
} else {
assumeTrue(String.format("Cannot run the test because I don't have a distinct master and slave but %s and %s",
node1Instance, node2Instance), false);
}
connectionToNode1.configSet("requirepass", passwd);
connectionToNode1.configSet("masterauth", passwd);
connectionToNode1.auth(passwd);
connectionToNode2.configSet("requirepass", passwd);
connectionToNode2.configSet("masterauth", passwd);
connectionToNode2.auth(passwd);
node1.setPassword(passwd);
node2.setPassword(passwd);
connection = (StatefulRedisMasterSlaveConnectionImpl) MasterSlave.connect(client, new Utf8StringCodec(),
Arrays.asList(master, slave));
connection.setReadFrom(ReadFrom.SLAVE);
}
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:40,代码来源:StaticMasterSlaveTest.java
示例15: noSlaveForRead
import com.lambdaworks.redis.codec.Utf8StringCodec; //导入依赖的package包/类
@Test(expected = RedisException.class)
public void noSlaveForRead() throws Exception {
connection.close();
connection = (StatefulRedisMasterSlaveConnectionImpl) MasterSlave.connect(client, new Utf8StringCodec(),
Arrays.asList(master));
connection.setReadFrom(ReadFrom.SLAVE);
slaveCall(connection);
}
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:12,代码来源:StaticMasterSlaveTest.java
示例16: shouldWorkWithMasterOnly
import com.lambdaworks.redis.codec.Utf8StringCodec; //导入依赖的package包/类
@Test
public void shouldWorkWithMasterOnly() throws Exception {
connection.close();
connection = (StatefulRedisMasterSlaveConnectionImpl) MasterSlave.connect(client, new Utf8StringCodec(),
Arrays.asList(master));
connection.sync().set(key, value);
assertThat(connection.sync().get(key)).isEqualTo("value");
}
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:12,代码来源:StaticMasterSlaveTest.java
示例17: shouldWorkWithSlaveOnly
import com.lambdaworks.redis.codec.Utf8StringCodec; //导入依赖的package包/类
@Test
public void shouldWorkWithSlaveOnly() throws Exception {
connection.close();
connection = (StatefulRedisMasterSlaveConnectionImpl) MasterSlave.connect(client, new Utf8StringCodec(),
Arrays.asList(slave));
connection.setReadFrom(ReadFrom.MASTER_PREFERRED);
assertThat(connection.sync().info()).isNotEmpty();
}
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:12,代码来源:StaticMasterSlaveTest.java
示例18: testMasterSlaveSentinelBasic
import com.lambdaworks.redis.codec.Utf8StringCodec; //导入依赖的package包/类
@Test
public void testMasterSlaveSentinelBasic() throws Exception {
RedisURI uri = RedisURI.create(
"redis-sentinel://127.0.0.1:21379,127.0.0.1:22379,127.0.0.1:26379?sentinelMasterId=mymaster&timeout=5s");
StatefulRedisMasterSlaveConnection<String, String> connection = MasterSlave.connect(sentinelClient,
new Utf8StringCodec(), uri);
connection.setReadFrom(ReadFrom.MASTER);
String server = slaveCall(connection);
assertThatServerIs(server, "master");
connection.close();
}
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:15,代码来源:MasterSlaveSentinelTest.java
示例19: masterSlaveConnectionShouldSetClientName
import com.lambdaworks.redis.codec.Utf8StringCodec; //导入依赖的package包/类
@Test
public void masterSlaveConnectionShouldSetClientName() throws Exception {
RedisURI redisURI = RedisURI.Builder.sentinel(TestSettings.host(), MASTER_ID).withClientName("my-client").build();
StatefulRedisMasterSlaveConnection<String, String> connection = MasterSlave.connect(sentinelClient,
new Utf8StringCodec(), redisURI);
assertThat(connection.sync().clientGetname()).isEqualTo(redisURI.getClientName());
connection.sync().quit();
assertThat(connection.sync().clientGetname()).isEqualTo(redisURI.getClientName());
connection.close();
}
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:15,代码来源:MasterSlaveSentinelTest.java
示例20: testMasterSlaveSentinelWithTwoUnavailableSentinels
import com.lambdaworks.redis.codec.Utf8StringCodec; //导入依赖的package包/类
@Test
public void testMasterSlaveSentinelWithTwoUnavailableSentinels() throws Exception {
RedisURI uri = RedisURI.create(
"redis-sentinel://127.0.0.1:21379,127.0.0.1:22379,127.0.0.1:26379?sentinelMasterId=mymaster&timeout=5s");
StatefulRedisMasterSlaveConnection<String, String> connection = MasterSlave.connect(sentinelClient,
new Utf8StringCodec(), uri);
connection.setReadFrom(ReadFrom.MASTER);
String server = connection.sync().info("replication");
assertThatServerIs(server, "master");
connection.close();
}
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:15,代码来源:MasterSlaveSentinelTest.java
注:本文中的com.lambdaworks.redis.codec.Utf8StringCodec类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论