Re: Proxy server example -- introduce a random delay from client to proxied server?

2007-08-21 Thread Paul Furbacher

Maarten,

Thanks for the suggestion.  At first read, it seemed so obvious, so simple.

But besides a lot of debug error statements like the following

  [...] ServerToProxyIoHandler - [localhost/127.0.0.1:9001]
java.lang.IllegalStateException: Timer already cancelled.

and 

  [...] ClientToProxyIoHandler - [/127.0.0.1:60974]
java.lang.IllegalStateException: Timer already cancelled. ...


the messages arrive in the same order they were dispatched by the client.  

The desired effect of having the randomized delay is to scramble the message
order, something like the following:

Client send order   1 2 3 4 5 . . .

Client receive order   3 1 4 5 2 . . .

Perhaps an IoHandler is not the right place to do this? Would an IoFilter be
more appropriate?  

-- 

Paul Furbacher



Maarten Bosteels-4 wrote:
 
 Hello Paul,
 
 How about adding this to ClientToProxyIoHandler ?
 
 private Random random = new Random();
 private Timer timer = new Timer();
 
 public void messageReceived(final IoSession session, final Object
 message) throws Exception {
 final int c = counter.incrementAndGet();
 ByteBuffer rb = (ByteBuffer) message;
 final ByteBuffer wb = ByteBuffer.allocate(rb.remaining());
 rb.mark();
 wb.put(rb);
 wb.flip();
 rb.reset();
 long delay = random.nextInt(500);
 final IoSession proxySession = (IoSession)
 session.getAttachment();
 timer.schedule(
 new TimerTask() {
 public void run() {
 proxySession.write(wb);
 }
 }, delay);
 }
 
 Maarten
 
 --
 View this message in context:
 http://www.nabble.com/Proxy-server-exampleintroduce-a-random-delay-from-client-to-proxied-server--tf4301103s16868.html#a12242579
 Sent from the Apache MINA Support Forum mailing list archive at
 Nabble.com
 

-- 
View this message in context: 
http://www.nabble.com/Proxy-server-exampleintroduce-a-random-delay-from-client-to-proxied-server--tf4301103s16868.html#a12248916
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.



Re: Proxy server example -- introduce a random delay from client to proxied server?

2007-08-21 Thread Maarten Bosteels
On 8/21/07, Paul Furbacher [EMAIL PROTECTED] wrote:


 Maarten,

 Thanks for the suggestion.  At first read, it seemed so obvious, so
 simple.

 But besides a lot of debug error statements like the following

   [...] ServerToProxyIoHandler - [localhost/127.0.0.1:9001]
 java.lang.IllegalStateException: Timer already cancelled.

 and

   [...] ClientToProxyIoHandler - [/127.0.0.1:60974]
 java.lang.IllegalStateException: Timer already cancelled. ...


seems  like you  added the  TimerTask to both ClientToProxy and
ServerToProxy.
I only added  it to ClientToProxy and didn't get these errors.
But it is always possible that the proxied server closes the connection
before you could forward the request.

the messages arrive in the same order they were dispatched by the client.


That's odd, maybe you need higher variation in the delay ?
Do you have control over the server ? I mean, can you ensure that it does
not close the connections too early ?

The desired effect of having the randomized delay is to scramble the message
 order, something like the following:

 Client send order   1 2 3 4 5 . . .

 Client receive order   3 1 4 5 2 . . .

 Perhaps an IoHandler is not the right place to do this? Would an IoFilter
 be
 more appropriate?


I guess you only want to randomize the messages to test the server ?
Wouldn't it be simpler then to write a test-case that sends a hard-coded
list of messages (randomized by hand) ?

Maarten

--

 Paul Furbacher



 Maarten Bosteels-4 wrote:
 
  Hello Paul,
 
  How about adding this to ClientToProxyIoHandler ?
 
  private Random random = new Random();
  private Timer timer = new Timer();
 
  public void messageReceived(final IoSession session, final Object
  message) throws Exception {
  final int c = counter.incrementAndGet();
  ByteBuffer rb = (ByteBuffer) message;
  final ByteBuffer wb = ByteBuffer.allocate(rb.remaining());
  rb.mark();
  wb.put(rb);
  wb.flip();
  rb.reset();
  long delay = random.nextInt(500);
  final IoSession proxySession = (IoSession)
  session.getAttachment();
  timer.schedule(
  new TimerTask() {
  public void run() {
  proxySession.write(wb);
  }
  }, delay);
  }
 
  Maarten
 
  --
  View this message in context:
 
 http://www.nabble.com/Proxy-server-exampleintroduce-a-random-delay-from-client-to-proxied-server--tf4301103s16868.html#a12242579
  Sent from the Apache MINA Support Forum mailing list archive at
  Nabble.com
 

 --
 View this message in context:
 http://www.nabble.com/Proxy-server-exampleintroduce-a-random-delay-from-client-to-proxied-server--tf4301103s16868.html#a12248916
 Sent from the Apache MINA Support Forum mailing list archive at Nabble.com
 .




Re: [jira] Commented: (DIRMINA-223) Addition of SocketConnector method to handle socks proxies.

2007-08-21 Thread shila

Hi! I've the same problem and i don't be able to connect to my application
server through the proxy.
Here there's the code that i've use:
  Proxy proxyServer = new Proxy(Proxy.Type.SOCKS, new
InetSocketAddress(192.168.2.250, 3128));
  IoConnector connector = new SocketConnector(proxyServer);
  IoConnectorConfig config = new SocketConnectorConfig();
  config.setThreadModel(ThreadModel.MANUAL);
...
...sorry for my terrible english :-/

JIRA [EMAIL PROTECTED] wrote:
 
 [
 http://issues.apache.org/jira/browse/DIRMINA-223?page=comments#action_12432728
 ] 
 
 Trustin Lee commented on DIRMINA-223:
 -
 
 I found your patch won't work.  SocketChannel.open() is a static method,
 and therefore, socket.getChannel().open() doesn't have effect other than
 resource leakage due to an extra socket creation.
 
 NIO specification says that socket.getChannel() will return *null* unless
 the socket is created via SocketChannel.open().
 
 Are you sure that your patch is really working with a Proxy?
 
 Addition of SocketConnector method to handle socks proxies.
 ---

 Key: DIRMINA-223
 URL: http://issues.apache.org/jira/browse/DIRMINA-223
 Project: Directory MINA
  Issue Type: Improvement
Affects Versions: 0.9.4
 Environment: All platforms
Reporter: John Preston

 When using MINA to to establish a SocketConnector behind a firewall it is
 necessary to specify socks proxie to use. The SocketConnector can be
 ammended as follows: (svn diff)
 Index:
 core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java
 ===
 ---
 core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java
 (revision 415629)
 +++
 core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java
 (working copy)
 @@ -21,6 +21,7 @@
  import java.io.IOException;
  import java.net.ConnectException;
  import java.net.InetSocketAddress;
 +import java.net.Proxy;
  import java.net.SocketAddress;
  import java.nio.channels.SelectionKey;
  import java.nio.channels.Selector;
 @@ -61,6 +62,7 @@
  private final Set managedSessions = Collections.synchronizedSet( new
 HashSet() );
  private final SocketIoProcessor[] ioProcessors;
  private final int processorCount;
 +private final Proxy socketProxy;
  
  /**
   * @noinspection FieldAccessedSynchronizedAndUnsynchronized
 @@ -73,9 +75,17 @@
  /**
   * Create a connector with a single processing thread
   */
 +public SocketConnector(Proxy proxy)
 +{
 +this( 1, proxy );
 +}
 +
 +/**
 + * Create a connector with a single processing thread
 + */
  public SocketConnector()
  {
 -this( 1 );
 +this( 1, Proxy.NO_PROXY );
  }
  
  /**
 @@ -83,7 +93,7 @@
   *
   * @param processorCount Number of processing threads
   */
 -public SocketConnector( int processorCount )
 +public SocketConnector( int processorCount, Proxy proxy )
  {
  if( processorCount  1 )
  {
 @@ -91,6 +101,7 @@
  }
  
  this.processorCount = processorCount;
 +this.socketProxy = proxy == null ? Proxy.NO_PROXY : proxy;
  ioProcessors = new SocketIoProcessor[processorCount];
  
  for( int i = 0; i  processorCount; i++ )
 @@ -153,11 +164,12 @@
  boolean success = false;
  try
  {
 -ch = SocketChannel.open();
 -ch.socket().setReuseAddress( true );
 +Socket s = new Socket(socketProxy);
 +s.setReuseAddress( true );
 +ch = s.getChannel().open();
  if( localAddress != null )
  {
 -ch.socket().bind( localAddress );
 +s.bind( localAddress );
  }
  
  ch.configureBlocking( false );
 @@ -475,4 +487,4 @@
  this.config = config;
  }
  }
 -}
 \ No newline at end of file
 +}
 
 -- 
 This message is automatically generated by JIRA.
 -
 If you think it was sent incorrectly contact one of the administrators:
 http://issues.apache.org/jira/secure/Administrators.jspa
 -
 For more information on JIRA, see: http://www.atlassian.com/software/jira
 
 
 
 
 

