Details
Description
Context:
-------
I am using BarchartUDT as transport, which I have integrated with MINA 2.0.4.
BarchartUDT is a java wrapper to a native UDT library (C++). UDT is a reliable,
connection-oriented, streaming protocol.
The example below is the MINA sample sumup client iprogram that breaks
with an exception during the connect() call into the UDT wrapper.
Description:
-----------
Trigger :
1. MINA creates a (non-blocking, by default) UDT channel.
2. Calls connect() on it BEFORE registering it with a selector.
3. My UDT library does not accept a connect with a nonblocking channel and throws an exception.
Just for reference, here's the exception in UDT - the message is quite clear :
Jul 3, 2012 11:22:30 AM com.barchart.udt.nio.ChannelSocketUDT connect
SEVERE: UDT channel is in non blocking mode;must register with a selector before trying to connect()
Of course, the above sequence of actions does work with the native TCP channels.
The problem is that UDT does not accept a connect on a nonblocking AND unregistered channel.
I am perfectly aware that this is most likely an issue with UDT, and not a bug in MINA.
However, I would greatly appreciate it if you can provide any suggestions or help.
Questions :
1. What would it take to have MINA perform these actions in reverse (first register, then connect) ?
Is there an easy change to AbstractPollingIoConnector.connect0 that would do the register before connect,
for example?
2. If this is not possible, is there a way to make the channel blocking, for example?
3. Is there other way around it?
I'd be happy to try any suggestion (or piece of code, if you provide it).
It would help me get over this hurdle until UDT people give a reply to this issue.
Details:
-------
– Call stack:
Jul 13, 2012 1:10:03 PM com.barchart.udt.nio.ChannelSocketUDT connect
SEVERE: UDT channel is in non blocking mode;must register with a selector before trying to connect()
Exception in thread "main" java.nio.channels.IllegalBlockingModeException
at com.barchart.udt.nio.ChannelSocketUDT.connect(ChannelSocketUDT.java:176)
at org.apache.mina.transport.socket.nio.NioUDTSocketConnector.connect(NioUDTSocketConnector.java:215)
at org.apache.mina.transport.socket.nio.NioUDTSocketConnector.connect(NioUDTSocketConnector.java:66)
at org.apache.mina.core.polling.AbstractPollingIoConnector.connect0(AbstractPollingIoConnector.java:320)
at org.apache.mina.core.service.AbstractIoConnector.connect(AbstractIoConnector.java:262)
at org.apache.mina.core.service.AbstractIoConnector.connect(AbstractIoConnector.java:172)
– Code in question :
AbstractPollingIoConnector.connect0 : creates Connector thread AFTER connect call on the non-blocking channel AbstractPollingIoConnector.Connector.run() : calls registerNew() : private class Connector implements Runnable { public Connector() { System.out.println("Connector::CTOR " + selectable); } public void run() { assert (connectorRef.get() == this); int nHandles = 0; while (selectable) { try { // the timeout for select shall be smaller of the connect // timeout or 1 second... int timeout = (int)Math.min(getConnectTimeoutMillis(), 1000L); int selected = select(timeout); nHandles += registerNew();
Thanks !
Florin