コード例 #1
0
ファイル: ConnPoolEndpoint.java プロジェクト: ramanan6/jruyi
  @Override
  public void onSessionReadTimedOut(ISession session) {
    Object msg = session.withdraw(IoConstants.FID_TCPCLIENT);
    c_logger.warn(StrUtil.join(session, ": READ_TIMEOUT, ", StrUtil.getLineSeparator(), msg));

    if (msg instanceof Closeable) {
      try {
        ((Closeable) msg).close();
      } catch (Throwable t) {
        c_logger.error(
            StrUtil.join(session, "Failed to close message: ", StrUtil.getLineSeparator(), msg), t);
      }
    }
  }
コード例 #2
0
ファイル: ConnPoolEndpoint.java プロジェクト: ramanan6/jruyi
  @Override
  public void onSessionException(ISession session, Throwable t) {
    Object msg = session.withdraw(IoConstants.FID_TCPCLIENT);
    if (msg == null) msg = session.detach();

    if (msg == null) c_logger.error(StrUtil.join(session, " got an error"), t);
    else {
      c_logger.error(StrUtil.join(session, " got an error: ", StrUtil.getLineSeparator(), msg), t);

      if (msg instanceof Closeable) {
        try {
          ((Closeable) msg).close();
        } catch (Throwable e) {
          c_logger.error(
              StrUtil.join(session, "Failed to close: ", StrUtil.getLineSeparator(), msg), e);
        }
      }
    }
  }
コード例 #3
0
ファイル: ConnPoolEndpoint.java プロジェクト: ramanan6/jruyi
  @Override
  public void onSessionConnectTimedOut(ISession session) {
    Object msg = session.detach();
    c_logger.warn(StrUtil.join(session, ": CONNECT_TIMEOUT, ", StrUtil.getLineSeparator(), msg));

    if (msg instanceof Closeable) {
      try {
        ((Closeable) msg).close();
      } catch (Throwable t) {
        c_logger.error(StrUtil.join(session, "Failed to close message: ", msg), t);
      }
    }
  }
コード例 #4
0
ファイル: TcpServer.java プロジェクト: jruyi/jruyi
  @Override
  public void write(ISession session, O msg) {
    final ConcurrentHashMap<Long, IChannel> channels = m_channels;
    if (channels == null) return;

    final IChannel channel = channels.get(session.id());
    if (channel != null) {
      channel.write(msg);
      return;
    }

    final Object remoteAddr = session.remoteAddress();
    c_logger.warn(
        StrUtil.join(
            session,
            "(remoteAddr=",
            remoteAddr,
            ") failed to send(channel closed): ",
            StrUtil.getLineSeparator(),
            msg));

    if (msg instanceof AutoCloseable) {
      try {
        ((AutoCloseable) msg).close();
      } catch (Throwable t) {
        c_logger.error(
            StrUtil.join(
                session,
                "(remoteAddr=",
                remoteAddr,
                ") failed to close message: ",
                StrUtil.getLineSeparator(),
                msg),
            t);
      }
    }
  }