-- 
View this message in context: 
http://www.nabble.com/-jira--Created%3A-%28DIRMINA-223%29-Addition-of-SocketConnector-method-to-handle-socks-proxies.-tf2697070s16868.html#a12251387
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.



Re: Mina throughput

2007-08-21 Thread mat
The reason why I raised this thread is: recently I am really bothered with
following issue.

My mina component has to connect to a legacy server written in C++. C++
server just simply sends out the struct as a message. I think for a C++
program it is just simple return the struct pointer and use each field.
However, to my java program that is a disaster(also really lower the
performance). I have to use all the system.arraycopy to make up each
field.(Actually it causes OOM). I don't know if you guys ever faced this
kind of problem. How to solve it?


On 8/11/07, Emmanuel Lecharny [EMAIL PROTECTED] wrote:

 Hi guys,

 when guessing relative performances of Java/C++ on a network
 environment, please keep in mind that data processing will be
 processed orders or magnitude faster than simple network handling by
 the underlying layer. Thinking that Java is slower than C++ to handle
 messages on a network based application because it does not have
 pointers is out of base.

 FYI, I have tested our LDAP server on my laptop, sending Search
 requests through MINA (Apache Directory Server is based on MINA, 1.0.3
 version), and I got something like 5000 req/s (a request is around
 1kb), assuming that almost all the time is spent internally to the
 server itself, not in the MINA layer. Btw, LDAP messages are binary,
 but that does not mean it's easier to decode them in C/C++ than in
 Java (I would say that the complexity is exactly the same for both
 languages).

 I don't want to start a flame war, but I encourage anyone who want to
 compare Java and C++ to compare things that are comparable, and not
 blind guess what can be slow or fast in both languages.

 My 2cts
 Emmanuel

 On 8/11/07, mat [EMAIL PROTECTED] wrote:
  Actually the windows IOCP server is written in C++ and it is running on
 a pc
  server. I believe the reasons why Java can't reach that performance
  sometimes due to lack of structure(pointer). I find it is really
 cumbersome
  job to decode a binary message in Java. I don't know if you guys have
 better
  solution to decode the binary format and manipulate the each field in
 the
  binary message.
 
  On 8/11/07, Michael Grundvig [EMAIL PROTECTED] wrote:
  
   I don't have the exact numbers but I know on a big Linux box (8
   processors,
   8 gb ram) with a switched gigabit backbone we have seen greater then
   45,000 - 50,000 messages per second sustained. Ultimately the problem
   becomes a matter of garbage collector churn rather then IO overhead.
 On
   Windows machines we could get only to a fraction of that. We believe
 the
   underlying I/O differences between Windows and *nix become really
 obvious
   when you get to higher message counts.
  
   Michael
  
   - Original Message -
   From: mat [EMAIL PROTECTED]
   To: dev dev@mina.apache.org
   Sent: Friday, August 10, 2007 11:24 AM
   Subject: Mina throughput
  
  
Does anyone have the throughput test by raw socket communication
(keep-alive
mode)? My colleague wrote a windows IOCP server whose throughput
 could
reach
1.8m/sec. (5000message/sec in intranet).
   
  
  
 


 --
 Regards,
 Cordialement,
 Emmanuel Lécharny
 www.iktek.com



Re: Mina throughput

2007-08-21 Thread Jeroen Brattinga




Well, I just use the (Mina) ByteBuffer (see
http://mina.apache.org/report/1.1/apidocs/org/apache/mina/common/ByteBuffer.html)
methods to get each field (e.g. getUnsignedInt, getString, getChar). I
have one class that does the basic unpacking (header, CRC, payload size
etc.), and some more specific classes that worry about the payload. I
didn't find it cumbersome, although a struct would have been easier. 

But now that it's implemented, I only deal with nice and easy message
objects that contain the processed data (using the
DemuxingProtocolCodecFactory).

Could you give a more detailed specification of one of your packets? It
would give us some more insight into the problem. 


Jeroen Brattinga


mat wrote:

  The reason why I raised this thread is: recently I am really bothered with
following issue.

My mina component has to connect to a legacy server written in C++. C++
server just simply sends out the struct as a message. I think for a C++
program it is just simple return the struct pointer and use each field.
However, to my java program that is a disaster(also really lower the
performance). I have to use all the system.arraycopy to make up each
field.(Actually it causes OOM). I don't know if you guys ever faced this
kind of problem. How to solve it?


On 8/11/07, Emmanuel Lecharny [EMAIL PROTECTED] wrote:
  
  
Hi guys,

when guessing relative performances of Java/C++ on a network
environment, please keep in mind that data processing will be
processed orders or magnitude faster than simple network handling by
the underlying layer. Thinking that Java is slower than C++ to handle
messages on a network based application because it does not have
pointers is out of base.

FYI, I have tested our LDAP server on my laptop, sending Search
requests through MINA (Apache Directory Server is based on MINA, 1.0.3
version), and I got something like 5000 req/s (a request is around
1kb), assuming that almost all the time is spent internally to the
server itself, not in the MINA layer. Btw, LDAP messages are binary,
but that does not mean it's easier to decode them in C/C++ than in
Java (I would say that the complexity is exactly the same for both
languages).

I don't want to start a flame war, but I encourage anyone who want to
compare Java and C++ to compare things that are comparable, and not
blind guess what can be slow or fast in both languages.

My 2cts
Emmanuel

On 8/11/07, mat [EMAIL PROTECTED] wrote:


  Actually the windows IOCP server is written in C++ and it is running on
  

a pc


  server. I believe the reasons why Java can't reach that performance
sometimes due to lack of structure(pointer). I find it is really
  

cumbersome


  job to decode a binary message in Java. I don't know if you guys have
  

better


  solution to decode the binary format and manipulate the each field in
  

the


  binary message.

On 8/11/07, Michael Grundvig [EMAIL PROTECTED] wrote:
  
  
I don't have the exact numbers but I know on a big Linux box (8
processors,
8 gb ram) with a switched gigabit backbone we have seen greater then
45,000 - 50,000 messages per second sustained. Ultimately the problem
becomes a matter of garbage collector churn rather then IO overhead.

  

On


  
Windows machines we could get only to a fraction of that. We believe

  

the


  
underlying I/O differences between Windows and *nix become really

  

obvious


  
when you get to higher message counts.

Michael

- Original Message -
From: "mat" [EMAIL PROTECTED]
To: "dev" dev@mina.apache.org
Sent: Friday, August 10, 2007 11:24 AM
Subject: Mina throughput




  Does anyone have the throughput test by raw socket communication
(keep-alive
mode)? My colleague wrote a windows IOCP server whose throughput
  

  

could


  

  reach
1.8m/sec. (5000message/sec in intranet).

  



  


--
Regards,
Cordialement,
Emmanuel Lcharny
www.iktek.com


  
  
  





[jira] Commented: (DIRMINA-353) Import AsyncWeb from Safehaus

2007-08-21 Thread Mike Heath (JIRA)

[ 
https://issues.apache.org/jira/browse/DIRMINA-353?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12521530
 ] 

Mike Heath commented on DIRMINA-353:


This template 
http://incubator.apache.org/ip-clearance/ip-clearance-template.html indicates 
that only Apache members and officers may execute IP clearance processing.  
With that being that case.  What can I do to get this ball rolling?  Would it 
be appropriate for me to fill out the template and attach it to this issue so 
that an Apache Member can actually submit it to the incubator?

 Import AsyncWeb from Safehaus
 -

 Key: DIRMINA-353
 URL: https://issues.apache.org/jira/browse/DIRMINA-353
 Project: MINA
  Issue Type: Task
Reporter: Cameron Taggart

 From the [EMAIL PROTECTED] mailing list where AsyncWeb currently is:
 (1) Trustin as the MINA chair needs to check that the software grant has
 been filed by the ASF Secretary after receiving it via fax from LogicaCMG.
 (2) The MINA TLP must complete the IP Clearance process to enable an
 import into their SVN repository:
http://incubator.apache.org/ip-clearance/index.html
 HTH,
 Alex
 James Im wrote:
  I'm afraid I don't understand the process (I'm not involved in it, just
  curious).
 
  Who needs to do what now?
  Alex Karasulu wrote:
  Cameron Taggart wrote:
  Alex, did you receive the ASF release grant that Dave is referring to?
  Isn't that that only thing keeping it from being moved over under
  MINA?
 
  I reported the notification the LogicaCMG lawyers gave me then ping'd
  the MINA PMC to watch the software grants file for commits by the ASF
  secretary.
 
  My job was to make that happen.  I think it has someone just needs to
  check the software grants file.
 
  Alex

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



Re: Mina throughput

2007-08-21 Thread Emmanuel Lecharny
Even in C/C++, when you want to stream data, you have to do your
homework : serialize the structure. There is no easy and simple way to
flush a pointer, unless you just want to flush the address !

