You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Samuel Doyle <sd...@yahoo.com> on 2006/04/26 20:09:11 UTC

IoSession writes

I'm a bit unclear on the javadoc description of this
method. The following is the actual description.

WriteFuture write(Object message)

    Writes the specified message to remote peer. This
operation is asynchronous;
IoHandler.messageSent(IoSession, Object) will be
invoked when the message is actually sent to remote
peer. You can also ait for the returned WriteFuture if
you want to wait for the session actually closed. 

The last part is where it is a bit unclear to me. Is
it saying that when you join on the future the session
is to be closed after that? Or does it mean that the
actual write operation has fully completed and the
session remains open?

In addition, is there a synchronized version of this
method? I'm just curious what is the best way to
handle a case where you may have multiple threads that
want to send packets of data to the same session.
Basically you have multiple client sessions driving
messages down the same piple to the server, the data
can not be mixed. Should I do my own locking in this
case?

Thanks, S.D.

Re: IoSession writes

Posted by Trustin Lee <tr...@gmail.com>.
On 4/27/06, Samuel Doyle <sd...@yahoo.com> wrote:
>
> I'm a bit unclear on the javadoc description of this
> method. The following is the actual description.
>
> WriteFuture write(Object message)
>
>     Writes the specified message to remote peer. This
> operation is asynchronous;
> IoHandler.messageSent(IoSession, Object) will be
> invoked when the message is actually sent to remote
> peer. You can also ait for the returned WriteFuture if
> you want to wait for the session actually closed.
>
> The last part is where it is a bit unclear to me. Is
> it saying that when you join on the future the session
> is to be closed after that? Or does it mean that the
> actual write operation has fully completed and the
> session remains open?


It's an error in the documentation.  Thanks for the notification!
session.write(...).join() just wait for the message to be written.

In addition, is there a synchronized version of this
> method? I'm just curious what is the best way to
> handle a case where you may have multiple threads that
> want to send packets of data to the same session.
> Basically you have multiple client sessions driving
> messages down the same piple to the server, the data
> can not be mixed. Should I do my own locking in this
> case?


Just add .join() after your write() call.  It never returns null.  Or do we
need a synchronous method?  I didn't add it because .join() is simple
enough.  Perhaps I need to add this idiom to the documentation, too. :)

HTH,
Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP key fingerprints:
* E167 E6AF E73A CBCE EE41  4A29 544D DE48 FE95 4E7E
* B693 628E 6047 4F8F CFA4  455E 1C62 A7DC 0255 ECA6

Re: Attempt to upgrade to 0.9.3

Posted by Trustin Lee <tr...@gmail.com>.
The main advantage of ServiceRegistry was in that it automatically adds
essential filters such as ThreadPoolFilter.  We added ThreadModel property
in IoServiceConfig so you can configure your favorite thread model very
easily now, and thus we decided to remove ServiceRegistry.

The default thread model is a very popular thread model with one thread pool
filter.  So you don't need to add your thread pool filter manually at all
since 0.9.3.

Please let us know if there're features you miss from ServiceRegistry
interface.

HTH,
Trustin

