当前位置: 首页>>代码示例>>Java>>正文


Java RedisChannelHandler类代码示例

本文整理汇总了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);
    }
}
 
开发者ID:mp911de,项目名称:spinach,代码行数:25,代码来源:GetJobsAction.java

示例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());
    }
}
 
开发者ID:mp911de,项目名称:spinach,代码行数:26,代码来源:GetJobsAction.java

示例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);
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:21,代码来源:ConnectionWatchdog.java

示例4: setRedisChannelHandler

import com.lambdaworks.redis.RedisChannelHandler; //导入依赖的package包/类
@Override
public void setRedisChannelHandler(RedisChannelHandler<K, V> redisChannelHandler) {
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:4,代码来源:MasterSlaveChannelWriter.java

示例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");
    }
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:6,代码来源:Connections.java

示例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);
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:5,代码来源:Connections.java

示例7: getChannel

import com.lambdaworks.redis.RedisChannelHandler; //导入依赖的package包/类
public static Channel getChannel(RedisChannelHandler<?, ?> channelHandler) {
    return (Channel) ReflectionTestUtils.getField(channelHandler.getChannelWriter(), "channel");
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:4,代码来源:Connections.java

示例8: getDisconnectedBuffer

import com.lambdaworks.redis.RedisChannelHandler; //导入依赖的package包/类
public static Queue<?> getDisconnectedBuffer(RedisChannelHandler<?, ?> channelHandler) {
    return (Queue<?>) ReflectionTestUtils.getField(channelHandler.getChannelWriter(), "disconnectedBuffer");
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:4,代码来源:Connections.java

示例9: getCommandBuffer

import com.lambdaworks.redis.RedisChannelHandler; //导入依赖的package包/类
public static Queue<?> getCommandBuffer(RedisChannelHandler<?, ?> channelHandler) {
    return (Queue<?>) ReflectionTestUtils.getField(channelHandler.getChannelWriter(), "commandBuffer");
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:4,代码来源:Connections.java

示例10: getStack

import com.lambdaworks.redis.RedisChannelHandler; //导入依赖的package包/类
public static Queue<Object> getStack(StatefulRedisConnection<?, ?> connection) {
    return getStack((RedisChannelHandler) connection);
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:4,代码来源:Connections.java

示例11: getConnectionState

import com.lambdaworks.redis.RedisChannelHandler; //导入依赖的package包/类
public static String getConnectionState(RedisChannelHandler<?, ?> channelHandler) {
    return ReflectionTestUtils.getField(channelHandler.getChannelWriter(), "lifecycleState").toString();
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:4,代码来源:Connections.java


注:本文中的com.lambdaworks.redis.RedisChannelHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。