So basically, I really see no difference between C/C++ and JAVA when
it comes to serialize data and send them through a network, using a
protocol. This is the reason why some weird people are defining
protocols to transfert data...

If you are using Java, you have simple ways to serialize data, by
implementing the serializable interface : your objects will be
automatically serialized, using introspection (something you can't do
in C/C++). This won't be the fastest way to serialize data, but at the
end, it's order of magnitude faster than the timeit takes to transfer
data through the network anyways !

Hope it helps.

On 8/21/07, Jeroen Brattinga [EMAIL PROTECTED] wrote:

  Well, I just use the (Mina) ByteBuffer (see
 http://mina.apache.org/report/1.1/apidocs/org/apache/mina/common/ByteBuffer.html)
 methods to get each field (e.g. getUnsignedInt, getString, getChar). I have
 one class that does the basic unpacking (header, CRC, payload size etc.),
 and some more specific classes that worry about the payload. I didn't find
 it cumbersome, although a struct would have been easier.

  But now that it's implemented, I only deal with nice and easy message
 objects that contain the processed data (using the
 DemuxingProtocolCodecFactory).

  Could you give a more detailed specification of one of your packets? It
 would give us some more insight into the problem.


  Jeroen Brattinga



  mat wrote:
  The reason why I raised this thread is: recently I am really bothered with
 following issue.

 My mina component has to connect to a legacy server written in C++. C++
 server just simply sends out the struct as a message. I think for a C++
 program it is just simple return the struct pointer and use each field.
 However, to my java program that is a disaster(also really lower the
 performance). I have to use all the system.arraycopy to make up each
 field.(Actually it causes OOM). I don't know if you guys ever faced this
 kind of problem. How to solve it?


 On 8/11/07, Emmanuel Lecharny [EMAIL PROTECTED] wrote:


  Hi guys,

 when guessing relative performances of Java/C++ on a network
 environment, please keep in mind that data processing will be
 processed orders or magnitude faster than simple network handling by
 the underlying layer. Thinking that Java is slower than C++ to handle
 messages on a network based application because it does not have
 pointers is out of base.

 FYI, I have tested our LDAP server on my laptop, sending Search
 requests through MINA (Apache Directory Server is based on MINA, 1.0.3
 version), and I got something like 5000 req/s (a request is around
 1kb), assuming that almost all the time is spent internally to the
 server itself, not in the MINA layer. Btw, LDAP messages are binary,
 but that does not mean it's easier to decode them in C/C++ than in
 Java (I would say that the complexity is exactly the same for both
 languages).

 I don't want to start a flame war, but I encourage anyone who want to
 compare Java and C++ to compare things that are comparable, and not
 blind guess what can be slow or fast in both languages.

 My 2cts
 Emmanuel

 On 8/11/07, mat [EMAIL PROTECTED] wrote:


  Actually the windows IOCP server is written in C++ and it is running on

  a pc


  server. I believe the reasons why Java can't reach that performance
 sometimes due to lack of structure(pointer). I find it is really

  cumbersome


  job to decode a binary message in Java. I don't know if you guys have

  better


  solution to decode the binary format and manipulate the each field in

  the


  binary message.

 On 8/11/07, Michael Grundvig [EMAIL PROTECTED] wrote:


  I don't have the exact numbers but I know on a big Linux box (8
 processors,
 8 gb ram) with a switched gigabit backbone we have seen greater then
 45,000 - 50,000 messages per second sustained. Ultimately the problem
 becomes a matter of garbage collector churn rather then IO overhead.

  On



  Windows machines we could get only to a fraction of that. We believe

  the



  underlying I/O differences between Windows and *nix become really

  obvious



  when you get to higher message counts.

 Michael

 - Original Message -
 From: mat [EMAIL PROTECTED]
 To: dev dev@mina.apache.org
 Sent: Friday, August 10, 2007 11:24 AM
 Subject: Mina throughput




  Does anyone have the throughput test by raw socket communication
 (keep-alive
 mode)? My colleague wrote a windows IOCP server whose throughput

  could




  reach
 1.8m/sec. (5000message/sec in intranet).



  --
 Regards,
 Cordialement,
 Emmanuel Lécharny
 www.iktek.com






-- 
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com


Re: Asynchronous Http Client donation

2007-08-21 Thread Jeff Genender
Let me know when you have moved the code over so I can start submitting
patches to it since I am developing against the Geronimo sandbox now.

Thanks,

Jeff

Mark wrote:
 I created a mina-httpclient component on the trunk.  Just working things
 out, along with an example and I will check things in.
 
 
 On 8/21/07, Mike Heath [EMAIL PROTECTED] wrote:
 This sounds awesome!

 I would like to see this as the client part of AsyncWeb for two reasons.
   First it seams to be a natural fit.  Second it might give us a little
 more incentive to finally get AsycWeb moved over to MINA.

 -Mike

 Jeff Genender wrote:
 Hi,

 First, I want to say that I am a big fan of Mina.  For those who don't
 know me (which is everyone), I am a committer on Geronimo and have had
 several people ask about an async http client API to use with our NIO
 clients with comet for the 2.0 Geronimo server.  We have had folks who
 want to be able to do HTTP calls to 3rd party servers from servlets/web
 apps to get content, and not tie up a thread while its doing its thing.
  So I decided to try to whip together an API that was similar to Commons
 HttpClient, fully asynchronous, but based on Mina...and I think I have
 80-90% of it completed.  It is here:

 http://svn.apache.org/repos/asf/geronimo/sandbox/AsyncHttpClient

 For what it's worth...it doesn't seem appropriate for Geronimo. So I
 would like to donate it to Mina.  Please have a look at it and give me
 feed back for if I have gone down the right path.  It can be enhanced
 greatly as this is just a start, but I think it can be very useful and
 become a powerful API with everyone moving to NIO.

 Don't hold back any comments ;-)  I would really like to see an API like
 this and I believe Mina is just perfect for this.

 Please let me know what you think..and if you don't think its right for
 Mina..thats ok too ;-)  But getting your feedback would be best for
 me...and making this a community project is even better ;-)

 Jeff


 
 


Re: Asynchronous Http Client donation

2007-08-21 Thread Mark
will do.  BTW, do you have any code that I could use in the mina-examples
component?  I have the code you wrote up to MINA 2.0 compliance, but I want
to provide a sample program as well.

Thanks,
Mark

On 8/21/07, Jeff Genender [EMAIL PROTECTED] wrote:

 Let me know when you have moved the code over so I can start submitting
 patches to it since I am developing against the Geronimo sandbox now.

 Thanks,

 Jeff

 Mark wrote:
  I created a mina-httpclient component on the trunk.  Just working things
  out, along with an example and I will check things in.
 
 
  On 8/21/07, Mike Heath [EMAIL PROTECTED] wrote:
  This sounds awesome!
 
  I would like to see this as the client part of AsyncWeb for two
 reasons.
First it seams to be a natural fit.  Second it might give us a little
  more incentive to finally get AsycWeb moved over to MINA.
 
  -Mike
 
  Jeff Genender wrote:
  Hi,
 
  First, I want to say that I am a big fan of Mina.  For those who don't
  know me (which is everyone), I am a committer on Geronimo and have had
  several people ask about an async http client API to use with our NIO
  clients with comet for the 2.0 Geronimo server.  We have had folks who
  want to be able to do HTTP calls to 3rd party servers from
 servlets/web
  apps to get content, and not tie up a thread while its doing its
 thing.
   So I decided to try to whip together an API that was similar to
 Commons
  HttpClient, fully asynchronous, but based on Mina...and I think I have
  80-90% of it completed.  It is here:
 
  http://svn.apache.org/repos/asf/geronimo/sandbox/AsyncHttpClient
 
  For what it's worth...it doesn't seem appropriate for Geronimo. So I
  would like to donate it to Mina.  Please have a look at it and give me
  feed back for if I have gone down the right path.  It can be enhanced
  greatly as this is just a start, but I think it can be very useful and
  become a powerful API with everyone moving to NIO.
 
  Don't hold back any comments ;-)  I would really like to see an API
 like
  this and I believe Mina is just perfect for this.
 
  Please let me know what you think..and if you don't think its right
 for
  Mina..thats ok too ;-)  But getting your feedback would be best for
  me...and making this a community project is even better ;-)
 
  Jeff
 
 
 
 




-- 
..Cheers
Mark


Re: Asynchronous Http Client donation

2007-08-21 Thread Jeff Genender
Mark,

Have a look look at:

src/test/java/org/apache/ahc/AsyncHttpClientTest.java

The doConnection() is pretty much an example.  Basically, you set up an
implementation of the AHCCallback to notify you of a response, set up a
HttpRequestMessage for your URI, and then make the call to ahc.connect()
 and ahc.sendRequest(request).

However, I am probably going to get rid of the direct access to the
HttpRequestMessage and have folks just set/get on the AsyncHttpClient
object, which will act as a proxy to the HttpRequestMessage.  This will
simplify things.  I will also probably get rid of the sendRequest() and
have everything happen in the connect() method as a single async call -
again to simplify its use.