On 4/27/06, Samuel Doyle <sd...@yahoo.com> wrote:
>
> So I attempted to upgrade my 0.9.0 prototype to 0.9.3
> I was hoping replacing the jar with the new core jar
> would do the trick, I guess that was wishful thinking.
> :)
> There was a fair bit of code involved in this so any
> recommendations on the best way to tackle getting this
> working again with the latest version would be
> appreciated.
>
> Thanks, S.D.
>
> compile:
>     [javac] Compiling 21 source files to
> lib/java/classes
>     [javac] BaseProcessor.java:23: package
> org.apache.mina.registry does not exist
>     [javac] import org.apache.mina.registry.Service;
>     [javac]                                 ^
>     [javac] BaseProcessor.java:24: package
> org.apache.mina.registry does not exist
>     [javac] import
> org.apache.mina.registry.ServiceRegistry;
>     [javac]                                 ^
>     [javac] BaseProcessor.java:25: package
> org.apache.mina.registry does not exist
>     [javac] import
> org.apache.mina.registry.SimpleServiceRegistry;
>     [javac]                                 ^
>     [javac] BaseProcessor.java:38: cannot find symbol
>     [javac] symbol  : class ServiceRegistry
>     [javac] location: class
> com.wm.finance.epay.BaseProcessor
>     [javac]    protected ServiceRegistry myRegistry =
> null;
>     [javac]              ^
>     [javac] BaseProcessor.java:109: cannot find symbol
>     [javac] symbol  : class ServiceRegistry
>     [javac] location: class
> com.wm.finance.epay.BaseProcessor
>     [javac]    protected abstract void addLogger(
> ServiceRegistry registry ) throws Exception;
>     [javac]                                       ^
>     [javac] ShoppingCardProcessor.java:32: package
> org.apache.mina.registry does not exist
>     [javac] import
> org.apache.mina.registry.ServiceRegistry;
>     [javac]                                 ^
>     [javac] RTCCSessionHandler.java:34: cannot find
> symbol
>     [javac] symbol  : class SocketSession
>     [javac] location: package
> org.apache.mina.transport.socket.nio
>     [javac] import
> org.apache.mina.transport.socket.nio.SocketSession;
>     [javac]
> ^
>     [javac] EPAYSessionHandler.java:36: cannot find
> symbol
>     [javac] symbol  : class SocketSession
>     [javac] location: package
> org.apache.mina.transport.socket.nio
>     [javac] import
> org.apache.mina.transport.socket.nio.SocketSession;
>     [javac]
> ^
>     [javac] ShoppingCardProcessor.java:105: cannot
> find symbol
>     [javac] symbol  : class ServiceRegistry
>     [javac] location: class
> com.wm.finance.epay.shoppingcard.ShoppingCardProcessor
>     [javac]    protected void addLogger(
> ServiceRegistry registry ) throws Exception
>     [javac]                              ^
>     [javac] BaseProcessor.java:67: cannot find symbol
>     [javac] symbol  : class SimpleServiceRegistry
>     [javac] location: class
> com.wm.finance.epay.BaseProcessor
>     [javac]       this.myRegistry = new
> SimpleServiceRegistry();
>     [javac]                             ^
>     [javac] BaseProcessor.java:83: cannot find symbol
>     [javac] symbol  : class Service
>     [javac] location: class
> com.wm.finance.epay.BaseProcessor
>     [javac]       Service service = new Service(
> this.myName, TransportType.SOCKET, this.port );
>     [javac]       ^
>     [javac] BaseProcessor.java:83: cannot find symbol
>     [javac] symbol  : class Service
>     [javac] location: class
> com.wm.finance.epay.BaseProcessor
>     [javac]       Service service = new Service(
> this.myName, TransportType.SOCKET, this.port );
>     [javac]                             ^
>     [javac] RTCCSessionHandler.java:76: cannot find
> symbol
>     [javac] symbol  : class SocketSession
>     [javac] location: class
> com.wm.finance.epay.shoppingcard.comms.RTCCSessionHandler
>     [javac]       if( session instanceof SocketSession
> )
>     [javac]                              ^
>     [javac] RTCCSessionHandler.java:78: cannot find
> symbol
>     [javac] symbol  : class SocketSession
>     [javac] location: class
> com.wm.finance.epay.shoppingcard.comms.RTCCSessionHandler
>     [javac]          ( ( SocketSession ) session
> ).setSessionReceiveBufferSize( 2048 );
>     [javac]              ^
>     [javac] EPAYSessionHandler.java:78: cannot find
> symbol
>     [javac] symbol  : class SocketSession
>     [javac] location: class
> com.wm.finance.epay.shoppingcard.comms.EPAYSessionHandler
>     [javac]       if( session instanceof SocketSession
> )
>     [javac]                              ^
>     [javac] EPAYSessionHandler.java:80: cannot find
> symbol
>     [javac] symbol  : class SocketSession
>     [javac] location: class
> com.wm.finance.epay.shoppingcard.comms.EPAYSessionHandler
>     [javac]          ( ( SocketSession ) session
> ).setSessionReceiveBufferSize( 2048 );
>     [javac]              ^
>     [javac] EPAYSessionPool.java:84: cannot find
> symbol
>     [javac] symbol  : method setConnectTimeout(int)
>     [javac] location: interface
> org.apache.mina.common.IoConnector
>     [javac]       this.connector.setConnectTimeout(
> this.connectTimeOut );
>     [javac]       ^
>     [javac] 17 errors
>
>


--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP key fingerprints:
* E167 E6AF E73A CBCE EE41  4A29 544D DE48 FE95 4E7E
* B693 628E 6047 4F8F CFA4  455E 1C62 A7DC 0255 ECA6

Re: What happened to SocketConnector.setConnectTimeout ?

Posted by Trustin Lee <tr...@gmail.com>.
On 4/27/06, Samuel Doyle <sd...@yahoo.com> wrote:
>
> Alright I assume this is how you do it. Can someone
> confirm?
>
> IoConnector connector = new SocketConnector()
> BaseIoConnectorConfig connectorConfig = new
> SocketConnectorConfig();
>
> connectorConfig.setConnectTimeout( connectTimeOut );
> connector.connect( host, sessionHandler,
> connectorConfig );


BaseIoConnectorConfig is an internal support class.  Please don't use it.

