final CloseFuture future = immediately ? session.closeNow() : session.closeOnFlush(); IoFutureListener<CloseFuture> listener = new IoFutureListener<CloseFuture>() { @SuppressWarnings({ "unchecked", "rawtypes" })
/** * @see IoSession#closeOnFlush() */ public CloseFuture closeOnFlush() { return wrappedSession.closeOnFlush(); }
@Override public void sessionIdle(IoSession session, IdleStatus status) { session.closeOnFlush(); }
@Override public void exceptionCaught(IoSession session, Throwable cause) { session.closeOnFlush(); LOG.debug("exceptionCaught", cause); }
@Override public void disconnect() { // We cannot call join() on the CloseFuture returned // by the following call. We are using a minimal // threading model and calling join will prevent the // close event from being processed by this thread (if // this thread is the MINA IO processor thread. ioSession.closeOnFlush(); ioSession.setAttribute(SessionConnector.QFJ_RESET_IO_CONNECTOR, Boolean.TRUE); }
@Override public void disconnect() { // We cannot call join() on the CloseFuture returned // by the following call. We are using a minimal // threading model and calling join will prevent the // close event from being processed by this thread (if // this thread is the MINA IO processor thread. ioSession.closeOnFlush(); ioSession.setAttribute(SessionConnector.QFJ_RESET_IO_CONNECTOR, Boolean.TRUE); }
@Override public void disconnect() { // We cannot call join() on the CloseFuture returned // by the following call. We are using a minimal // threading model and calling join will prevent the // close event from being processed by this thread (if // this thread is the MINA IO processor thread. ioSession.closeOnFlush(); ioSession.setAttribute(SessionConnector.QFJ_RESET_IO_CONNECTOR, Boolean.TRUE); }
@Override public void close() throws IOException { try { flush(); } finally { CloseFuture future = session.closeOnFlush(); future.awaitUninterruptibly(); } }
public void close() { super.close(); for (Queue<ConnectFuture> f : connections.values()) { for (ConnectFuture cf : f) { cf.getSession().closeOnFlush(); } } connections.clear(); connector.dispose(); connector = null; }
@Override public void close() throws IOException { try { flush(); } finally { CloseFuture future = session.closeOnFlush(); future.awaitUninterruptibly(); } }
public void close() { super.close(); for (Queue<ConnectFuture> f : connections.values()) { for (ConnectFuture cf : f) { cf.getSession().closeOnFlush(); } } connections.clear(); connector.dispose(); connector = null; }
@Override public void exceptionCaught(IoSession session, Throwable cause) { session.closeOnFlush(); if (cause == null) { return; } if (cause.getClass() == IOException.class && AppInfo.getBoolean("rpc.session.print_simple_error", true)) { String msg = cause.getMessage(); if (msg != null && (msg.contains("连接") || msg.contains("connection"))) { Log.get("sumk.rpc.session").debug("session:{},message:{}", session.getId(), cause.getMessage()); return; } } Log.get("sumk.rpc.session").error("session:" + session.getId() + ",message:" + cause.getMessage(), cause); }
public void exceptionCaught(IoSession session, Throwable cause) { final IoSessionInputStream in = (IoSessionInputStream) session .getAttribute(KEY_IN); IOException e = null; if (cause instanceof StreamIoException) { e = (IOException) cause.getCause(); } else if (cause instanceof IOException) { e = (IOException) cause; } if (e != null && in != null) { in.throwException(e); } else { session.closeOnFlush().awaitUninterruptibly(); } } public void sessionIdle(IoSession session, IdleStatus status) {
public void exceptionCaught(IoSession session, Throwable cause) { final IoSessionInputStream in = (IoSessionInputStream) session .getAttribute(KEY_IN); IOException e = null; if (cause instanceof StreamIoException) { e = (IOException) cause.getCause(); } else if (cause instanceof IOException) { e = (IOException) cause; } if (e != null && in != null) { in.throwException(e); } else { session.closeOnFlush().awaitUninterruptibly(); } } public void sessionIdle(IoSession session, IdleStatus status) {
@SuppressWarnings("synthetic-access") @Override public org.apache.sshd.common.future.CloseFuture close(boolean immediately) { org.apache.mina.core.future.CloseFuture cf = immediately ? session.closeNow() : session.closeOnFlush(); cf.addListener(f -> future.setValue(Boolean.TRUE)); return future; } };
public void close(Message msg) throws IOException { super.close(msg); if (msg.getExchange().isOneWay() || msg.getExchange().getInMessage() == msg || msg.getExchange().getInFaultMessage() == msg) { String s = (String)msg.getExchange().get(HOST_PORT); ConnectFuture c = msg.getExchange().get(ConnectFuture.class); if (s != null && c != null) { c.getSession().removeAttribute(CXF_MESSAGE_ATTR); Queue<ConnectFuture> q = connections.get(s); if (q == null) { connections.putIfAbsent(s, new ArrayBlockingQueue<ConnectFuture>(10)); q = connections.get(s); } if (!q.offer(c)) { c.getSession().closeOnFlush(); } } } } public void close() {
public void close(Message msg) throws IOException { super.close(msg); if (msg.getExchange().isOneWay() || msg.getExchange().getInMessage() == msg || msg.getExchange().getInFaultMessage() == msg) { String s = (String)msg.getExchange().get(HOST_PORT); ConnectFuture c = msg.getExchange().get(ConnectFuture.class); if (s != null && c != null) { c.getSession().removeAttribute(CXF_MESSAGE_ATTR); Queue<ConnectFuture> q = connections.get(s); if (q == null) { connections.putIfAbsent(s, new ArrayBlockingQueue<ConnectFuture>(10)); q = connections.get(s); } if (!q.offer(c)) { c.getSession().closeOnFlush(); } } } } public void close() {
CloseFuture closeFuture = session.closeOnFlush(); closeFuture.addListener(new IoFutureListener<CloseFuture>() {
CloseFuture closeFuture = session.closeOnFlush(); closeFuture.addListener(new IoFutureListener<CloseFuture>() {
if (disconnectOnReturn) { log.debug("Close connection due to connect handling exception: {}", conn.getSessionId()); conn.getIoSession().closeOnFlush(); //must wait until flush to close as we just wrote asynchronously to the stream