There are a few TODOs I am currently working on.

1) I am working on the HTTP/1.1 chunking (hopefully be done today).
2) Need to handle the HTTP/1.1 100 Continue (should be easy to do).
3) Auto-handle 301 Redirect.
4) Handle proxies.
5) A good timeout implementation.  Not sure whether to use the
sessionIdle() or use a concurrent timer.  Since its a single
request/response, sessionIdle() may work fine.
6) Possibly allow handling of streams for very large packets (right now
it pulls the entire response into memory - which works for 99% of the
use cases).  But it would be nice to allow people to get their data
moved in chunks.  I probably need some input on implementing this
efficiently...but I think this is the lowest priority item.
7) Finer grained control over the threading model.  Basically allow
people to tweak the thread pool or pass in their own to use.

What currently works:

A) HTTPS/SSL/HTTP submission and response
B) Cookie handling
C) Header handling
D) Parameter handling (web parameters)
E) All HTTP request types (GET, POST, etc)
D) Text and Binary responses

As for the donation's being up to Apache spec...I am already an Apache
guy (CLA already on file) and it's coming from Apache into Apache ;-)
AFICT I have all of the necessary headers are in the source - hopefully
I haven't missed anything.  We probably just need to rename the
packages, etc, to something more meaningful/appropriate to Mina.

Thanks,

Jeff

Mark wrote:
 will do.  BTW, do you have any code that I could use in the mina-examples
 component?  I have the code you wrote up to MINA 2.0 compliance, but I want
 to provide a sample program as well.
 
 Thanks,
 Mark
 
 On 8/21/07, Jeff Genender [EMAIL PROTECTED] wrote:
 Let me know when you have moved the code over so I can start submitting
 patches to it since I am developing against the Geronimo sandbox now.

 Thanks,

 Jeff

 Mark wrote:
 I created a mina-httpclient component on the trunk.  Just working things
 out, along with an example and I will check things in.


 On 8/21/07, Mike Heath [EMAIL PROTECTED] wrote:
 This sounds awesome!

 I would like to see this as the client part of AsyncWeb for two
 reasons.
   First it seams to be a natural fit.  Second it might give us a little
 more incentive to finally get AsycWeb moved over to MINA.

 -Mike

 Jeff Genender wrote:
 Hi,

 First, I want to say that I am a big fan of Mina.  For those who don't
 know me (which is everyone), I am a committer on Geronimo and have had
 several people ask about an async http client API to use with our NIO
 clients with comet for the 2.0 Geronimo server.  We have had folks who
 want to be able to do HTTP calls to 3rd party servers from
 servlets/web
 apps to get content, and not tie up a thread while its doing its
 thing.
  So I decided to try to whip together an API that was similar to
 Commons
 HttpClient, fully asynchronous, but based on Mina...and I think I have
 80-90% of it completed.  It is here:

 http://svn.apache.org/repos/asf/geronimo/sandbox/AsyncHttpClient

 For what it's worth...it doesn't seem appropriate for Geronimo. So I
 would like to donate it to Mina.  Please have a look at it and give me
 feed back for if I have gone down the right path.  It can be enhanced
 greatly as this is just a start, but I think it can be very useful and
 become a powerful API with everyone moving to NIO.

 Don't hold back any comments ;-)  I would really like to see an API
 like
 this and I believe Mina is just perfect for this.

 Please let me know what you think..and if you don't think its right
 for
 Mina..thats ok too ;-)  But getting your feedback would be best for
 me...and making this a community project is even better ;-)

 Jeff


 
 
 


Re: Asynchronous Http Client donation

2007-08-21 Thread Mike Heath
I'm wondering where this project should really go.  Do we want to make 
it part of MINA (ie. put it in mina/trunk) or do we want to create a 
separate subproject that depends on MINA (ie. put it in something like 
mina/async-httpclient/trunk).


I'm concerned about the agility of MINA if we start adding protocol 
handlers to MINA itself.  What if we make a change to MINA that breaks 
one of our protocol handlers?  What if there's a bug in a protocol 
handler that doesn't affect 99.9% of MINA's user base?  Will these 
problems keep us from making releases?  If we fix a major bug in MINA 
that doesn't affect async-httpclient, do we still release a new version 
of async-httpclient with MINA because async-httpclient is part of the 
baseline MINA build?


I would rather see async-httpclient be a subproject of MINA and have it 
reside it's own directory in subversion with its own build and with its 
own examples separate from the MINA examples.


That being said, I would MUCH rather see AsyncWeb finally moved over to 
MINA as a sub-project and then make async-httpclient part of AsyncWeb. 
There's certainly going to be a lot of overlap between the two.  We 
should leverage that.


-Mike

Mark wrote:

I created a mina-httpclient component on the trunk.  Just working things
out, along with an example and I will check things in.


On 8/21/07, Mike Heath [EMAIL PROTECTED] wrote:

This sounds awesome!

I would like to see this as the client part of AsyncWeb for two reasons.
  First it seams to be a natural fit.  Second it might give us a little
more incentive to finally get AsycWeb moved over to MINA.

-Mike

Jeff Genender wrote:

Hi,

First, I want to say that I am a big fan of Mina.  For those who don't
know me (which is everyone), I am a committer on Geronimo and have had
several people ask about an async http client API to use with our NIO
clients with comet for the 2.0 Geronimo server.  We have had folks who
want to be able to do HTTP calls to 3rd party servers from servlets/web
apps to get content, and not tie up a thread while its doing its thing.
 So I decided to try to whip together an API that was similar to Commons
HttpClient, fully asynchronous, but based on Mina...and I think I have
80-90% of it completed.  It is here:

http://svn.apache.org/repos/asf/geronimo/sandbox/AsyncHttpClient

For what it's worth...it doesn't seem appropriate for Geronimo. So I
would like to donate it to Mina.  Please have a look at it and give me
feed back for if I have gone down the right path.  It can be enhanced
greatly as this is just a start, but I think it can be very useful and
become a powerful API with everyone moving to NIO.

Don't hold back any comments ;-)  I would really like to see an API like
this and I believe Mina is just perfect for this.

Please let me know what you think..and if you don't think its right for
Mina..thats ok too ;-)  But getting your feedback would be best for
me...and making this a community project is even better ;-)

Jeff










Re: Asynchronous Http Client donation

2007-08-21 Thread Jeff Genender
Mike,

I would concur with you on this.  I think a sub-project of its own is
good since it can be used as a standalone API (with a dependency on Mina
of course).  I would recommend that this API be a separate artifact from
asyncweb as I think we want the client to be capable of being slit off
from the server (for obvious reasons).

Jeff

Mike Heath wrote:
 I'm wondering where this project should really go.  Do we want to make
 it part of MINA (ie. put it in mina/trunk) or do we want to create a
 separate subproject that depends on MINA (ie. put it in something like
 mina/async-httpclient/trunk).
 
 I'm concerned about the agility of MINA if we start adding protocol
 handlers to MINA itself.  What if we make a change to MINA that breaks
 one of our protocol handlers?  What if there's a bug in a protocol
 handler that doesn't affect 99.9% of MINA's user base?  Will these
 problems keep us from making releases?  If we fix a major bug in MINA
 that doesn't affect async-httpclient, do we still release a new version
 of async-httpclient with MINA because async-httpclient is part of the
 baseline MINA build?
 
 I would rather see async-httpclient be a subproject of MINA and have it
 reside it's own directory in subversion with its own build and with its
 own examples separate from the MINA examples.
 
 That being said, I would MUCH rather see AsyncWeb finally moved over to
 MINA as a sub-project and then make async-httpclient part of AsyncWeb.
 There's certainly going to be a lot of overlap between the two.  We
 should leverage that.
 
 -Mike
 
 Mark wrote:
 I created a mina-httpclient component on the trunk.  Just working things
 out, along with an example and I will check things in.


 On 8/21/07, Mike Heath [EMAIL PROTECTED] wrote:
 This sounds awesome!

 I would like to see this as the client part of AsyncWeb for two reasons.
   First it seams to be a natural fit.  Second it might give us a little
 more incentive to finally get AsycWeb moved over to MINA.

 -Mike

 Jeff Genender wrote:
 Hi,

 First, I want to say that I am a big fan of Mina.  For those who don't
 know me (which is everyone), I am a committer on Geronimo and have had
 several people ask about an async http client API to use with our NIO
 clients with comet for the 2.0 Geronimo server.  We have had folks who
 want to be able to do HTTP calls to 3rd party servers from servlets/web
 apps to get content, and not tie up a thread while its doing its thing.
  So I decided to try to whip together an API that was similar to
 Commons
 HttpClient, fully asynchronous, but based on Mina...and I think I have
 80-90% of it completed.  It is here:

 http://svn.apache.org/repos/asf/geronimo/sandbox/AsyncHttpClient

 For what it's worth...it doesn't seem appropriate for Geronimo. So I
 would like to donate it to Mina.  Please have a look at it and give me
 feed back for if I have gone down the right path.  It can be enhanced
 greatly as this is just a start, but I think it can be very useful and
 become a powerful API with everyone moving to NIO.

 Don't hold back any comments ;-)  I would really like to see an API
 like
 this and I believe Mina is just perfect for this.

 Please let me know what you think..and if you don't think its right for
 Mina..thats ok too ;-)  But getting your feedback would be best for
 me...and making this a community project is even better ;-)

 Jeff