IoConnectorConfig connectorConfig = new SocketConnectorConfig();

will suffice.

Otherwise, if you want to just override the default configuration for the
connector you created:

connector,getDefaultConfig().setConnectTimeout( connectTimeout );

HTH,
Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP key fingerprints:
* E167 E6AF E73A CBCE EE41  4A29 544D DE48 FE95 4E7E
* B693 628E 6047 4F8F CFA4  455E 1C62 A7DC 0255 ECA6

Re: What happened to SocketConnector.setConnectTimeout ?

Posted by Samuel Doyle <sd...@yahoo.com>.
Hi, 

Yes I do something similar to handle legacy client -->
mina connections. The socketconnecor is required to go
from mina --> legacy server, well at least that is
what I assume based on looking at examples and apis.
I'm using mina to act as a proxy server.

S.D.


--- Enrique Rodriguez <en...@gmail.com> wrote:

> Samuel Doyle wrote:
> > Alright I assume this is how you do it. Can
> someone
> > confirm?
> > 
> > IoConnector connector = new SocketConnector()
> > BaseIoConnectorConfig connectorConfig = new
> > SocketConnectorConfig();
> > 
> > connectorConfig.setConnectTimeout( connectTimeOut
> );
> > connector.connect( host, sessionHandler,
> > connectorConfig );
> 
> I've been doing:
> 
>      private IoAcceptor acceptor;
>      private IoHandler handler;
> 
>      handler = new KerberosProtocolHandler();
>      acceptor.bind( new InetSocketAddress( port ),
> handler );
> 
> Enrique
> 


Re: What happened to SocketConnector.setConnectTimeout ?

Posted by Enrique Rodriguez <en...@gmail.com>.
Samuel Doyle wrote:
> Alright I assume this is how you do it. Can someone
> confirm?
> 
> IoConnector connector = new SocketConnector()
> BaseIoConnectorConfig connectorConfig = new
> SocketConnectorConfig();
> 
> connectorConfig.setConnectTimeout( connectTimeOut );
> connector.connect( host, sessionHandler,
> connectorConfig );

I've been doing:

     private IoAcceptor acceptor;
     private IoHandler handler;

     handler = new KerberosProtocolHandler();
     acceptor.bind( new InetSocketAddress( port ), handler );

Enrique

Re: What happened to SocketConnector.setConnectTimeout ?

Posted by Samuel Doyle <sd...@yahoo.com>.
Alright I assume this is how you do it. Can someone
confirm?

IoConnector connector = new SocketConnector()
BaseIoConnectorConfig connectorConfig = new
SocketConnectorConfig();

connectorConfig.setConnectTimeout( connectTimeOut );
connector.connect( host, sessionHandler,
connectorConfig );

Thanks, S.D.


--- Samuel Doyle <sd...@yahoo.com> wrote:

> It appears that the SocketConnector parent class 
> org.apache.mina.common.support.DelegatedIoConnector
> is
> missing from the javadocs.
> 
> S.D.
> 
> --- Samuel Doyle <sd...@yahoo.com> wrote:
> 
> > Where did this go? What should I use to replace
> it?
> > 
> > Thanks, S.D.
> > 
> 
> 


Re: What happened to SocketConnector.setConnectTimeout ?

Posted by Samuel Doyle <sd...@yahoo.com>.
It appears that the SocketConnector parent class 
org.apache.mina.common.support.DelegatedIoConnector is
missing from the javadocs.

S.D.

--- Samuel Doyle <sd...@yahoo.com> wrote:

> Where did this go? What should I use to replace it?
> 
> Thanks, S.D.
> 


What happened to SocketConnector.setConnectTimeout ?

Posted by Samuel Doyle <sd...@yahoo.com>.
Where did this go? What should I use to replace it?

Thanks, S.D.

Re: Attempt to upgrade to 0.9.3

Posted by peter royal <pr...@apache.org>.
On Apr 26, 2006, at 7:18 PM, Samuel Doyle wrote:
> There was a fair bit of code involved in this so any
> recommendations on the best way to tackle getting this
> working again with the latest version would be
> appreciated.

Take a look at the examples.. Service and ServiceRegistry have been  
removed.
-pete

-- 
proyal@apache.org - http://fotap.org/~osi



Attempt to upgrade to 0.9.3

Posted by Samuel Doyle <sd...@yahoo.com>.
So I attempted to upgrade my 0.9.0 prototype to 0.9.3
I was hoping replacing the jar with the new core jar
would do the trick, I guess that was wishful thinking.
:)
There was a fair bit of code involved in this so any
recommendations on the best way to tackle getting this
working again with the latest version would be
appreciated.

Thanks, S.D.

compile:
    [javac] Compiling 21 source files to
