本文整理汇总了Java中com.lambdaworks.redis.RedisChannelHandler类的典型用法代码示例。如果您正苦于以下问题:Java RedisChannelHandler类的具体用法?Java RedisChannelHandler怎么用?Java RedisChannelHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RedisChannelHandler类属于com.lambdaworks.redis包,在下文中一共展示了RedisChannelHandler类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reconnectToNearestProducer
import com.lambdaworks.redis.RedisChannelHandler; //导入依赖的package包/类
private void reconnectToNearestProducer(DisqueConnection<K, V> disqueConnection, boolean forcedReconnect) {
log.debug("reconnectToNearestProducer()");
Set<Multiset.Entry<String>> stats = Multisets.copyHighestCountFirst(nodePrefixes).entrySet();
nodePrefixes.clear();
if (!isNodeSwitchNecessary(stats) && !forcedReconnect) {
return;
}
String nodeIdPrefix = getNodeIdPrefix(stats);
if (nodeIdPrefix != null) {
log.debug("Set preferred node prefix to {}", nodeIdPrefix);
socketAddressSupplier.setPreferredNodeIdPrefix(nodeIdPrefix);
}
if (disqueConnection.isOpen()) {
if (nodeIdPrefix == null) {
log.info("Initiating reconnect");
} else {
log.info("Initiating reconnect to preferred node with prefix {}", nodeIdPrefix);
}
disconnect((RedisChannelHandler<?, ?>) disqueConnection);
}
}
示例2: disconnect
import com.lambdaworks.redis.RedisChannelHandler; //导入依赖的package包/类
/**
* Disconnect the channel. Why {@link Channel#disconnect()} and not {@link DisqueCommands#quit()}? The quit command produces
* an {@code OK} result which is read by the channel. Sometimes the pipeline is not finished with reading but the disconnect
* is already initiated and this raises an {@link java.io.IOException}.
*
* The {@link Channel} is retrieved by reflection because it is not exposed.
*
* @param redisChannelHandler the channel handler.
*/
private void disconnect(RedisChannelHandler<?, ?> redisChannelHandler) {
RedisChannelHandler<?, ?> rch = redisChannelHandler;
RedisChannelWriter<?, ?> channelWriter = rch.getChannelWriter();
try {
Field field = CommandHandler.class.getDeclaredField("channel");
field.setAccessible(true);
Channel o = (Channel) field.get(channelWriter);
if (o != null && o.isOpen()) {
o.disconnect();
}
} catch (Exception e) {
throw new IllegalStateException("Cannot look up/retrieve the channel from the " + CommandHandler.class.getName());
}
}
示例3: channelInactive
import com.lambdaworks.redis.RedisChannelHandler; //导入依赖的package包/类
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
logger.debug("{} channelInactive({})", logPrefix(), ctx);
channel = null;
if (listenOnChannelInactive && !reconnectionHandler.isReconnectSuspended()) {
RedisChannelHandler<?, ?> channelHandler = ctx.pipeline().get(RedisChannelHandler.class);
if (channelHandler != null) {
reconnectionHandler.setTimeout(channelHandler.getTimeout());
reconnectionHandler.setTimeoutUnit(channelHandler.getTimeoutUnit());
}
scheduleReconnect();
} else {
logger.debug("{} Reconnect scheduling disabled", logPrefix(), ctx);
}
super.channelInactive(ctx);
}
示例4: setRedisChannelHandler
import com.lambdaworks.redis.RedisChannelHandler; //导入依赖的package包/类
@Override
public void setRedisChannelHandler(RedisChannelHandler<K, V> redisChannelHandler) {
}
示例5: getRedisChannelHandler
import com.lambdaworks.redis.RedisChannelHandler; //导入依赖的package包/类
public static <K, V> RedisChannelHandler<K, V> getRedisChannelHandler(RedisConnection<K, V> sync) {
InvocationHandler invocationHandler = Proxy.getInvocationHandler(sync);
return (RedisChannelHandler<K, V>) ReflectionTestUtils.getField(invocationHandler, "connection");
}
示例6: getHandler
import com.lambdaworks.redis.RedisChannelHandler; //导入依赖的package包/类
public static <T> T getHandler(Class<T> handlerType, RedisChannelHandler<?, ?> channelHandler) {
Channel channel = getChannel(channelHandler);
return (T) channel.pipeline().get((Class) handlerType);
}
示例7: getChannel
import com.lambdaworks.redis.RedisChannelHandler; //导入依赖的package包/类
public static Channel getChannel(RedisChannelHandler<?, ?> channelHandler) {
return (Channel) ReflectionTestUtils.getField(channelHandler.getChannelWriter(), "channel");
}
示例8: getDisconnectedBuffer
import com.lambdaworks.redis.RedisChannelHandler; //导入依赖的package包/类
public static Queue<?> getDisconnectedBuffer(RedisChannelHandler<?, ?> channelHandler) {
return (Queue<?>) ReflectionTestUtils.getField(channelHandler.getChannelWriter(), "disconnectedBuffer");
}
示例9: getCommandBuffer
import com.lambdaworks.redis.RedisChannelHandler; //导入依赖的package包/类
public static Queue<?> getCommandBuffer(RedisChannelHandler<?, ?> channelHandler) {
return (Queue<?>) ReflectionTestUtils.getField(channelHandler.getChannelWriter(), "commandBuffer");
}
示例10: getStack
import com.lambdaworks.redis.RedisChannelHandler; //导入依赖的package包/类
public static Queue<Object> getStack(StatefulRedisConnection<?, ?> connection) {
return getStack((RedisChannelHandler) connection);
}
示例11: getConnectionState
import com.lambdaworks.redis.RedisChannelHandler; //导入依赖的package包/类
public static String getConnectionState(RedisChannelHandler<?, ?> channelHandler) {
return ReflectionTestUtils.getField(channelHandler.getChannelWriter(), "lifecycleState").toString();
}