Re: Mina throughput

2007-08-21 Thread mat
Thanks. I remember Trustin mentioned your project once in this forum. I did
some research last night before I saw your thread. :) BTW, how do you handle
Big Little Endian thing in your project? The examples and tutorials are too
simple to understand. and why you consider it is fast?

On 8/22/07, Mehmet D. AKIN [EMAIL PROTECTED] wrote:

 On 8/21/07, mat [EMAIL PROTECTED] wrote:
  The reason why I raised this thread is: recently I am really bothered
 with
  following issue.
 
  My mina component has to connect to a legacy server written in C++. C++
  server just simply sends out the struct as a message. I think for a C++
  program it is just simple return the struct pointer and use each field.
  However, to my java program that is a disaster(also really lower the
  performance). I have to use all the system.arraycopy to make up each
  field.(Actually it causes OOM). I don't know if you guys ever faced this
  kind of problem. How to solve it?
 
 [snip]

 well there is a small library I am working on, It helps protocol
 programmers by allowing java classes to be somewhat treated as C - C++
 structs. You might want to check it, it uses annotations and
 reflection and reasonably fast.
 I am still working on it so there is no guarantee that its interfaces
 wont change, but it works, and there are examples on the site (an
 adobe color book reader-writer), check the wiki pages of project.

 site is:  http://code.google.com/p/javastruct/

 Mehmet



Re: Mina throughput

2007-08-21 Thread mat
Thanks. Emmanuel,

I heard people transfer serialized object among different VMs. However, I
believed serialize really takes IO, right? I don't know if it is suitable
for my case. (thousands of message/sec)Furtheremore, in my project, my java
server has to talk to C++ server.

On 8/22/07, Emmanuel Lecharny [EMAIL PROTECTED] wrote:

 Even in C/C++, when you want to stream data, you have to do your
 homework : serialize the structure. There is no easy and simple way to
 flush a pointer, unless you just want to flush the address !

 So basically, I really see no difference between C/C++ and JAVA when
 it comes to serialize data and send them through a network, using a
 protocol. This is the reason why some weird people are defining
 protocols to transfert data...

 If you are using Java, you have simple ways to serialize data, by
 implementing the serializable interface : your objects will be
 automatically serialized, using introspection (something you can't do
 in C/C++). This won't be the fastest way to serialize data, but at the
 end, it's order of magnitude faster than the timeit takes to transfer
 data through the network anyways !

 Hope it helps.

 On 8/21/07, Jeroen Brattinga [EMAIL PROTECTED] wrote:
 
   Well, I just use the (Mina) ByteBuffer (see
 
 http://mina.apache.org/report/1.1/apidocs/org/apache/mina/common/ByteBuffer.html
 )
  methods to get each field (e.g. getUnsignedInt, getString, getChar). I
 have
  one class that does the basic unpacking (header, CRC, payload size
 etc.),
  and some more specific classes that worry about the payload. I didn't
 find
  it cumbersome, although a struct would have been easier.
 
   But now that it's implemented, I only deal with nice and easy message
  objects that contain the processed data (using the
  DemuxingProtocolCodecFactory).
 
   Could you give a more detailed specification of one of your packets? It
  would give us some more insight into the problem.
 
 
   Jeroen Brattinga
 
 
 
   mat wrote:
   The reason why I raised this thread is: recently I am really bothered
 with
  following issue.
 
  My mina component has to connect to a legacy server written in C++. C++
  server just simply sends out the struct as a message. I think for a C++
  program it is just simple return the struct pointer and use each field.
  However, to my java program that is a disaster(also really lower the
  performance). I have to use all the system.arraycopy to make up each
  field.(Actually it causes OOM). I don't know if you guys ever faced this
  kind of problem. How to solve it?
 
 
  On 8/11/07, Emmanuel Lecharny [EMAIL PROTECTED] wrote:
 
 
   Hi guys,
 
  when guessing relative performances of Java/C++ on a network
  environment, please keep in mind that data processing will be
  processed orders or magnitude faster than simple network handling by
  the underlying layer. Thinking that Java is slower than C++ to handle
  messages on a network based application because it does not have
  pointers is out of base.
 
  FYI, I have tested our LDAP server on my laptop, sending Search
  requests through MINA (Apache Directory Server is based on MINA, 1.0.3
  version), and I got something like 5000 req/s (a request is around
  1kb), assuming that almost all the time is spent internally to the
  server itself, not in the MINA layer. Btw, LDAP messages are binary,
  but that does not mean it's easier to decode them in C/C++ than in
  Java (I would say that the complexity is exactly the same for both
  languages).
 
  I don't want to start a flame war, but I encourage anyone who want to
  compare Java and C++ to compare things that are comparable, and not
  blind guess what can be slow or fast in both languages.
 
  My 2cts
  Emmanuel
 
  On 8/11/07, mat [EMAIL PROTECTED] wrote:
 
 
   Actually the windows IOCP server is written in C++ and it is running on
 
   a pc
 
 
   server. I believe the reasons why Java can't reach that performance
  sometimes due to lack of structure(pointer). I find it is really
 
   cumbersome
 
 
   job to decode a binary message in Java. I don't know if you guys have
 
   better
 
 
   solution to decode the binary format and manipulate the each field in
 
   the
 
 
   binary message.
 
  On 8/11/07, Michael Grundvig [EMAIL PROTECTED] wrote:
 
 
   I don't have the exact numbers but I know on a big Linux box (8
  processors,
  8 gb ram) with a switched gigabit backbone we have seen greater then
  45,000 - 50,000 messages per second sustained. Ultimately the problem
  becomes a matter of garbage collector churn rather then IO overhead.
 
   On
 
 
 
   Windows machines we could get only to a fraction of that. We believe
 
   the
 
 
 
   underlying I/O differences between Windows and *nix become really
 
   obvious
 
 
 
   when you get to higher message counts.
 
  Michael
 
  - Original Message -
  From: mat [EMAIL PROTECTED]
  To: dev dev@mina.apache.org
  Sent: Friday, August 10, 2007 11:24 AM
  Subject: Mina throughput
 
 
 
 
   

Re: Mina throughput

2007-08-21 Thread Mehmet D. AKIN
Hi mat,

Actually it is not faster than any hand made protocol encoder -
decoder, since it has the overhead of reflection. But most of the time
the problem is not the encoding and decoding of streams, it is usually
I/O or processing (not decoding or encoding) of messages that causes
the performance problems. The aim of library is to make life easier if
you have lots of different types of messages to encode and decode.

But it is fast enough for most applications. It can encode or decode
more than 100.000 simple and small messages per second on an average
box. You should try it yourself to see whether it is appropriate for
your application.

As for the endian problem, it also contains Little endian data streams
for the job.

There is also a mina example in the samples directory.. It is not
complete, but gives an idea for use of javastruct for network
protocols.

Mehmet

On 8/21/07, mat [EMAIL PROTECTED] wrote:
 Thanks. I remember Trustin mentioned your project once in this forum. I did
 some research last night before I saw your thread. :) BTW, how do you handle
 Big Little Endian thing in your project? The examples and tutorials are too
 simple to understand. and why you consider it is fast?

 On 8/22/07, Mehmet D. AKIN [EMAIL PROTECTED] wrote:
 
  On 8/21/07, mat [EMAIL PROTECTED] wrote:
   The reason why I raised this thread is: recently I am really bothered
  with
   following issue.
  
   My mina component has to connect to a legacy server written in C++. C++
   server just simply sends out the struct as a message. I think for a C++
   program it is just simple return the struct pointer and use each field.
   However, to my java program that is a disaster(also really lower the
   performance). I have to use all the system.arraycopy to make up each
   field.(Actually it causes OOM). I don't know if you guys ever faced this
   kind of problem. How to solve it?
  
  [snip]
 
  well there is a small library I am working on, It helps protocol
  programmers by allowing java classes to be somewhat treated as C - C++
  structs. You might want to check it, it uses annotations and
  reflection and reasonably fast.
  I am still working on it so there is no guarantee that its interfaces
  wont change, but it works, and there are examples on the site (an
  adobe color book reader-writer), check the wiki pages of project.
 
  site is:  http://code.google.com/p/javastruct/
 
  Mehmet
 



Re: Asynchronous Http Client donation

2007-08-21 Thread Trustin Lee
On 8/22/07, Jeff Genender [EMAIL PROTECTED] wrote:
 Mike,

 I would concur with you on this.  I think a sub-project of its own is
 good since it can be used as a standalone API (with a dependency on Mina
 of course).  I would recommend that this API be a separate artifact from
 asyncweb as I think we want the client to be capable of being slit off
 from the server (for obvious reasons).

