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


Java IoFuture.Status方法代码示例

本文整理汇总了Java中org.xnio.IoFuture.Status方法的典型用法代码示例。如果您正苦于以下问题:Java IoFuture.Status方法的具体用法?Java IoFuture.Status怎么用?Java IoFuture.Status使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.xnio.IoFuture的用法示例。


在下文中一共展示了IoFuture.Status方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: connectBlocking

import org.xnio.IoFuture; //导入方法依赖的package包/类
/**
 * Blocking connection attempt to the given URI endpoint
 *
 * @param timeout time to wait in seconds before aborting connection attempt
 * @return true if connected; false otherwise
 * @throws IOException if something goes wrong with XNIO worker
 */
@Override
public boolean connectBlocking(long timeout) throws IOException {
    logger.debug("Connect blocking... ({})", this);
    IoFuture<WebSocketChannel> futureChan = connectionBuilder().connect();
    IoFuture.Status status = futureChan.await(timeout, TimeUnit.SECONDS);
    logger.debug("Connect blocking status: {}", status);
    switch (status) {
        case DONE:
            // ok
            this.channel = futureChan.get();
            this.channel.setIdleTimeout(this.idleTimeout);
            registerChannelReceivers();
            return true;

        default:
            // error or interrupted or timed-out
            return false;
    }
}
 
开发者ID:BraindeadCrew,项目名称:java-websocket,代码行数:27,代码来源:WebSocketClientImpl.java

示例2: connectBlocking

import org.xnio.IoFuture; //导入方法依赖的package包/类
@Override
public boolean connectBlocking(long timeout) throws IOException {
    logger.debug("Connect blocking... ({})", this);
    IoFuture<WebSocketChannel> futureChan = connectionBuilder().connect();
    IoFuture.Status status = futureChan.await(timeout, TimeUnit.MILLISECONDS);
    logger.debug("Connect blocking status: {}", status);
    switch (status) {
        case DONE:
            // ok
            this.channel = futureChan.get();
            registerChannelReceivers();
            return true;

        default:
            handlerService.submit(() -> onError(futureChan.getException()));
            try {
                Thread.sleep(reconnectDelay);
                return this.connectBlocking(timeout);
            } catch (InterruptedException e) {
                logger.warn("Connect blocking interrupted while sleeping", e);
            }
            // error or interrupted or timed-out
            return false;
    }
}
 
开发者ID:BraindeadCrew,项目名称:java-websocket,代码行数:26,代码来源:ReconnectWebSocketClient.java

示例3: await

import org.xnio.IoFuture; //导入方法依赖的package包/类
@Override
public Status await(IoFuture<?> future, long timeoutMillis) {
    final long startTime = System.currentTimeMillis();

    IoFuture.Status status = future.await(timeoutMillis, TimeUnit.MILLISECONDS);
    while (status == IoFuture.Status.WAITING) {
        if (thinking) {
            status = future.await(timeoutMillis, TimeUnit.MILLISECONDS);
        } else {
            long timeToWait = (timeoutMillis + thinkTime.get()) - (System.currentTimeMillis() - startTime);
            if (timeToWait > 0) {
                status = future.await(timeToWait, TimeUnit.MILLISECONDS);
            } else {
                return status;
            }
        }
    }

    return status;
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:21,代码来源:GeneralTimeoutHandler.java

示例4: connectUsingRemoting

import org.xnio.IoFuture; //导入方法依赖的package包/类
private boolean connectUsingRemoting(CommandContext cmdCtx, RemotingMBeanServerConnection rmtMBeanSvrConn)
        throws IOException, CliInitializationException {
    Connection conn = rmtMBeanSvrConn.getConnection();
    Channel channel;
    final IoFuture<Channel> futureChannel = conn.openChannel("management", OptionMap.EMPTY);
    IoFuture.Status result = futureChannel.await(5, TimeUnit.SECONDS);
    if (result == IoFuture.Status.DONE) {
        channel = futureChannel.get();
    } else {
        futureChannel.cancel();
        return false;
    }

    ModelControllerClient modelCtlrClient = ExistingChannelModelControllerClient.createReceiving(channel, createExecutor());
    cmdCtx.bindClient(modelCtlrClient);

    return true;
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:19,代码来源:JConsoleCLIPlugin.java

示例5: connectSync

import org.xnio.IoFuture; //导入方法依赖的package包/类
/**
 * Connect sync.
 *
 * @param configuration the protocol configuration
 * @return the connection
 * @throws IOException
 */
public static Connection connectSync(final ProtocolConnectionConfiguration configuration) throws IOException {
    long timeoutMillis = configuration.getConnectionTimeout();
    CallbackHandler handler = configuration.getCallbackHandler();
    final CallbackHandler actualHandler;
    ProtocolTimeoutHandler timeoutHandler = configuration.getTimeoutHandler();
    // Note: If a client supplies a ProtocolTimeoutHandler it is taking on full responsibility for timeout management.
    if (timeoutHandler == null) {
        GeneralTimeoutHandler defaultTimeoutHandler = new GeneralTimeoutHandler();
        // No point wrapping our AnonymousCallbackHandler.
        actualHandler = handler != null ? new WrapperCallbackHandler(defaultTimeoutHandler, handler) : null;
        timeoutHandler = defaultTimeoutHandler;
    } else {
        actualHandler = handler;
    }

    final IoFuture<Connection> future = connect(actualHandler, configuration);

    IoFuture.Status status = timeoutHandler.await(future, timeoutMillis);

    if (status == IoFuture.Status.DONE) {
        return future.get();
    }
    if (status == IoFuture.Status.FAILED) {
        throw ProtocolLogger.ROOT_LOGGER.failedToConnect(configuration.getUri(), future.getException());
    }
    throw ProtocolLogger.ROOT_LOGGER.couldNotConnect(configuration.getUri());
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:35,代码来源:ProtocolConnectionUtils.java

示例6: await

import org.xnio.IoFuture; //导入方法依赖的package包/类
/**
 * Wait for the specified time on the supplied {@link IoFuture}, taking into account that some of this time could actually
 * not be related to the establishment of the connection but instead some local task such as user think time.
 *
 * @param future - The {@link IoFuture} to wait on.
 * @param timeoutMillis - The configures timeout in milliseconds.
 * @return The {@link IoFuture.Status} when available or at the time the timeout is reached - whichever is soonest.
 */
IoFuture.Status await(IoFuture<?> future, long timeoutMillis);
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:10,代码来源:ProtocolTimeoutHandler.java


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