[lsc-dev] [LDAP Synchronization Connector - Bug #599] (New) in case of hard TCP/IP disconnection (power cut), asynchronous LSC is not alerted

noreply at lsc-project.org noreply at lsc-project.org
Mon Jul 1 10:34:57 CEST 2013


Issue #599 has been reported by David Coutadeur.

----------------------------------------
Bug #599: in case of hard TCP/IP disconnection (power cut), asynchronous LSC is not alerted
http://tools.lsc-project.org/issues/599

Author: David Coutadeur
Status: New
Priority: Normal
Assigned to: 
Category: Core
Target version: trunk
Problem in version: 



The main problem of this is the JMX monitoring tool that does not report any alert.

Here are some elements to solve this problem :

in C : setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, &optval, optlen)
http://traduc.org/Guides_pratiques/Suivi/TCP-Keepalive-HOWTO/Document

in java : rewrite a socket factory extending the standard factory. In this factory, set the KEEP ALIVE on the created sockets. Here is an example :

<pre>
           public class MyCustomSocketFactory extends SocketFactory {

                public MyCustomSocketFactory() {

                    System.out.println("[creating a custom socket
           factory]");
                }

                public static SocketFactory getDefault() {

                    System.out.println("[acquiring the default socket
           factory]");
                    return new MyCustomSocketFactory();
                }

                public Socket createSocket(String host, int port)
                    throws IOException, UnknownHostException {

                    System.out.println("[creating a custom socket
           (method 1)]");

                    Socket s = new Socket(host, port);
                    s.*setKeepAlive*(true);

                    return s;

                }

                public Socket createSocket(String host, int port,
           InetAddress localHost,
                    int localPort) throws IOException,
           UnknownHostException {

                    System.out.println("[creating a custom socket
           (method 2)]");

                    Socket s = new Socket(host, port, localHost,
           localPort);
                    s.*setKeepAlive*(true);

                    return s;
                }

                public Socket createSocket(InetAddress host, int port)
           throws IOException {

                    System.out.println("[creating a custom socket
           (method 3)]");

                    Socket s = new Socket(host, port);
                    s.*setKeepAlive*(true);

                    return s;

                }


                public Socket createSocket(InetAddress address, int port,
                    InetAddress localAddress, int localPort) throws
           IOException {

                    System.out.println("[creating a custom socket
           (method 4)]");

                    Socket s = new Socket(address, port, localAddress,
           localPort);
                    s.*setKeepAlive*(true);

                    return s;
                }
</pre> 

at JNDI level, specify the new socket :

<pre>
       env.put("java.naming.ldap.factory.socket",
       "MyCustomSocketFactory");
</pre>

Some pointers :
   http://comments.gmane.org/gmane.comp.java.sun.jndi/296
   http://old.nabble.com/How-to-set-TCP-Keep-Alive-for-JNDI-Connection---td17273270.html
   http://java.sun.com/javase/6/docs/api/java/net/Socket.html#setKeepAlive


Thanks to Raphael Martz for reporting this issue !



-- 
You have received this notification because you have either subscribed to it, or are involved in it.
To change your notification preferences, please click here: http://tools.lsc-project.org/my/account
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lsc-project.org/pipermail/lsc-dev/attachments/20130701/691ff5d7/attachment.htm>


More information about the lsc-dev mailing list