+ 1 here too.  and I didn't review the code yet.  Too much things to
handle these days.  Let me get back to you again soon.

Cheers,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6


Re: Mina throughput

2007-08-21 Thread mat
Thanks. I need read more about your source code and see if it helps. Great
job.

On 8/22/07, Mehmet D. AKIN [EMAIL PROTECTED] wrote:

 Hi mat,

 Actually it is not faster than any hand made protocol encoder -
 decoder, since it has the overhead of reflection. But most of the time
 the problem is not the encoding and decoding of streams, it is usually
 I/O or processing (not decoding or encoding) of messages that causes
 the performance problems. The aim of library is to make life easier if
 you have lots of different types of messages to encode and decode.

 But it is fast enough for most applications. It can encode or decode
 more than 100.000 simple and small messages per second on an average
 box. You should try it yourself to see whether it is appropriate for
 your application.

 As for the endian problem, it also contains Little endian data streams
 for the job.

 There is also a mina example in the samples directory.. It is not
 complete, but gives an idea for use of javastruct for network
 protocols.

 Mehmet

 On 8/21/07, mat [EMAIL PROTECTED] wrote:
  Thanks. I remember Trustin mentioned your project once in this forum. I
 did
  some research last night before I saw your thread. :) BTW, how do you
 handle
  Big Little Endian thing in your project? The examples and tutorials are
 too
  simple to understand. and why you consider it is fast?
 
  On 8/22/07, Mehmet D. AKIN [EMAIL PROTECTED] wrote:
  
   On 8/21/07, mat [EMAIL PROTECTED] wrote:
The reason why I raised this thread is: recently I am really
 bothered
   with
following issue.
   
My mina component has to connect to a legacy server written in C++.
 C++
server just simply sends out the struct as a message. I think for a
 C++
program it is just simple return the struct pointer and use each
 field.
However, to my java program that is a disaster(also really lower the
performance). I have to use all the system.arraycopy to make up each
field.(Actually it causes OOM). I don't know if you guys ever faced
 this
kind of problem. How to solve it?
   
   [snip]
  
   well there is a small library I am working on, It helps protocol
   programmers by allowing java classes to be somewhat treated as C - C++
   structs. You might want to check it, it uses annotations and
   reflection and reasonably fast.
   I am still working on it so there is no guarantee that its interfaces
   wont change, but it works, and there are examples on the site (an
   adobe color book reader-writer), check the wiki pages of project.
  
   site is:  http://code.google.com/p/javastruct/
  
   Mehmet
  
 



[jira] Commented: (DIRMINA-353) Import AsyncWeb from Safehaus

2007-08-21 Thread Trustin Lee (JIRA)

[ 
https://issues.apache.org/jira/browse/DIRMINA-353?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12521645
 ] 

Trustin Lee commented on DIRMINA-353:
-

We can import asyncweb directly into our trunk (or sandbox).  Peter or I can 
take care of it.  Let me raise the priority of this task in my personal to do 
list. :)

 Import AsyncWeb from Safehaus
 -

 Key: DIRMINA-353
 URL: https://issues.apache.org/jira/browse/DIRMINA-353
 Project: MINA
  Issue Type: Task
Reporter: Cameron Taggart

 From the [EMAIL PROTECTED] mailing list where AsyncWeb currently is:
 (1) Trustin as the MINA chair needs to check that the software grant has
 been filed by the ASF Secretary after receiving it via fax from LogicaCMG.
 (2) The MINA TLP must complete the IP Clearance process to enable an
 import into their SVN repository:
http://incubator.apache.org/ip-clearance/index.html
 HTH,
 Alex
 James Im wrote:
  I'm afraid I don't understand the process (I'm not involved in it, just
  curious).
 
  Who needs to do what now?
  Alex Karasulu wrote:
  Cameron Taggart wrote:
  Alex, did you receive the ASF release grant that Dave is referring to?
  Isn't that that only thing keeping it from being moved over under
  MINA?
 
  I reported the notification the LogicaCMG lawyers gave me then ping'd
  the MINA PMC to watch the software grants file for commits by the ASF
  secretary.
 
  My job was to make that happen.  I think it has someone just needs to
  check the software grants file.
 
  Alex

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



Re: two processes listening on same port

2007-08-21 Thread Trustin Lee
On 8/20/07, Maarten Bosteels [EMAIL PROTECTED] wrote:
 Hello all,

 I am witnessing some very weird behavior:  two processes listening on the
 same TCP port on the same machine.
 using Windows XP Professional

 I thought this might be possible because my portable is multi-homed (wired +
 wireless network) ?
 But I disabled the wireless network and it still works.

 1st process = org.apache.mina.example.chat.Main
 2nd process = org.apache.mina.example.chat.SpringMain

 Running two instances of org.apache.mina.example.chat.Main gives the
 expected Address already in use
 but it seems I can start as many instances of SpringMain as I want (I tried
 upto 6)

 Ok, this behavior is clearly a consequence of setting reuseAddress=true on
 the SocketAcceptor
 but I have never witnessed this behavior on linux.

 Does anybody know whether this is a documented feature on Windows ?

 C:\netstat -na | grep 1234
 TCP  0.0.0.0:1234 0.0.0.0:0 LISTENING
 TCP  0.0.0.0:1234 0.0.0.0:0 LISTENING
 TCP  127.0.0.1:1234   127.0.0.1:1379ESTABLISHED
 TCP  127.0.0.1:1379   127.0.0.1:1234ESTABLISHED
 (unfortunately netstat on windows doesn't have the -p option to show process
 id of listening process)

 Changing localAddress from  :1234  to 127.0.0.1:1234 or 
 192.168.0.5:1234 doesn't make a difference.

 Clients seem to connect to the process that was started last.
 And when that server stops, new connections are accepted by an 'older'
 server.

It's probably because of setReuseAddress().  We need to get rid of
that line from all examples.

Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6


Re: IoSessionLogger.trace()

2007-08-21 Thread Trustin Lee
On 8/19/07, Mark [EMAIL PROTECTED] wrote:
 I am getting compilation errors on the following methods:

 public static void trace(Logger log, IoSession session, String message)
 public static void trace(Logger log, IoSession session, String message,
 Throwable cause)

 Am I missing someting?  I just did an update in Eclipse, and the problem
 still exists.

You need to run mvn eclipse:eclipse (or the mvn-eclipse script) again
to synchronize the updated dependency information.

HTH,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6


[jira] Closed: (DIRMINA-425) Upgrade to SLF4J 1.4.3.

