Return-Path: Delivered-To: apmail-cassandra-dev-archive@www.apache.org Received: (qmail 65595 invoked from network); 6 May 2010 08:17:39 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 6 May 2010 08:17:39 -0000 Received: (qmail 26219 invoked by uid 500); 6 May 2010 08:17:38 -0000 Delivered-To: apmail-cassandra-dev-archive@cassandra.apache.org Received: (qmail 26196 invoked by uid 500); 6 May 2010 08:17:38 -0000 Mailing-List: contact dev-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list dev@cassandra.apache.org Received: (qmail 26188 invoked by uid 99); 6 May 2010 08:17:38 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 May 2010 08:17:38 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of rantav@gmail.com designates 209.85.223.175 as permitted sender) Received: from [209.85.223.175] (HELO mail-iw0-f175.google.com) (209.85.223.175) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 May 2010 08:17:29 +0000 Received: by iwn5 with SMTP id 5so7351595iwn.9 for ; Thu, 06 May 2010 01:17:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=7LRQ2aLTdRxCep2A23N+k8v/lL0pgQaFABKfL2Fa6zM=; b=ZIBqjdYqlIQawdN+0NV6+VxeD88K45T3PNTgC3mzY3dwJyduYYZ+VOWSBfy92mzxAS 0vl47kl+V8NXyx0YxC3XyuL0ZGzkSPp78nLfAS5fDtMefAj2wdVIQxEUuOn8dYg2K2WP 9kDgEvBMEDVhu4mhxwuefMEO+kPXsXR/GG/Bc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=IsnF+qjo5zTUwQ6k35L/YnyldS+V3cIp8aBWqQEi3DwOrJZ2GNstHnnDsAStXoTeH4 Rd1BR6zwDilEZsKs3l6GvBTvBcG7JFGifEKvnWWDxhCiWr0vQlC+dXubVq6HRFtBArcJ OSj6tX7EPwItNl6XXNbarBAzZI/0LSXeRako4= MIME-Version: 1.0 Received: by 10.231.147.201 with SMTP id m9mr1901016ibv.11.1273133825405; Thu, 06 May 2010 01:17:05 -0700 (PDT) Received: by 10.231.162.72 with HTTP; Thu, 6 May 2010 01:17:05 -0700 (PDT) In-Reply-To: References: <1272982863.17468.71.camel@erebus.lan> <4BE05378.9060207@openx.org> <20100504174909.GB7305@alumni.caltech.edu> Date: Thu, 6 May 2010 11:17:05 +0300 Message-ID: Subject: Re: admin web UI From: Ran Tavory To: gabriele renzi Cc: dev@cassandra.apache.org Content-Type: multipart/mixed; boundary=0016e6476de26a387b0485e8916d X-Virus-Checked: Checked by ClamAV on apache.org --0016e6476de26a387b0485e8916d Content-Type: multipart/alternative; boundary=0016e6476de26a38740485e8916b --0016e6476de26a38740485e8916b Content-Type: text/plain; charset=UTF-8 Thanks Gabriele, it's quite nice! The code change is pretty small I would even say for simplicity it's better to just commit that to the core. I'll paste the code below. In main(): daemon.startJmxOverHttp(); And we have: public void startJmxOverHttp() { try { MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); ObjectName processorName = new ObjectName("Server:name=XSLTProcessor"); HttpAdaptor adapter = new HttpAdaptor(9292); ObjectName httpName = new ObjectName("system:name=http"); mbs.registerMBean(adapter, httpName); XSLTProcessor processor = new XSLTProcessor(); adapter.setProcessor(processor); mbs.registerMBean(processor, processorName); adapter.start(); } catch(MalformedObjectNameException ex) { logger.warn("Could not start JMX over HTTP service, wrong name specifed in code: {}", ex); } catch(InstanceAlreadyExistsException ex) { logger.warn("Could not start JMX over HTTP service, already started: {}", ex); } catch(IOException ex) { logger.warn("Could not start JMX over HTTP service: {}", ex); } catch(JMException ex) { logger.warn("Could not start register mbean in JMX: {}", ex); } } That's all, now just add mx4j.jar and mx4j-tools.jar to lib and you're done. See screenshot for what you get from that on a live cassandra node. I'll try this for my installation but I think it'll be also nice to have that for everyone, let me know what you think. If you prefer contrib, then I'm not sure how to do that without having to run two processes. On Thu, May 6, 2010 at 10:15 AM, gabriele renzi wrote: > On Wed, May 5, 2010 at 12:00 PM, Ran Tavory wrote: > > can you send it to me? I'll try to work from it. > > I updated it to trunk, moved the code into a method and added a few > catch'es (before: in main() throws Exception) . > As you can see, once exception handling and imports are removed it's > about ten lines. > > To compile you need the jars mx4j-tools.jar, mx4j.jar from the mx4j > distribution, compile, run cassandra, connect to 9292. > > I recall I've seen better looking mx4j-over-http interfaces (in e.g. > mule ESB) which I'd say depends on the default stylesheet, but for a > quick glance it kind of works. It should also be possible to only > expose selected beans, though I have not investigated it. > > -- > blog en: http://www.riffraff.info > blog it: http://riffraff.blogsome.com > --0016e6476de26a38740485e8916b Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Thanks Gabriele, it's quite nice!

