當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。