2007-08-21 Thread Trustin Lee (JIRA)

 [ 
https://issues.apache.org/jira/browse/DIRMINA-425?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Trustin Lee closed DIRMINA-425.
---

Resolution: Fixed

Done.

 Upgrade to SLF4J 1.4.3.
 ---

 Key: DIRMINA-425
 URL: https://issues.apache.org/jira/browse/DIRMINA-425
 Project: MINA
  Issue Type: Task
Reporter: Trustin Lee
Assignee: Trustin Lee
Priority: Trivial
 Fix For: 1.0.6, 1.1.3


 SLF4J 1.4.3 has been released.  Let's upgrade.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



[jira] Created: (DIRMINA-425) Upgrade to SLF4J 1.4.3.

2007-08-21 Thread Trustin Lee (JIRA)
Upgrade to SLF4J 1.4.3.
---

 Key: DIRMINA-425
 URL: https://issues.apache.org/jira/browse/DIRMINA-425
 Project: MINA
  Issue Type: Task
Reporter: Trustin Lee
Assignee: Trustin Lee
Priority: Trivial
 Fix For: 1.0.6, 1.1.3


SLF4J 1.4.3 has been released.  Let's upgrade.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



[jira] Created: (DIRMINA-426) Clean up POM dependencies using dependencyManagement section.

2007-08-21 Thread Trustin Lee (JIRA)
Clean up POM dependencies using dependencyManagement section.
-

 Key: DIRMINA-426
 URL: https://issues.apache.org/jira/browse/DIRMINA-426
 Project: MINA
  Issue Type: Task
Reporter: Trustin Lee
Priority: Minor
 Fix For: 2.0.0-M1


We are not using dependencyManagement section that greatly simplifies 
dependency management of POM.  Adding dependencyManagement section to the 
parent POM will save a lot of time when we upgrade a common dependency (e.g. 
SLF4J).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



Re: [jira] Commented: (DIRMINA-223) Addition of SocketConnector method to handle socks proxies.

2007-08-21 Thread Trustin Lee
On 8/21/07, shila [EMAIL PROTECTED] wrote:

 Hi! I've the same problem and i don't be able to connect to my application
 server through the proxy.
 Here there's the code that i've use:
   Proxy proxyServer = new Proxy(Proxy.Type.SOCKS, new
 InetSocketAddress(192.168.2.250, 3128));
   IoConnector connector = new SocketConnector(proxyServer);
   IoConnectorConfig config = new SocketConnectorConfig();
   config.setThreadModel(ThreadModel.MANUAL);
 ...
 ...sorry for my terrible english :-/

NIO doesn't support Java standard Proxy at all unfortunately for now.

HTH,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6


Re: Proxy server example -- introduce a random delay from client to proxied server?

2007-08-21 Thread Trustin Lee
On 8/21/07, Maarten Bosteels [EMAIL PROTECTED] wrote:
 On 8/21/07, Paul Furbacher [EMAIL PROTECTED] wrote:
 
 
  Maarten,
 
  Thanks for the suggestion.  At first read, it seemed so obvious, so
  simple.
 
  But besides a lot of debug error statements like the following
 
[...] ServerToProxyIoHandler - [localhost/127.0.0.1:9001]
  java.lang.IllegalStateException: Timer already cancelled.
 
  and
 
[...] ClientToProxyIoHandler - [/127.0.0.1:60974]
  java.lang.IllegalStateException: Timer already cancelled. ...


 seems  like you  added the  TimerTask to both ClientToProxy and
 ServerToProxy.
 I only added  it to ClientToProxy and didn't get these errors.
 But it is always possible that the proxied server closes the connection
 before you could forward the request.

 the messages arrive in the same order they were dispatched by the client.


 That's odd, maybe you need higher variation in the delay ?
 Do you have control over the server ? I mean, can you ensure that it does
 not close the connections too early ?

 The desired effect of having the randomized delay is to scramble the message
  order, something like the following:
 
  Client send order   1 2 3 4 5 . . .
 
  Client receive order   3 1 4 5 2 . . .
 
  Perhaps an IoHandler is not the right place to do this? Would an IoFilter
  be
  more appropriate?


 I guess you only want to randomize the messages to test the server ?
 Wouldn't it be simpler then to write a test-case that sends a hard-coded
 list of messages (randomized by hand) ?

Giving delay just randomly can cause mixed order of messages.  For
example, giving 500ms delay to the msg #1 and 1ms to #2 can switch the
order of messages.  The following code will work better:

   private volatile long lastScheduledTime = System.currentTimeMillis();
   private final Random random = new Random();
   private final Timer timer = new Timer();

   public void messageReceived(final IoSession session, final Object
message) throws Exception {
   final int c = counter.incrementAndGet();
   ByteBuffer rb = (ByteBuffer) message;
   final ByteBuffer wb = ByteBuffer.allocate(rb.remaining());
   rb.mark();
   wb.put(rb);
   wb.flip();
   rb.reset();
   long scheduledTime = lastScheduledTime + random.nextInt(500);
   final IoSession proxySession = (IoSession) session.getAttachment();
   timer.schedule(
   new TimerTask() {
   public void run() {
   proxySession.write(wb);
   }
   }, new Date(scheduledTime));;
   lastScheduledTime = scheduledTime;
   }

HTH,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6


Re: Running MINA inside Tomcat causing problems.

2007-08-21 Thread Trustin Lee
On 8/21/07, satish viswanatham [EMAIL PROTECTED] wrote:
 Hi

 I have a Servlet- which start TCP and UDP MINA servers. After receiving few
 packets on the server - the servlet gets un-deployed. Not java stack trace
 or details were available in the logs. Is there is a way to debug this? The
 code runs fine outside Tomcat.  I think MINA uses Sl4J and I made sure I
 have commons-logging.jar, log4j.jar and sl4j-log4j12-1.3.1.jar. I am using
 Tomcat 5.5.12. Which version of log4j does Tomcat 5.5.12 use? I tried with
 both Apache MINA 1.1 and 1.0. It has the same issue. I have just this web
 app deployed on tomcat.

 Please let me know, if you have suggestions.

I think it's a SLF4J problem.  Why don't you contact SLF4J mailing list?

Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6


Re: svn commit: r565676 - in /mina/trunk: core/src/main/java/org/apache/mina/common/ core/src/main/java/org/apache/mina/transport/socket/nio/ core/src/main/java/org/apache/mina/transport/socket/nio/su

2007-08-21 Thread Trustin Lee
On 8/21/07, Julien Vermillard [EMAIL PROTECTED] wrote:
 On Mon, 20 Aug 2007 23:42:37 +0900
 Trustin Lee [EMAIL PROTECTED] wrote:

  On 8/20/07, peter royal [EMAIL PROTECTED] wrote:
   On Aug 14, 2007, at 2:40 AM, [EMAIL PROTECTED] wrote:
Renamed TransportType to IoServiceMetadata because it stands what
it does more precisely
  
   This name seems odd to me.. I think of a 'service' as what I'm
   providing.. and MINA makes my service available over various
   transports (TCP,UDP,in-VM, etc)
  
   I do agree about it being 'Metadata' vs 'Type' though.
  
   How about TransportMetadata?

 Sound good for me too

OK, then let me rename it.

  TransportMetadata sounds good.  Then should we rename
  IoService.getMetadata() to getTransportMetadata()?  We could also
 Yes, will be more understandable.
  resurrect IoSession.getTransportMetadata() (was: getTransportType()).

 I liked this API change, since it's quite redundant.

If it's an IoServiceMetadata, IoSession doesn't need to provide the
metadata, but if it's a TransportMetadata, I think IoSession should
provide direct access to the metadata because it is independent from
IoService, like it was with TransportType.

Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6


[jira] Commented: (DIRMINA-422) create a new loggingfilter that leverages SLF4J's MDC feauture

2007-08-21 Thread Trustin Lee (JIRA)

[ 
https://issues.apache.org/jira/browse/DIRMINA-422?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12521652
 ] 

Trustin Lee commented on DIRMINA-422:
-

A few comments:

* We could use Runnable instead of introducing FilterAction.
* Let's make IoFilter methods in WrappingFilter 'final'.
* Very trivial thing but I'd prefer protected abstract to abstract protected.
* The name 'WrappingFilter' doesn't represent what it does clearly.  What would 
be a better name?  We will also have to change wrapFilterAction to something 
else.

 Depending on the relative position of ExecutorFilter and ProtocolCodecFilter
 more than one MdcLoggingFilter must be added to the chain
 (when you want the MDC to be set during encoding/decoding). 

We could simply change MdcLoggingFilter to MDCInjectionFilter and make it 
perform property injection only, and let LoggingFilter handle logging. (i.e. 
Separation of concern :) WDYT?



 create a new loggingfilter that leverages SLF4J's MDC feauture
 --

 Key: DIRMINA-422
 URL: https://issues.apache.org/jira/browse/DIRMINA-422
 Project: MINA
  Issue Type: New Feature
  Components: Filter
Reporter: Maarten Bosteels
Assignee: Maarten Bosteels
Priority: Minor
 Fix For: 2.0.0-M1


 A logging filter that puts some basic info about the IoSession in the MDC 
 (Mapped Diagnostic Context)
 has the advantage that all logging events down the call stack include this 
 info.
 Even if those log events are generated by code that is not aware of MINA at 
 all.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



Re: Asynchronous Http Client donation

2007-08-21 Thread Mark
Just so we are straight on terminology, what I referred to as a MINA
component is what I think you all are calling sub-projects.  I will be sure
to get this right from now on.  These include:

mina-example
mina-filter-codec-netty
mina-filter-compression
mina-integration-jmx
mina-integration-spring

My intention is to create a new sub-project called mina-httpclient.  Once
I get the code up to compliance with the trunk, and an example for
mina-example in the trunk, I will check everything in.  I never planned on
placing this code into mina-core, and would not vote for something like
this; it makes no sense.


On 8/21/07, Mike Heath [EMAIL PROTECTED] wrote:

 I'm wondering where this project should really go.  Do we want to make
 it part of MINA (ie. put it in mina/trunk) or do we want to create a
 separate subproject that depends on MINA (ie. put it in something like
 mina/async-httpclient/trunk).

 I'm concerned about the agility of MINA if we start adding protocol
 handlers to MINA itself.  What if we make a change to MINA that breaks
 one of our protocol handlers?  What if there's a bug in a protocol
 handler that doesn't affect 99.9% of MINA's user base?  Will these
 problems keep us from making releases?  If we fix a major bug in MINA
 that doesn't affect async-httpclient, do we still release a new version
 of async-httpclient with MINA because async-httpclient is part of the
 baseline MINA build?

 I would rather see async-httpclient be a subproject of MINA and have it
 reside it's own directory in subversion with its own build and with its
 own examples separate from the MINA examples.

 That being said, I would MUCH rather see AsyncWeb finally moved over to
 MINA as a sub-project and then make async-httpclient part of AsyncWeb.
 There's certainly going to be a lot of overlap between the two.  We
 should leverage that.

 -Mike

 Mark wrote:
  I created a mina-httpclient component on the trunk.  Just working things
  out, along with an example and I will check things in.
 
 
  On 8/21/07, Mike Heath [EMAIL PROTECTED] wrote:
  This sounds awesome!
 
  I would like to see this as the client part of AsyncWeb for two
 reasons.
First it seams to be a natural fit.  Second it might give us a little
  more incentive to finally get AsycWeb moved over to MINA.
 
  -Mike
 
  Jeff Genender wrote:
  Hi,
 
  First, I want to say that I am a big fan of Mina.  For those who don't
  know me (which is everyone), I am a committer on Geronimo and have had
  several people ask about an async http client API to use with our NIO
  clients with comet for the 2.0 Geronimo server.  We have had folks who
  want to be able to do HTTP calls to 3rd party servers from
 servlets/web
  apps to get content, and not tie up a thread while its doing its
 thing.
   So I decided to try to whip together an API that was similar to
 Commons
  HttpClient, fully asynchronous, but based on Mina...and I think I have
  80-90% of it completed.  It is here:
 
  http://svn.apache.org/repos/asf/geronimo/sandbox/AsyncHttpClient
 
  For what it's worth...it doesn't seem appropriate for Geronimo. So I
  would like to donate it to Mina.  Please have a look at it and give me
  feed back for if I have gone down the right path.  It can be enhanced
  greatly as this is just a start, but I think it can be very useful and
  become a powerful API with everyone moving to NIO.
 
  Don't hold back any comments ;-)  I would really like to see an API
 like
  this and I believe Mina is just perfect for this.
 
  Please let me know what you think..and if you don't think its right
 for
  Mina..thats ok too ;-)  But getting your feedback would be best for
  me...and making this a community project is even better ;-)
 
  Jeff
 
 
 
 