T= he code change is pretty small I would even say for simplicity it's bet= ter to just commit that to the core. I'll paste the code below.

In main():

=C2=A0=C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0daemon.startJmxOverHttp();

=

And we have:

=C2=A0= =C2=A0 =C2=A0public void startJmxOverHttp()
=C2=A0=C2=A0 =C2=A0{
=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0try
=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0{
=C2=A0=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0MBeanServer mbs =3D ManagementFactory.getPlatfor= mMBeanServer();
=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Ob= jectName processorName =3D new ObjectName("Server:name=3DXSLTProcessor= ");

=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0HttpAdap= tor adapter =3D new HttpAdaptor(9292);
=C2=A0=C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0ObjectName httpName =3D new ObjectName("system:na= me=3Dhttp");
=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= mbs.registerMBean(adapter, httpName);
=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0XSLTProcessor processor= =3D new XSLTProcessor();
=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0adapter.setProcessor(processor);
=C2=A0=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0mbs.registerMBean(processor, processorName);
=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0adapter.start();
=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0} catch(MalformedObjectNameException = ex)
=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0{
=C2=A0=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0logger.warn("Could not start JMX over HTTP ser= vice, wrong name specifed in code: {}", ex);
=C2=A0=C2=A0 = =C2=A0 =C2=A0 =C2=A0} catch(InstanceAlreadyExistsException ex)
=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0{
=C2=A0=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0logger.warn("Could not start JMX over HTTP service, a= lready started: {}", ex);
=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0}= catch(IOException ex)
=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0{
=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0logger.warn("Could not star= t JMX over HTTP service: {}", ex);
=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0} catch(JMException ex)
=C2= =A0=C2=A0 =C2=A0 =C2=A0 =C2=A0{
=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0logger.warn("Could not start register mbean in JMX: {}", e= x);
=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0}
=C2=A0=C2=A0 =C2= =A0}

That's all, now just add mx4j.jar a= nd mx4j-tools.jar to lib and you're done. See screenshot for what you g= et from that on a live cassandra node.
I'll try this for my installation but I think it'll be also ni= ce to have that for everyone, let me know what you think. If you prefer con= trib, then I'm not sure how to do that without having to run two proces= ses.


On Thu, May 6, 2010 at 10:15 AM, ga= briele renzi <rff= .rff@gmail.com> wrote:
On Wed, May 5, 2010 at 12:00 PM, Ran Tavory <rantav@gmail.com> wrote:
> can you send it to me? I'll try to work from it.

I updated it to trunk, moved the code into a method and added a few catch'es (before: in main() throws Exception) .
As you can see, once exception handling and imports are removed it's about ten lines.

To compile you need the jars mx4j-tools.jar, mx4j.jar from the mx4j
distribution, compile, run cassandra, connect to 9292.

I recall I've seen better looking mx4j-over-http interfaces (in e.g. mule ESB) which I'd say depends on the default stylesheet, but for a quick glance it kind of works. It should also be possible to only
expose selected beans, though I have not investigated it.

--
blog en: http://www.= riffraff.info
blog it: http://= riffraff.blogsome.com

--0016e6476de26a38740485e8916b-- --0016e6476de26a387b0485e8916d--