It's rather an offtop but I should say some words about NIO on Linux.
NIO or new input/output provides better performance and less resources consumption than simple sockets and IMHO pretty good thing to use wherever it's possible.
Starting from 1.5 GridGain uses Java NIO to give users maximum flexibility, compatibility and throughput. All messages that nodes exchange each over and even jobs and tasks exchange uses new input/output provide highest speed and consume less resources then ordinary sockets.
But recently digging into some Java 6 features on Linux we ran into the issue with NIO implementation.
Linux has so called epoll (I/O event notification facility that was implemented in 2.6 kernel). Java 6 reimplemented NIO to use Linux epoll and thus this new version won't work on old Linux installations. So to use latest Java VM you have to keep you OS up-to-date or get back to Java 5.
Some tips to check if your Linux is compatible with Java 6 NIO:
Caused By:
----------
>>> Type: java.io.IOException
>>> Message: Function not implemented
>>> Stack trace:
>>> at sun.nio.ch.EPollArrayWrapper.epollCreate(EPollArrayWrapper.java:1)
...
P.S. The reason was old "glibc" library. So if you got this exception check the kernel and then update "glibc" to the latest.
NIO or new input/output provides better performance and less resources consumption than simple sockets and IMHO pretty good thing to use wherever it's possible.
Starting from 1.5 GridGain uses Java NIO to give users maximum flexibility, compatibility and throughput. All messages that nodes exchange each over and even jobs and tasks exchange uses new input/output provide highest speed and consume less resources then ordinary sockets.
But recently digging into some Java 6 features on Linux we ran into the issue with NIO implementation.
Linux has so called epoll (I/O event notification facility that was implemented in 2.6 kernel). Java 6 reimplemented NIO to use Linux epoll and thus this new version won't work on old Linux installations. So to use latest Java VM you have to keep you OS up-to-date or get back to Java 5.
Some tips to check if your Linux is compatible with Java 6 NIO:
- Execute "nm -D /lib/libc.so.6 | grep epoll". You should get all 4 functions like below
00000000000d8040 T epoll_create
00000000000d8070 T epoll_ctl
00000000000d7d10 T epoll_pwait
00000000000d80a0 T epoll_wait - Check you kernel " sudo cat /boot/System.map-* |grep epoll" (note that you need super user privileges). Your active kernel should have epoll functions implemented.
ffffffff802dd050 T sys_epoll_wait
ffffffff802dd530 T sys_epoll_ctl
ffffffff802dda50 T sys_epoll_create
ffffffff802ddb30 T sys_epoll_pwait
ffffffff802e10b0 T compat_sys_epoll_pwait
Caused By:
----------
>>> Type: java.io.IOException
>>> Message: Function not implemented
>>> Stack trace:
>>> at sun.nio.ch.EPollArrayWrapper.epollCreate(EPollArrayWrapper.java:1)
...
P.S. The reason was old "glibc" library. So if you got this exception check the kernel and then update "glibc" to the latest.


2 comments:
Hi,
I've severall linux servers with various 2.6.x kernels, and none has the four lines...
So, I've googled for a working example of NIO that I found here :
http://rox-xmlrpc.sourceforge.net/niotut/
[root@home testNIO]# javac *.java
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
[root@home testNIO]# ll
total 64
-rw-r--r-- 1 root root 469 mai 2 01:12 ChangeRequest.class
-rw-r--r-- 1 root root 351 mai 2 01:12 ChangeRequest.java
-rw-r--r-- 1 root root 1430 mai 2 01:12 EchoWorker.class
-rw-r--r-- 1 root root 871 mai 2 01:11 EchoWorker.java
-rw-r--r-- 1 root root 5814 mai 2 01:12 NioClient.class
-rw-r--r-- 1 root root 6990 mai 2 01:12 NioClient.java
-rw-r--r-- 1 root root 5236 mai 2 01:12 NioServer.class
-rw-r--r-- 1 root root 6137 mai 2 01:10 NioServer.java
-rw-r--r-- 1 root root 714 mai 2 01:12 RspHandler.class
-rw-r--r-- 1 root root 369 mai 2 01:12 RspHandler.java
-rw-r--r-- 1 root root 421 mai 2 01:12 ServerDataEvent.class
-rw-r--r-- 1 root root 296 mai 2 01:11 ServerDataEvent.java
[root@home testNIO]# java NioServer
[root@home testNIO]# java NioServer&
[1] 5963
[root@home testNIO]# java NioClient
Hello World
And it seems to work on my SME Server.
SME Server 7
[root@home ~]# nm -D /lib/libc.so.6 | grep epoll
000caba0 T epoll_create
000cabe0 T epoll_ctl
000cac30 T epoll_wait
[root@home ~]# cat /boot/System.map-* |grep epoll
c0195f57 T sys_epoll_create
c0195fa0 T sys_epoll_ctl
c019614d T sys_epoll_wait
... (about 70 lines of the 3 lines above repeating, first column changing)
[root@home ~]# uname -a
Linux home 2.6.9-67.0.7.ELsmp #1 SMP Sat Mar 15 06:54:55 EDT 2008 i686 i686 i386 GNU/Linux
Ubuntu Feisty Fawn Server
thomas@dedibox1:~$ nm -D /lib/libc.so.6 | grep epoll
000beeb0 T epoll_create
000beef0 T epoll_ctl
000bef40 T epoll_wait
thomas@dedibox1:~$ sudo cat /boot/System.map-* |grep epoll
c01818e0 T sys_epoll_wait
c0181d10 T sys_epoll_pwait
c0181e10 T sys_epoll_ctl
c0182240 T sys_epoll_create
thomas@dedibox1:~$ uname -a
Linux dedibox1 2.6.21.1dedibox-r7 #1 Mon Apr 30 17:25:38 CEST 2007 i686 GNU/Linux
Redhat ES 4
[root@dell1 ~]# nm -D /lib/libc.so.6 | grep epoll
000caba0 T epoll_create
000cabe0 T epoll_ctl
000cac30 T epoll_wait
[root@dell1 ~]# cat /boot/System.map-* |grep epoll
c019004b T sys_epoll_create
c0190094 T sys_epoll_ctl
c0190241 T sys_epoll_wait
... (about 140 lines of the 3 lines above repeating, first column changing)
[root@dell1 ~]# uname -a
Linux dell 2.6.9-55.0.9.ELsmp #1 SMP Tue Sep 25 02:17:24 EDT 2007 i686 i686 i386 GNU/Linux
Java 6 detects that kernel does not have epoll and uses "old" way from Java 5 but sometimes it does not work (for example Gentoo 2006 and Java 1.6.0_03)
Post a Comment