-- 
..Cheers
Mark


Re: please review my commits

2007-08-21 Thread Trustin Lee
On 8/20/07, Maarten Bosteels [EMAIL PROTECTED] wrote:
 Hello,

 I created an MdcLoggingFilter and made some other small changes in the
 trunk.
 Could you please review these commits and let me know what you think.

 Trustin, I noticed too late that my commit message should have started with
 Resolved issue: DIRMINA-422

 Please also have a look at the WrappingFilter : it's easy for IoFilters that
 need to perform the SAME logic before and/or after EVERY IoEvent
 (for example BlacklistFilter or ProfileTimerFilter)

I left a few comments at DIRMINA-422.

HTH,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6


Re: two processes listening on same port

2007-08-21 Thread Mark
Done.  I updated examples-trunk for:

httpserver.codec.Server
proxy.Main
reverser.Main
sumup.Server

The call to setReuseAddress(true) was taken out.

On 8/21/07, Trustin Lee [EMAIL PROTECTED] wrote:

 On 8/20/07, Maarten Bosteels [EMAIL PROTECTED] wrote:
  Hello all,
 
  I am witnessing some very weird behavior:  two processes listening on
 the
  same TCP port on the same machine.
  using Windows XP Professional
 
  I thought this might be possible because my portable is multi-homed
 (wired +
  wireless network) ?
  But I disabled the wireless network and it still works.
 
  1st process = org.apache.mina.example.chat.Main
  2nd process = org.apache.mina.example.chat.SpringMain
 
  Running two instances of org.apache.mina.example.chat.Main gives the
  expected Address already in use
  but it seems I can start as many instances of SpringMain as I want (I
 tried
  upto 6)
 
  Ok, this behavior is clearly a consequence of setting reuseAddress=true
 on
  the SocketAcceptor
  but I have never witnessed this behavior on linux.
 
  Does anybody know whether this is a documented feature on Windows ?
 
  C:\netstat -na | grep 1234
  TCP  0.0.0.0:1234 0.0.0.0:0 LISTENING
  TCP  0.0.0.0:1234 0.0.0.0:0 LISTENING
  TCP  127.0.0.1:1234   127.0.0.1:1379ESTABLISHED
  TCP  127.0.0.1:1379   127.0.0.1:1234ESTABLISHED
  (unfortunately netstat on windows doesn't have the -p option to show
 process
  id of listening process)
 
  Changing localAddress from  :1234  to 127.0.0.1:1234 or 
  192.168.0.5:1234 doesn't make a difference.
 
  Clients seem to connect to the process that was started last.
  And when that server stops, new connections are accepted by an 'older'
  server.

 It's probably because of setReuseAddress().  We need to get rid of
 that line from all examples.

 Trustin
 --
 what we call human nature is actually human habit
 --
 http://gleamynode.net/
 --
 PGP Key ID: 0x0255ECA6




-- 
..Cheers
Mark


Re: IoSessionLogger.trace()

2007-08-21 Thread Mark
thanks...got it.

On 8/21/07, Trustin Lee [EMAIL PROTECTED] wrote:

 On 8/19/07, Mark [EMAIL PROTECTED] wrote:
  I am getting compilation errors on the following methods:
 
  public static void trace(Logger log, IoSession session, String message)
  public static void trace(Logger log, IoSession session, String message,
  Throwable cause)
 
  Am I missing someting?  I just did an update in Eclipse, and the problem
  still exists.

 You need to run mvn eclipse:eclipse (or the mvn-eclipse script) again
 to synchronize the updated dependency information.

 HTH,
 Trustin
 --
 what we call human nature is actually human habit
 --
 http://gleamynode.net/
 --
 PGP Key ID: 0x0255ECA6




-- 
..Cheers
Mark


Re: Asynchronous Http Client donation

2007-08-21 Thread Mike Heath

Jeff Genender wrote:

I would concur with you on this.  I think a sub-project of its own is
good since it can be used as a standalone API (with a dependency on Mina
of course).  I would recommend that this API be a separate artifact from
asyncweb as I think we want the client to be capable of being slit off
from the server (for obvious reasons).


Certainly if you want an HTTP client, it's unlikely that you would want 
an HTTP server.  This, of course, makes sense.  I would imagine, 
however, that there are going to be a lot of similarities between the 
client and server code (header parsing, cookies support, the many 
caching options of HTTP/1.1, etc.).  That's why I was thinking making it 
part of AsyncWeb would be a good idea.  I don't think the client and 
server should be distributed in the same artifact either.  However, I 
believe there's a lot to be gained by keeping the the HTTP client and 
server close together.


WDYT?

-Mike


Re: Asynchronous Http Client donation

2007-08-21 Thread Jeff Genender
Agreed...if we can split the artifacts, then that is fine with me.

Jeff

Mike Heath wrote:
 Jeff Genender wrote:
 I would concur with you on this.  I think a sub-project of its own is
 good since it can be used as a standalone API (with a dependency on Mina
 of course).  I would recommend that this API be a separate artifact from
 asyncweb as I think we want the client to be capable of being slit off
 from the server (for obvious reasons).
 
 Certainly if you want an HTTP client, it's unlikely that you would want
 an HTTP server.  This, of course, makes sense.  I would imagine,
 however, that there are going to be a lot of similarities between the
 client and server code (header parsing, cookies support, the many
 caching options of HTTP/1.1, etc.).  That's why I was thinking making it
 part of AsyncWeb would be a good idea.  I don't think the client and
 server should be distributed in the same artifact either.  However, I
 believe there's a lot to be gained by keeping the the HTTP client and
 server close together.
 
 WDYT?
 
 -Mike


Re: Asynchronous Http Client donation

2007-08-21 Thread Mike Heath

Mark wrote:

Just so we are straight on terminology, what I referred to as a MINA
component is what I think you all are calling sub-projects.  I will be sure
to get this right from now on.  These include:

mina-example
mina-filter-codec-netty
mina-filter-compression
mina-integration-jmx
mina-integration-spring



I would say that these are optional components of MINA since they are 
part of the MINA build and all share the same version.  When we do a 
MINA release we vote on, build, and distribute all of these modules and 
not just mina-core.  I don't think async-httpclient should be tied to 
this process.


I think a better home for async-httpclient would be to create something 
like https://svn.apache.org/repos/asf/mina/async-httpclient and put 
'trunk', 'tags', and 'branches' in there.  Then in trunk put a parent 
pom.xml that builds the 'client' and 'examples' modules.  This would 
make async-httpclient totally independent of the MINA release cycle.


Do others see things differently?

-Mike


Re: Asynchronous Http Client donation

2007-08-21 Thread Mark
I am fine with that.  Honestly, I can't come up with a great reason for any
one particular place so I will go with the majority.

On 8/22/07, Mike Heath [EMAIL PROTECTED] wrote:

 Mark wrote:
  Just so we are straight on terminology, what I referred to as a MINA
  component is what I think you all are calling sub-projects.  I will be
 sure
  to get this right from now on.  These include:
 
  mina-example
  mina-filter-codec-netty
  mina-filter-compression
  mina-integration-jmx
  mina-integration-spring


 I would say that these are optional components of MINA since they are
 part of the MINA build and all share the same version.  When we do a
 MINA release we vote on, build, and distribute all of these modules and
 not just mina-core.  I don't think async-httpclient should be tied to
 this process.

 I think a better home for async-httpclient would be to create something
 like https://svn.apache.org/repos/asf/mina/async-httpclient and put
 'trunk', 'tags', and 'branches' in there.  Then in trunk put a parent
 pom.xml that builds the 'client' and 'examples' modules.  This would
 make async-httpclient totally independent of the MINA release cycle.

 Do others see things differently?

 -Mike




-- 
..Cheers
Mark