Return-Path: Delivered-To: apmail-directory-dev-archive@www.apache.org Received: (qmail 12793 invoked from network); 22 Dec 2005 02:01:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 22 Dec 2005 02:01:14 -0000 Received: (qmail 98090 invoked by uid 500); 22 Dec 2005 02:01:09 -0000 Delivered-To: apmail-directory-dev-archive@directory.apache.org Received: (qmail 97962 invoked by uid 500); 22 Dec 2005 02:01:08 -0000 Mailing-List: contact dev-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Apache Directory Developers List" Delivered-To: mailing list dev@directory.apache.org Received: (qmail 97933 invoked by uid 99); 22 Dec 2005 02:01:08 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Dec 2005 18:01:08 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of sveerama@gmail.com designates 64.233.162.204 as permitted sender) Received: from [64.233.162.204] (HELO zproxy.gmail.com) (64.233.162.204) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Dec 2005 18:01:07 -0800 Received: by zproxy.gmail.com with SMTP id 13so312452nzn for ; Wed, 21 Dec 2005 18:00:47 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=owUuR8RpOmfBd8WmcMNkbtD5Qptkd8+L0EcIBKKnkKNavJLukDaa8CXP1C5mtY8hFR5lItwP/gIFGIgVB5gZ/1D7jjMVKF6bL7oDfd6OP8cf3xsHHvybdqZnTrsr8OXx0/EqzSYpSL8cMHg3wCFYdCZEXNfAlhY7SfPauY6rTRk= Received: by 10.65.84.4 with SMTP id m4mr16661qbl; Wed, 21 Dec 2005 18:00:46 -0800 (PST) Received: by 10.65.119.11 with HTTP; Wed, 21 Dec 2005 18:00:46 -0800 (PST) Message-ID: <4cdd6f370512211800m227b2f09maaaf3a05e3334ff1@mail.gmail.com> Date: Wed, 21 Dec 2005 21:00:46 -0500 From: Srikanth Veeramachaneni To: Apache Directory Developers List Subject: [MINA] 0.9.0 - Need advice on implementing graceful shutdown MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N I would like to implement graceful shutdown of a MINA server. The features I would like to support for the graceful shutdown are 1. Stop listening for new connections 2. Suspend read on all open IO sessions 3. Wait until all pending requests are processed for open IO sessions 4. Send a message to the clients indicating the session is being closed due to server shutdown 5. Close all IO sessions Assuming that sessions are added and removed from a list using the sessionOpened() and sessionClosed() methods of the IO handler and information as to whether= a session has pending requests is maintained as a session attribute, would an approach like below work? ------------------------------------------------------- private ServiceRegistry registry; private List ioSessionsList; /** * pseudo code for supporting MINA server graceful shutdown */ public void shutdown() { registry.unbindAll(); while (!ioSessionsList.isEmpty()) { IoSession[] ioSessions =3D ioSessionsList.toArray(new IoSession[0]); for (int i =3D 0; i < ioSessions.length; i++) { IoSession session =3D ioSessions[i]; if (!session.isClosing()) { session.suspendRead(); if (!(Boolean) session.getAttribute("HAS_PENDING_REQUESTS")) { session.write("Server closing connection due to shutdown"); session.close(); } } } } } ------------------------------------------------------- I would appreciate any advice/feedback/suggestions from MINA experts or anyone who has already implemented something similar. I probably need to add some synchronization to the above approach if it is a reasonable approach. thanks, Srikanth