org.apache.mina.core.future.CloseFuture Java Examples
The following examples show how to use
org.apache.mina.core.future.CloseFuture.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UDPDestination.java From cxf with Apache License 2.0 | 6 votes |
@Override public void sessionOpened(IoSession session) { // Set timeouts session.getConfig().setWriteTimeout(getWriteTimeout()); session.getConfig().setIdleTime(IdleStatus.READER_IDLE, getReadTimeout()); // Create streams InputStream in = new IoSessionInputStream(); OutputStream out = new IoSessionOutputStream(session) { @Override public void close() throws IOException { try { flush(); } finally { CloseFuture future = session.closeNow(); future.awaitUninterruptibly(); } } }; session.setAttribute(KEY_IN, in); session.setAttribute(KEY_OUT, out); processStreamIo(session, in, out); }
Example #2
Source File: RTMPClient.java From red5-client with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override public void disconnect() { if (future != null) { try { // session will be null if connect failed if (session != null) { // close, now CloseFuture closeFuture = session.closeNow(); // now wait for the close to be completed if (closeFuture.await(1000, TimeUnit.MILLISECONDS)) { if (!future.isCanceled()) { if (future.cancel()) { log.debug("Connect future cancelled after close future"); } } } } else if (future.cancel()) { log.debug("Connect future cancelled"); } } catch (Exception e) { log.warn("Exception during disconnect", e); } finally { // we can now dispose the connector socketConnector.dispose(false); } } super.disconnect(); }
Example #3
Source File: NioSession.java From jane with GNU Lesser General Public License v3.0 | 5 votes |
@Override public CloseFuture closeOnFlush() { if (!isClosing()) { writeRequestQueue.offer(CLOSE_REQUEST); getProcessor().flush(this); } return closeFuture; }
Example #4
Source File: NioSession.java From jane with GNU Lesser General Public License v3.0 | 5 votes |
@Override public CloseFuture closeNow() { synchronized (closeFuture) { if (isClosing()) return closeFuture; closing = true; } filterChain.fireFilterClose(); return closeFuture; }
Example #5
Source File: AbstractIoSession.java From neoscada with Eclipse Public License 1.0 | 5 votes |
public void operationComplete(CloseFuture future) { AbstractIoSession session = (AbstractIoSession) future.getSession(); session.scheduledWriteBytes.set(0); session.scheduledWriteMessages.set(0); session.readBytesThroughput = 0; session.readMessagesThroughput = 0; session.writtenBytesThroughput = 0; session.writtenMessagesThroughput = 0; }
Example #6
Source File: AbstractIoSession.java From neoscada with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ public final CloseFuture close(boolean rightNow) { if (!isClosing()) { if (rightNow) { return close(); } return closeOnFlush(); } else { return closeFuture; } }
Example #7
Source File: AbstractIoSession.java From neoscada with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ public final CloseFuture close() { synchronized (lock) { if (isClosing()) { return closeFuture; } closing = true; } getFilterChain().fireFilterClose(); return closeFuture; }
Example #8
Source File: IdleStatusChecker.java From neoscada with Eclipse Public License 1.0 | 5 votes |
/** * Add the session for being checked for idle. * @param session the session to check */ public void addSession(AbstractIoSession session) { sessions.add(session); CloseFuture closeFuture = session.getCloseFuture(); // isn't service reponsability to remove the session nicely ? closeFuture.addListener(sessionCloseListener); }
Example #9
Source File: IoSessionOutputStream.java From cxf with Apache License 2.0 | 5 votes |
@Override public void close() throws IOException { try { flush(); } finally { CloseFuture future = session.closeOnFlush(); future.awaitUninterruptibly(); } }
Example #10
Source File: Client.java From gameserver with Apache License 2.0 | 5 votes |
/** * Run the test suites. */ public void run() { logger.info("client runs"); try { for ( currentIndex = 0; currentIndex < this.testcases.size(); currentIndex++ ) { Class clazz = this.testcaseClasses.get(currentIndex); Object object = this.testcases.get(currentIndex); ProtoTest protoTest = (ProtoTest) clazz.getAnnotation(ProtoTest.class); int times = protoTest.times(); logger.info("run the " + this.testcaseClasses.get(currentIndex) + " cases for " + times + " times."); for ( int i=0; i<times; i++ ) { Method method = clazz.getDeclaredMethod("generateMessge", Map.class); MessageLite request = (MessageLite)method.invoke(object, context); sendRequest(request); sema.acquire(); } } if ( !longRunning ) { CloseFuture future = session.close(false); future.await(); logger.info("client exit"); } } catch (Throwable e) { logger.error(e.getMessage(), e); } }
Example #11
Source File: WebSocketServerTest.java From red5-websocket with Apache License 2.0 | 4 votes |
@Override public CloseFuture closeOnFlush() { // TODO Auto-generated method stub return null; }
Example #12
Source File: NioSession.java From jane with GNU Lesser General Public License v3.0 | 4 votes |
@Override public CloseFuture getCloseFuture() { return closeFuture; }
Example #13
Source File: MinaChannel.java From light-task-scheduler with Apache License 2.0 | 4 votes |
@Override public ChannelHandler close() { CloseFuture closeFuture = session.close(false); return new MinaChannelHandler(closeFuture); }
Example #14
Source File: WebSocketServerTest.java From red5-websocket with Apache License 2.0 | 4 votes |
@Override public CloseFuture getCloseFuture() { // TODO Auto-generated method stub return null; }
Example #15
Source File: WebSocketServerTest.java From red5-websocket with Apache License 2.0 | 4 votes |
@Override @Deprecated public CloseFuture close() { // TODO Auto-generated method stub return null; }
Example #16
Source File: WebSocketServerTest.java From red5-websocket with Apache License 2.0 | 4 votes |
@Override public CloseFuture close(boolean immediately) { // TODO Auto-generated method stub return null; }
Example #17
Source File: LdapNetworkConnection.java From directory-ldap-api with Apache License 2.0 | 4 votes |
/** * Set a listener associated to the closeFuture * * @param connectionFuture A Future for which we want to set a listener */ private void setCloseListener( ConnectFuture connectionFuture ) { // Get the close future for this session CloseFuture closeFuture = connectionFuture.getSession().getCloseFuture(); closeFuture.addListener( future -> { // Process all the waiting operations and cancel them if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_04137_NOD_RECEIVED ) ); } for ( ResponseFuture<?> responseFuture : futureMap.values() ) { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_04137_NOD_RECEIVED ) ); } responseFuture.cancel(); try { if ( responseFuture instanceof AddFuture ) { ( ( AddFuture ) responseFuture ).set( AddNoDResponse.PROTOCOLERROR ); } else if ( responseFuture instanceof BindFuture ) { ( ( BindFuture ) responseFuture ).set( BindNoDResponse.PROTOCOLERROR ); } else if ( responseFuture instanceof CompareFuture ) { ( ( CompareFuture ) responseFuture ).set( CompareNoDResponse.PROTOCOLERROR ); } else if ( responseFuture instanceof DeleteFuture ) { ( ( DeleteFuture ) responseFuture ).set( DeleteNoDResponse.PROTOCOLERROR ); } else if ( responseFuture instanceof ExtendedFuture ) { ( ( ExtendedFuture ) responseFuture ).set( ExtendedNoDResponse.PROTOCOLERROR ); } else if ( responseFuture instanceof ModifyFuture ) { ( ( ModifyFuture ) responseFuture ).set( ModifyNoDResponse.PROTOCOLERROR ); } else if ( responseFuture instanceof ModifyDnFuture ) { ( ( ModifyDnFuture ) responseFuture ).set( ModifyDnNoDResponse.PROTOCOLERROR ); } else if ( responseFuture instanceof SearchFuture ) { ( ( SearchFuture ) responseFuture ).set( SearchNoDResponse.PROTOCOLERROR ); } } catch ( InterruptedException e ) { LOG.error( I18n.err( I18n.ERR_04113_ERROR_PROCESSING_NOD, responseFuture ), e ); } futureMap.remove( messageId.get() ); } futureMap.clear(); } ); }
Example #18
Source File: WebSocketServerTest.java From red5-websocket with Apache License 2.0 | 4 votes |
@Override public CloseFuture closeNow() { // TODO Auto-generated method stub return null; }
Example #19
Source File: MockIOSession.java From mapleLemon with GNU General Public License v2.0 | 4 votes |
@Deprecated @Override public CloseFuture close() { return null; }
Example #20
Source File: MockIOSession.java From mapleLemon with GNU General Public License v2.0 | 4 votes |
@Override public CloseFuture getCloseFuture() { return null; }
Example #21
Source File: MockIOSession.java From mapleLemon with GNU General Public License v2.0 | 4 votes |
@Override public CloseFuture close(boolean bln) { return null; }
Example #22
Source File: AbstractIoSession.java From neoscada with Eclipse Public License 1.0 | 4 votes |
private final CloseFuture closeOnFlush() { getWriteRequestQueue().offer(this, CLOSE_REQUEST); getProcessor().flush(this); return closeFuture; }
Example #23
Source File: AbstractIoSession.java From neoscada with Eclipse Public License 1.0 | 4 votes |
/** * {@inheritDoc} */ public final CloseFuture getCloseFuture() { return closeFuture; }
Example #24
Source File: IoSession.java From neoscada with Eclipse Public License 1.0 | 2 votes |
/** * Returns the {@link CloseFuture} of this session. This method returns * the same instance whenever user calls it. */ CloseFuture getCloseFuture();
Example #25
Source File: IoSession.java From neoscada with Eclipse Public License 1.0 | 2 votes |
/** * Closes this session after all queued write requests * are flushed. This operation is asynchronous. Wait for the returned * {@link CloseFuture} if you want to wait for the session actually closed. * @deprecated use {@link IoSession#close(boolean)} */ @Deprecated CloseFuture close();
Example #26
Source File: IoSession.java From jane with GNU Lesser General Public License v3.0 | 2 votes |
/** * @return the {@link CloseFuture} of this session. * This method returns the same instance whenever user calls it. */ CloseFuture getCloseFuture();
Example #27
Source File: IoSession.java From jane with GNU Lesser General Public License v3.0 | 2 votes |
/** * Closes this session immediately. This operation is asynchronous, it returns a {@link CloseFuture}. * * @return The {@link CloseFuture} that can be use to wait for the completion of this operation */ CloseFuture closeNow();
Example #28
Source File: IoSession.java From jane with GNU Lesser General Public License v3.0 | 2 votes |
/** * Closes this session after all queued write requests are flushed. This operation is asynchronous. * Wait for the returned {@link CloseFuture} if you want to wait for the session actually closed. * * @return The associated CloseFuture */ CloseFuture closeOnFlush();
Example #29
Source File: IoSession.java From neoscada with Eclipse Public License 1.0 | 2 votes |
/** * Closes this session immediately or after all queued write requests * are flushed. This operation is asynchronous. Wait for the returned * {@link CloseFuture} if you want to wait for the session actually closed. * * @param immediately {@code true} to close this session immediately * (i.e. {@link #close()}). The pending write requests * will simply be discarded. * {@code false} to close this session after all queued * write requests are flushed (i.e. {@link #closeOnFlush()}). */ CloseFuture close(boolean immediately);