nio

Jetty 7 NIO issue?

I saw this test showing Jetty 7's performance drops drastically when switched from blocking IO to NIO (95% drop): http://wiki.apache.org/HttpComponents/HttpCoreBenchmark Is this a known issue? Have you experienced it first hand? Should I be avoiding NIO on Jetty? ...

Java programs using NIO framework

Hello, everyone I am doing some research related to Java NIO. I need to find some representative applications that are based on this framework. Please feel free to suggest! The more, the merrier! Thanks ...

How to see the memory usage of NIO buffers?

Is there a way to see the memory usage of NIO buffers? There is the non-heap memory section in JConsole, but I do not think this includes the NIO buffers? Operating system is Linux (Ubuntu or CentOS) if that would matter. regards, Wim ...

looking for good solution to invoke http client method in a bean (i.e. MDB, session)

---[ejb request]--> bean -----[http request]----> host I would like to invoke http client method (http put, get...) within a bean, but I want these beans, either MDB or stateless session bean, run as quick as possible (with extreme short life time). Problem is, the http connection is too slow (especially when connecting to slow host...

Java blocking socket returning incomplete ByteBuffer

I have a socketChannel configured as blocking, but when reading byte buffers of 5K from this socket, I get an incomplete buffer sometimes. ByteBuffer messageBody = ByteBuffer.allocate(5*1024); messageBody.mark(); messageBody.order(ByteOrder.BIG_ENDIAN); int msgByteCount = channel.read(messageBody); Ocasionally, message...

Java NIO SocketChannel writing problem

I am using Java NIO's SocketChannel to write : int n = socketChannel.write(byteBuffer); Most of the times the data is sent in one or two parts; i.e. if the data could not be sent in one attemmpt, remaining data is retried. The issue here is, sometimes, the data is not being sent completely in one attempt, rest of the data when tried to ...

Apache MINA NIO connector help

I'm new to using MINA. I've a program which uses MINA NIOconnector to connect to host. I'm able to send data and also receive. This is clear from log4j log which i'm attaching below. E:\>java TC4HostClient [12:21:46] NioProcessor-1 INFO [] [] [org.apache.mina.filter.logging.LoggingFil ter] - CREATED [12:21:46] NioProcessor-1 INFO [] [...

Why use Java's AsynchronousFileChannel?

I can understand why network apps would use multiplexing (to not create too many threads), and why programs would use async calls for pipelining (more efficient). But I don't understand the efficiency purpose of AsynchronousFileChannel. Any ideas? ...

Fast 4x4 matrix multiplication in Java with NIO float buffers

I know there are LOT of questions like that but I can't find one specific to my situation. I have 4x4 matrices implemented as NIO float buffers (These matrices are used for OpenGL). Now I want to implement a multiply method which multiplies Matrix A with Matrix B and stores the result in Matrix C. So the code may look like this: class M...

What does "Insufficient system resources..." error mean?

This question spans both serverfault and stackoverflow so I just picked this one. I get the following exception with some simple file copy code. Its running on Windows Server 2003 x64 Caused by: java.io.IOException: Insufficient system resources exist to complete the requested service at sun.nio.ch.FileDispatcher.pwrite0(Native Method...

Write a stream into a file with NIO and the Channel system

Hi I have an inputStream and i want to write it to a file. I saw NIO and the FileChannel which has the method "transferTo" ou "transferFrom" and i know how to create the WriteableChannel, but i don't know to transform my inputStream to a ReadableChannel. Thanks. ...

In Java What is the guaranteed way to get a FileLock from FileChannel while accessing a RandomAccessFile ?

I am trying to use FileLock lock(long position, long size,boolean shared) in FileChannel object As per the javadoc it can throw OverlappingFileLockException. When I create a test program with 2 threads lock method seems to be waiting to acquire the lock (both exclusive and non exclusive) But when the number threads increases in the a...

NIO Best Practices - SelectableChannel and InterestOps

Hello, using java.nio one has to register interest in operations via the SelectableChannel: SelectionKey = SelectableChannel.register(selector, interestInOpsBitmask) Registering Interest: overwriting the existing SelectionKey by executing SelectableChannel.register with new Ops VS. updating the existing SelectionKey with key.intere...

Java: GatheringByteChannel advantages?

I'm wondering when the GatheringByteChannel's write methods (taking in an array of ByteBuffers) have advantages over the "regular" WritableByteChannel write methods. I tried a test where I could use the regular vs. the gathering write method on a FileChannel, with approx 400KB/sec total in ByteBuffers of between 23-27 bytes in length i...

Is this the right way to write a ProtocolDecoder in MINA?

public class CustomProtocolDecoder extends CumulativeProtocolDecoder{ byte currentCmd = -1; int currentSize = -1; boolean isFirst = false; @Override protected boolean doDecode(IoSession is, ByteBuffer bb, ProtocolDecoderOutput pdo) throws Exception { if(currentCmd == -1) { currentCmd = bb.get(); cu...

RTSP over HTTP client

I trying to realize rtsp over http. i have a problem with connection to RTSP camera. Maybe, someone can help me? Thanks. ...

Testing SocketChannel NIO

Hello, I just wrote some NIO-code and wonder how to stress-test my implementation regarding SocketChannel.write(ByteBuffer) not able to write the whole byte-buffer SocketChannel.read(ByteBuffer) reading the data in chunks into ByteBuffer are there some simple linux-utilities like telnet to open a ServerSocket with some buffering-op...

Java NIO (Netty): Exceptionhandling in Downstream Hanlders/Chain

Hello Experts, could someone please explain to me, how in netty "Downstream Exceptions" are handeled? According to the javadoc there are no Downstream exceptions: http://docs.jboss.org/netty/3.1/api/org/jboss/netty/channel/ExceptionEvent.html Given the case that in one of my downstream handlers an exception occures OR in the I/0 Threa...

Java 1.7ea: Files.probeContentType(path) returns null

Hi, I'm having a bit of a strange problem with an application using the Files.probeContentType(path)-method to test for file type: On both my Ubuntu and Fedora systems, it works fine, but when moved to a RedHat Enterprise server (2.6.18-194.el5 #1 x86_64 x86_64 x86_64 GNU/Linux), it only returns null. I'm using java 7 early access (1.7....

Java map / nio / NFS issue causing a VM fault: "a fault occurred in a recent unsafe memory access operation in compiled Java code"

I have written a parser class for a particular binary format (nfdump if anyone is interested) which uses java.nio's MappedByteBuffer to read through files of a few GB each. The binary format is just a series of headers and mostly fixed-size binary records, which are fed out to the called by calling nextRecord(), which pushes on the stat...