本文整理汇总了Java中org.apache.mina.core.write.WriteRequestQueue类的典型用法代码示例。如果您正苦于以下问题:Java WriteRequestQueue类的具体用法?Java WriteRequestQueue怎么用?Java WriteRequestQueue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WriteRequestQueue类属于org.apache.mina.core.write包,在下文中一共展示了WriteRequestQueue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: clearWriteRequestQueue
import org.apache.mina.core.write.WriteRequestQueue; //导入依赖的package包/类
private void clearWriteRequestQueue(S session, IOException ioe) {
WriteRequestQueue writeRequestQueue = session.getWriteRequestQueue();
WriteRequest req = session.getCurrentWriteRequest();
if (req == null) {
req = writeRequestQueue.poll();
if (req == null) {
return;
}
} else {
session.setCurrentWriteRequest(null);
}
// Create an exception and notify.
Throwable cause = (ioe != null ? new WriteToClosedSessionException(ioe) : new WriteToClosedSessionException());
do {
req.getFuture().setException(cause);
Object message = req.getMessage();
if (message instanceof IoBuffer) {
((IoBuffer) message).free();
}
} while ((req = writeRequestQueue.poll()) != null);
session.getFilterChain().fireExceptionCaught(cause);
}
示例2: write
import org.apache.mina.core.write.WriteRequestQueue; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public void write(VmPipeSession session, WriteRequest writeRequest) {
WriteRequestQueue writeRequestQueue = session.getWriteRequestQueue();
writeRequestQueue.offer(session, writeRequest);
if (!session.isWriteSuspended()) {
this.flush(session);
}
}
示例3: getWriteRequestQueue
import org.apache.mina.core.write.WriteRequestQueue; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public final WriteRequestQueue getWriteRequestQueue() {
if (writeRequestQueue == null) {
throw new IllegalStateException();
}
return writeRequestQueue;
}
示例4: write
import org.apache.mina.core.write.WriteRequestQueue; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public void write(S session, WriteRequest writeRequest) {
WriteRequestQueue writeRequestQueue = session.getWriteRequestQueue();
writeRequestQueue.offer(session, writeRequest);
if (!session.isWriteSuspended()) {
this.flush(session);
}
}
示例5: filterWrite
import org.apache.mina.core.write.WriteRequestQueue; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void filterWrite(NextFilter nextFilter, IoSession session, WriteRequest writeRequest) throws Exception {
AbstractIoSession s = (AbstractIoSession) session;
// Maintain counters.
if (writeRequest.getMessage() instanceof IoBuffer) {
IoBuffer buffer = (IoBuffer) writeRequest.getMessage();
// I/O processor implementation will call buffer.reset()
// it after the write operation is finished, because
// the buffer will be specified with messageSent event.
buffer.mark();
int remaining = buffer.remaining();
if (remaining == 0) {
// Zero-sized buffer means the internal message
// delimiter.
s.increaseScheduledWriteMessages();
} else {
s.increaseScheduledWriteBytes(remaining);
}
} else {
s.increaseScheduledWriteMessages();
}
WriteRequestQueue writeRequestQueue = s.getWriteRequestQueue();
if (!s.isWriteSuspended()) {
if (writeRequestQueue.size() == 0) {
// We can write directly the message
s.getProcessor().write(s, writeRequest);
} else {
s.getWriteRequestQueue().offer(s, writeRequest);
s.getProcessor().flush(s);
}
} else {
s.getWriteRequestQueue().offer(s, writeRequest);
}
}
示例6: getWriteRequestQueue0
import org.apache.mina.core.write.WriteRequestQueue; //导入依赖的package包/类
WriteRequestQueue getWriteRequestQueue0() {
return super.getWriteRequestQueue();
}
示例7: CloseAwareWriteQueue
import org.apache.mina.core.write.WriteRequestQueue; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public CloseAwareWriteQueue(WriteRequestQueue queue) {
this.queue = queue;
}
示例8: getWriteRequestQueue
import org.apache.mina.core.write.WriteRequestQueue; //导入依赖的package包/类
public WriteRequestQueue getWriteRequestQueue(IoSession session) throws Exception {
return new DefaultWriteRequestQueue();
}
示例9: flush
import org.apache.mina.core.write.WriteRequestQueue; //导入依赖的package包/类
private boolean flush( S session, long currentTime ) throws Exception
{
final WriteRequestQueue writeRequestQueue = session.getWriteRequestQueue();
final int maxWrittenBytes = session.getConfig().getMaxReadBufferSize()
+ ( session.getConfig().getMaxReadBufferSize() >>> 1 );
int writtenBytes = 0;
try
{
for ( ;; )
{
WriteRequest req = session.getCurrentWriteRequest();
if ( req == null )
{
req = writeRequestQueue.poll( session );
if ( req == null )
{
setInterestedInWrite( session, false );
break;
}
session.setCurrentWriteRequest( req );
}
IoBuffer buf = ( IoBuffer ) req.getMessage();
if ( buf.remaining() == 0 )
{
// Clear and fire event
session.setCurrentWriteRequest( null );
buf.reset();
session.getFilterChain().fireMessageSent( req );
continue;
}
SocketAddress destination = req.getDestination();
if ( destination == null )
{
destination = session.getRemoteAddress();
}
int localWrittenBytes = send( session, buf, destination );
if ( ( localWrittenBytes == 0 ) || ( writtenBytes >= maxWrittenBytes ) )
{
// Kernel buffer is full or wrote too much
setInterestedInWrite( session, true );
return false;
}
else
{
setInterestedInWrite( session, false );
// Clear and fire event
session.setCurrentWriteRequest( null );
writtenBytes += localWrittenBytes;
buf.reset();
session.getFilterChain().fireMessageSent( req );
}
}
}
finally
{
session.increaseWrittenBytes( writtenBytes, currentTime );
}
return true;
}
示例10: getWriteRequestQueue
import org.apache.mina.core.write.WriteRequestQueue; //导入依赖的package包/类
@Override
public WriteRequestQueue getWriteRequestQueue() {
return null;
}
示例11: getWriteRequestQueue
import org.apache.mina.core.write.WriteRequestQueue; //导入依赖的package包/类
@Override
public WriteRequestQueue getWriteRequestQueue() {
throw new UnsupportedOperationException("Not supported yet.");
}
示例12: getWriteRequestQueue
import org.apache.mina.core.write.WriteRequestQueue; //导入依赖的package包/类
@Override
public WriteRequestQueue getWriteRequestQueue() {
// TODO Auto-generated method stub
return null;
}
示例13: getWriteRequestQueue
import org.apache.mina.core.write.WriteRequestQueue; //导入依赖的package包/类
@Override
public WriteRequestQueue getWriteRequestQueue(IoSession session)
{
_wrqCount.getAndIncrement();
return new WriteRequestQueue()
{
private final ArrayDeque<WriteRequest> _wrq = new ArrayDeque<>();
@Override
public synchronized int size()
{
return _wrq.size();
}
@Override
public synchronized boolean isEmpty()
{
return _wrq.isEmpty();
}
@Override
public synchronized void clear()
{
_wrq.clear();
}
@Override
public WriteRequest poll()
{
WriteRequest wr;
synchronized(this)
{
wr = _wrq.pollFirst();
}
if(wr == AbstractIoSession.CLOSE_REQUEST)
{
wr = null;
session.closeNow();
dispose();
}
return wr;
}
@Override
public synchronized void offer(WriteRequest writeRequest) // message must be IoBuffer or FileRegion
{
_wrq.addLast(writeRequest);
}
@Override
public void dispose()
{
}
@Override
public synchronized String toString()
{
return _wrq.toString();
}
};
}
示例14: getWriteRequestQueue
import org.apache.mina.core.write.WriteRequestQueue; //导入依赖的package包/类
@Override
public final WriteRequestQueue getWriteRequestQueue() {
return writeRequestQueue;
}
示例15: getWriteRequestQueue
import org.apache.mina.core.write.WriteRequestQueue; //导入依赖的package包/类
@Override
public WriteRequestQueue getWriteRequestQueue(IoSession session) {
return new DefaultWriteRequestQueue(session);
}