Return-Path: Delivered-To: apmail-jakarta-httpcomponents-dev-archive@www.apache.org Received: (qmail 31621 invoked from network); 26 Nov 2007 12:45:12 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 26 Nov 2007 12:45:12 -0000 Received: (qmail 48673 invoked by uid 500); 26 Nov 2007 12:45:00 -0000 Delivered-To: apmail-jakarta-httpcomponents-dev-archive@jakarta.apache.org Received: (qmail 48659 invoked by uid 500); 26 Nov 2007 12:44:59 -0000 Mailing-List: contact httpcomponents-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list httpcomponents-dev@jakarta.apache.org Received: (qmail 48650 invoked by uid 99); 26 Nov 2007 12:44:59 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Nov 2007 04:44:59 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Nov 2007 12:44:40 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 12AC1714236 for ; Mon, 26 Nov 2007 04:44:43 -0800 (PST) Message-ID: <4993918.1196081083045.JavaMail.jira@brutus> Date: Mon, 26 Nov 2007 04:44:43 -0800 (PST) From: "Asankha C. Perera (JIRA)" To: httpcomponents-dev@jakarta.apache.org Subject: [jira] Commented: (HTTPCORE-127) Expose improved API for lifecycle management In-Reply-To: <12703801.1193832830593.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/HTTPCORE-127?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12545426 ] Asankha C. Perera commented on HTTPCORE-127: -------------------------------------------- Hi Oleg I was trying out some sample code for this, and it seems like I need to close the ServerSocketChannel to prevent new connections from being accepted. However, if I had registered a Selector to this, it seems like I am required to *close* that as well to prevent new connections from being accepted. To keep responding to any in-flight requests, I only want to prevent new connections from being accepted - thus I do not want to close the selector. I am pasting some test code that illustrates this problem.. Do you know how I could work around this? thanks asankha package org.apache.http.examples.nio; import java.nio.channels.ServerSocketChannel; import java.nio.channels.Selector; import java.nio.channels.SelectionKey; import java.net.InetSocketAddress; public class Test { public static void main(String[] args) throws Exception { SelectionKey key = null; Selector selector = Selector.open(); ServerSocketChannel serverChannel = ServerSocketChannel.open(); serverChannel.configureBlocking(false); serverChannel.socket().bind(new InetSocketAddress(8080)); key = serverChannel.register(selector, SelectionKey.OP_ACCEPT); System.out.println("Started... sleeping 5s"); Thread.sleep(5000); key.cancel(); serverChannel.close(); selector.close(); // <------------- I don't want to do this... System.out.println("Stopped... sleeping 10s"); Thread.sleep(10000); serverChannel = ServerSocketChannel.open(); serverChannel.configureBlocking(false); serverChannel.socket().bind(new InetSocketAddress(8080)); key = serverChannel.register(Selector.open(), SelectionKey.OP_ACCEPT); // <--- but want to register a new channel with the same selector again.. System.out.println("Re-Started... sleeping 10s"); Thread.sleep(10000); } } > Expose improved API for lifecycle management > -------------------------------------------- > > Key: HTTPCORE-127 > URL: https://issues.apache.org/jira/browse/HTTPCORE-127 > Project: HttpComponents Core > Issue Type: Improvement > Components: HttpCore NIO > Affects Versions: 4.0-alpha6 > Reporter: Asankha C. Perera > Fix For: 4.0-beta1 > > > Apache Synapse uses HttpCore and we would like to stop accepting new connections to put our servers into a "maintenance" mode. In this mode any in-flight requests already being served will continue as normal (i.e. reading, writing etc) but new connections should be rejected, so that a load balancer could direct new connections to another instance in the cluster. The requirement is to then update configuration, apply patches or cleanly shutdown etc. for maintenance without effecting any in-flight requests. > Implementation wise I think this would be fairly straightforward as we can remove OP_ACCEPT from the interested ops. > On the mailing list Odi suggested that we tackle this at a broader level by exposing lifecycle management APIs > "I suggest create, start, stop, destroy methods in some classes/APIs (semantics of JBoss Service MBeans)" -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. --------------------------------------------------------------------- To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org