org.apache.mina.common.WriteFuture Java Examples
The following examples show how to use
org.apache.mina.common.WriteFuture.
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: MinaChannel.java From dubbo-2.6.5 with Apache License 2.0 | 6 votes |
@Override public void send(Object message, boolean sent) throws RemotingException { super.send(message, sent); boolean success = true; int timeout = 0; try { WriteFuture future = session.write(message); if (sent) { timeout = getUrl().getPositiveParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT); success = future.join(timeout); } } catch (Throwable e) { throw new RemotingException(this, "Failed to send message " + message + " to " + getRemoteAddress() + ", cause: " + e.getMessage(), e); } if (!success) { throw new RemotingException(this, "Failed to send message " + message + " to " + getRemoteAddress() + "in timeout(" + timeout + "ms) limit"); } }
Example #2
Source File: MinaChannel.java From dubbox with Apache License 2.0 | 6 votes |
public void send(Object message, boolean sent) throws RemotingException { super.send(message, sent); boolean success = true; int timeout = 0; try { WriteFuture future = session.write(message); if (sent) { timeout = getUrl().getPositiveParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT); success = future.join(timeout); } } catch (Throwable e) { throw new RemotingException(this, "Failed to send message " + message + " to " + getRemoteAddress() + ", cause: " + e.getMessage(), e); } if(!success) { throw new RemotingException(this, "Failed to send message " + message + " to " + getRemoteAddress() + "in timeout(" + timeout + "ms) limit"); } }
Example #3
Source File: MinaChannel.java From dubbox-hystrix with Apache License 2.0 | 6 votes |
public void send(Object message, boolean sent) throws RemotingException { super.send(message, sent); boolean success = true; int timeout = 0; try { WriteFuture future = session.write(message); if (sent) { timeout = getUrl().getPositiveParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT); success = future.join(timeout); } } catch (Throwable e) { throw new RemotingException(this, "Failed to send message " + message + " to " + getRemoteAddress() + ", cause: " + e.getMessage(), e); } if(!success) { throw new RemotingException(this, "Failed to send message " + message + " to " + getRemoteAddress() + "in timeout(" + timeout + "ms) limit"); } }
Example #4
Source File: MinaChannel.java From dubbox with Apache License 2.0 | 6 votes |
public void send(Object message, boolean sent) throws RemotingException { super.send(message, sent); boolean success = true; int timeout = 0; try { WriteFuture future = session.write(message); if (sent) { timeout = getUrl().getPositiveParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT); success = future.join(timeout); } } catch (Throwable e) { throw new RemotingException(this, "Failed to send message " + message + " to " + getRemoteAddress() + ", cause: " + e.getMessage(), e); } if(!success) { throw new RemotingException(this, "Failed to send message " + message + " to " + getRemoteAddress() + "in timeout(" + timeout + "ms) limit"); } }
Example #5
Source File: MinaChannel.java From dubbox with Apache License 2.0 | 6 votes |
public void send(Object message, boolean sent) throws RemotingException { super.send(message, sent); boolean success = true; int timeout = 0; try { WriteFuture future = session.write(message); if (sent) { timeout = getUrl().getPositiveParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT); success = future.join(timeout); } } catch (Throwable e) { throw new RemotingException(this, "Failed to send message " + message + " to " + getRemoteAddress() + ", cause: " + e.getMessage(), e); } if(!success) { throw new RemotingException(this, "Failed to send message " + message + " to " + getRemoteAddress() + "in timeout(" + timeout + "ms) limit"); } }
Example #6
Source File: MyIoSession.java From cougar with Apache License 2.0 | 6 votes |
@Override public WriteFuture write(Object o) { try { writeLock.lock(); if (throwExceptionOnNextWrite) { throw new RuntimeException(); } DefaultWriteFuture f = new DefaultWriteFuture(this); f.setWritten(!closed); if (!closed) { written.add(o); if (latch != null) { latch.countDown(); } } return f; } finally { writeLock.unlock(); } }
Example #7
Source File: CougarProtocolTest.java From cougar with Apache License 2.0 | 6 votes |
@Override public WriteFuture write(Object message) { DefaultWriteFuture ret = new DefaultWriteFuture(this); try { otherEnd.messageReceived(nextFilter, otherSession, message); ret.setWritten(true); } catch (Exception e) { e.printStackTrace(); ret.setWritten(false); } // behave like the real thing.. if (attributes.get(SSLFilter.DISABLE_ENCRYPTION_ONCE) != null) { attributes.remove(SSLFilter.DISABLE_ENCRYPTION_ONCE); } return ret; }
Example #8
Source File: SessionTestUtil.java From cougar with Apache License 2.0 | 5 votes |
public static IoSession newSession(byte version) { final IoSession mockSession = mock(IoSession.class); when(mockSession.getAttribute(CougarProtocol.PROTOCOL_VERSION_ATTR_NAME)).thenReturn(version); final WriteFuture mockFuture = mock(WriteFuture.class); when(mockSession.write(any())).thenReturn(mockFuture); return mockSession; }
Example #9
Source File: MyIoSession.java From cougar with Apache License 2.0 | 5 votes |
@Override public WriteFuture write(Object message) { allValuesWritten.add(message); DefaultWriteFuture future = new DefaultWriteFuture(this); future.setWritten(true); return future; }