lib/java/classes
    [javac] BaseProcessor.java:23: package
org.apache.mina.registry does not exist
    [javac] import org.apache.mina.registry.Service;
    [javac]                                 ^
    [javac] BaseProcessor.java:24: package
org.apache.mina.registry does not exist
    [javac] import
org.apache.mina.registry.ServiceRegistry;
    [javac]                                 ^
    [javac] BaseProcessor.java:25: package
org.apache.mina.registry does not exist
    [javac] import
org.apache.mina.registry.SimpleServiceRegistry;
    [javac]                                 ^
    [javac] BaseProcessor.java:38: cannot find symbol
    [javac] symbol  : class ServiceRegistry
    [javac] location: class
com.wm.finance.epay.BaseProcessor
    [javac]    protected ServiceRegistry myRegistry =
null;
    [javac]              ^
    [javac] BaseProcessor.java:109: cannot find symbol
    [javac] symbol  : class ServiceRegistry
    [javac] location: class
com.wm.finance.epay.BaseProcessor
    [javac]    protected abstract void addLogger(
ServiceRegistry registry ) throws Exception;
    [javac]                                       ^
    [javac] ShoppingCardProcessor.java:32: package
org.apache.mina.registry does not exist
    [javac] import
org.apache.mina.registry.ServiceRegistry;
    [javac]                                 ^
    [javac] RTCCSessionHandler.java:34: cannot find
symbol
    [javac] symbol  : class SocketSession
    [javac] location: package
org.apache.mina.transport.socket.nio
    [javac] import
org.apache.mina.transport.socket.nio.SocketSession;
    [javac]                                           
 ^
    [javac] EPAYSessionHandler.java:36: cannot find
symbol
    [javac] symbol  : class SocketSession
    [javac] location: package
org.apache.mina.transport.socket.nio
    [javac] import
org.apache.mina.transport.socket.nio.SocketSession;
    [javac]                                           
 ^
    [javac] ShoppingCardProcessor.java:105: cannot
find symbol
    [javac] symbol  : class ServiceRegistry
    [javac] location: class
com.wm.finance.epay.shoppingcard.ShoppingCardProcessor
    [javac]    protected void addLogger(
ServiceRegistry registry ) throws Exception
    [javac]                              ^
    [javac] BaseProcessor.java:67: cannot find symbol
    [javac] symbol  : class SimpleServiceRegistry
    [javac] location: class
com.wm.finance.epay.BaseProcessor
    [javac]       this.myRegistry = new
SimpleServiceRegistry();
    [javac]                             ^
    [javac] BaseProcessor.java:83: cannot find symbol
    [javac] symbol  : class Service
    [javac] location: class
com.wm.finance.epay.BaseProcessor
    [javac]       Service service = new Service(
this.myName, TransportType.SOCKET, this.port );
    [javac]       ^
    [javac] BaseProcessor.java:83: cannot find symbol
    [javac] symbol  : class Service
    [javac] location: class
com.wm.finance.epay.BaseProcessor
    [javac]       Service service = new Service(
this.myName, TransportType.SOCKET, this.port );
    [javac]                             ^
    [javac] RTCCSessionHandler.java:76: cannot find
symbol
    [javac] symbol  : class SocketSession
    [javac] location: class
com.wm.finance.epay.shoppingcard.comms.RTCCSessionHandler
    [javac]       if( session instanceof SocketSession
)
    [javac]                              ^
    [javac] RTCCSessionHandler.java:78: cannot find
symbol
    [javac] symbol  : class SocketSession
    [javac] location: class
com.wm.finance.epay.shoppingcard.comms.RTCCSessionHandler
    [javac]          ( ( SocketSession ) session
).setSessionReceiveBufferSize( 2048 );
    [javac]              ^
    [javac] EPAYSessionHandler.java:78: cannot find
symbol
    [javac] symbol  : class SocketSession
    [javac] location: class
com.wm.finance.epay.shoppingcard.comms.EPAYSessionHandler
    [javac]       if( session instanceof SocketSession
)
    [javac]                              ^
    [javac] EPAYSessionHandler.java:80: cannot find
symbol
    [javac] symbol  : class SocketSession
    [javac] location: class
com.wm.finance.epay.shoppingcard.comms.EPAYSessionHandler
    [javac]          ( ( SocketSession ) session
).setSessionReceiveBufferSize( 2048 );
    [javac]              ^
    [javac] EPAYSessionPool.java:84: cannot find
symbol
    [javac] symbol  : method setConnectTimeout(int)
    [javac] location: interface
org.apache.mina.common.IoConnector
    [javac]       this.connector.setConnectTimeout(
this.connectTimeOut );
    [javac]       ^
    [javac] 17 errors