and i’ve been workin’ like a dog
Originally uploaded by manyfires

JRuby has proved (to me at least) to be really powerful in prototyping and learning Java APIs. A few weeks ago I started thinking to rewrite one of my old Java programs in JRuby. I wrote that Java program as part of learning Java programming (so it’s not as good as I hoped) and I am no longer interested in maintaining it in Java since I’ve learned JRuby. I also thought that I made it a bit complicated to maintain. So I am hoping to simplify it by rewriting in JRuby and Ruby. It will be a challenge for me since I am still learning Ruby, but I hope I enjoy it.

The program calls various JMX APIs on a JMS server periodically and publishes outputs in XML onto JMS. The JMS server has a JMX Console, but I needed a web application for a consolidated view to monitor a number of JMS servers and clients on them.

It was not difficult at all to rewrite one part of the program, calling JMX APIs in JRuby. However, I thought twice about the data transport. Although it’s possible to use JMS in JRuby, inspired by Joe Gregorio’s RESTful JSON, I have decided to use JSON as data transport format this time. Bearing in mind the further integration with the current infrastructure at work, I have also chosen Jetty as HTTP server. Thanks to Keith who has shared his experience in running Jetty in JRuby. Jetty has JSON libraries built in, which is a bonus.

During the development, I’ve found Eyal’s JSON Viewer handy (even I have to cut & paste JSON data from cURL output) since browsers do not render response which content type is “application./json”, while you can view unformatted JSON with Firebug’s network monitoring. Does anyone know anything like Michael Bolin‘s JSON Inspector?

So far I’ve got the RESTful JSON webservice working for some GET requests. Now I need to think about URIs mapping and implementation of other JMX functions I use. I will post follow-up if I find something worthy to post.

P.S. The photo is nothing to do with this post, but as always I love to attach a wonderful photo (and story, too) I’ve found in Flickr.

Related Posts:

Advertisements


Endtime
Originally uploaded by Batram

Have your application ever been blocked by Log4j logging? Ideally your application should be less dependable on external logging services, SMTPAppender or JMSAppender, etc, but you need one to monitor important events remotely.

The AsyncAppender lets you log events asynchronously. It will collect the events sent to it and then dispatch them to all the appenders that are attached to it. You can attach multiple appenders to an AsyncAppender, but I won’t do that. The AsyncAppender uses a separate thread to serve the events in its buffer. The default buffer size is 128 and the blocking is set to true, which means that the logging is blocked when the buffer is full. I don’t know why the default blocking is set to true. Reading the source codes, if it’s set to false, the logging won’t be blocked since events are summarized and discarded. I’ve got to test it.

I have used JRuby to test the AsyncAppender and found it very handy again.

First of all, I needed an Log4j Appender that runs a bit slow. So, I have created a very simple SlowAppender.rb, which is a subclass of Log4j AppenderSkeleton. You just need to implement the append method.

SlowAppender < org.apache.log4j.AppenderSkeleton
def append(event)
sleep 1
puts layout.format(event)
end
end

Since I can’t configure it in log4j.xml, I add it to an AsyncAppender programmatically in a test JRuby script.

logger = Logger.getRootLogger()
slow = SlowAppender.new
slow.setLayout(PatternLayout.new("%d{ABSOLUTE} %-5p [%c{1}] %m%n"))
async = logger.getAppender("ASYNC")
async.addAppender(slow)

Full source codes and the result of the test script are available here.

You may not like that some events are discarded, but ideally you should be notified by catastrophic problems with remote logging services before that. What’s important to you is that your application keeps working without being disrupted by other services.

You should also consider using StringMatchFilter to avoid sending unnecessary log messages to remote logging services. A flood of unnecessary logging messages will cause problems to remove logging services that are most likely shared with other applications.

A while back I came across RSSAppender and I think it’s a very simple way to retrieve and aggregate important logging events. How it works? Why don’t you test it in JRuby?



Penguins galore!

Originally uploaded by BrynJ

I was not supporting that idea, but when I received an email from Linda Capper of British Antarctic Survey (BAS) a few days ago I was excited about the news and I am now really looking forward to watching their first ever live concert from Antarctic.

OK, so they’re not rock stars. But scientists with the British Antarctic Survey will guarantee Al Gore’s promise that the Live Earth concerts on July 7 will be performed on all 7 continents. They’ll be performing during the dead of winter at the Rothera Research Station. In fact, it’ll be the first time anyone outside the station has heard the indie rock-folk band, Nunatak, play at all. (Nunatak, by the way, is a Greenlandic word that means an exposed summit of a ridge mountain or peak within an ice field or glacier.) […] Gore personally reached out to the band, not that he had many alternatives. “We were invited by former Vice President Gore, who has followed our research for some years and knows us,” says BAS spokeswoman Linda Capper. Live Earth organizers did originally explore the idea of flying in performers, but quickly dropped that when told the continent is pretty much inaccessible during the winter.

Don’t forget that there are more hard working scientists in Antarctic. It would be great if they joined the gig via their satellite link.

Bryan Jones, whose photos I used in this post and previous one, has a great set of photos from his time working for BAS in Antarctica. Check them out.

In the surrounding Antarctica, commercial tourism, whaling, and politics which was reminded by the 25th anniversary of the end of Falklands War are still a bit concerned.

Oh, BTW, Al Gore’s plan to have a symbolic switch-off of lights across the UK during the Live Earth gig in London has been vetoed by the National Grid.

Related Posts:


All Your Famous Friends
Originally uploaded by Thomas Hawk

I have waited for this news, JRuby 1.0.0RC3 Released – And This Is It!

I have already managed to run an example of JRuby on Rails in Tomcat with PKI at work. So what I need next was an application development environment and I’ve got JRuby on Rails running on Tomcat inside Eclipse IDE with Eclipse WebTools Platform and Aptana’s RadRails plugin.

I already have a Tomcat package coupled with JASS (Java Authentication and Authorisation Service) framework at work, which works nicely within Eclipse IDE with WTP. So, I just needed to install RadRails as a plugin to that. I can only use RadRails to develop a Rails app, but can’t run it in WEBrick because it calls Java JASS API functions to get out other information about the user. However, you can add it to a Tomcat server as an external web module (you can’t add this as a web module because it’s not a web project, but a rails project) so that you can run the Rails app with JRuby in Tomcat within Eclipse! Here is a short instruction.

  1. Download the Eclipse + WTP all-in-one package
  2. Install RadRails and configure it
  3. Create a new Rails project
  4. Create a WEB-INF folder with necessary files in the root of the project
  5. Create a new server (e.g. Tomcat)
  6. Add the Rails project as an external web module to the server. You just point the directory where the Rails project resides in and give a path like /projectname.
  7. Start the server
  8. Open a browser in Eclipse and access the webapp (screenshot)

Related Posts:


Neon Green Light Switch on Wall
Originally uploaded by EltonHarding

On Thursday June 21 – Midsummer’s Night – Lights Out London will take place between 9 and 10pm. Londoners and businesses are invited to turn off all lights and non-essential appliances between 9 and 10pm.

I will definitely take part in the event. Will you?

I will also check out the realtime electricity demand chart at the National Grid UK after the event. I hope they will release an official data as they support the event.

Do you remember Sydney’s Earth Hour?

On Saturday March 31 2007, more than 2 million Sydney residents took part in the event between 7:30 and 8:30pm and they observed impressive 10.2% drop in energy usage which represents a reduction of 24.86 tonnes of carbon dioxide – the equivalent of taking 48,613 cars off the road for an hour!

[via thelondonpaper.com]

Related Posts:


Ten
Originally uploaded by jonesprimavera

I stop posting “10 things I didn’t know last week“, but will post more on my tumblr. I will post some follow-ups here if anything gets more interested.

I have been enjoying tumblelogging using the excellent hosting service Tumblr. Like twitter, you can now follow your friends on your Dashboard.

Don’t you have one, yet? Check what people are tumblring about. There are 28000 tumblr users according to Google.

Check Juxtaviews if you are wondering about tumblelogging. I agree with him that it can be more personal than the blogging. For me, it’s more exciting than twitter.

Related Posts:



Google Experimental – timeline view

Google Experimental was one of announcements made on Google Searchology Day.

I am particularly interested in their experiment on timeline and map views.

Being a big fan of SIMLE project, I thought it would be interesting to see the search results in Timeline or even Exhibit if they added XML or JSON feeds of the search results with “view:timeline” or “view:map” option.

Beside the early experiment of UI, the search results are not what I expected either. For example, I searched for “Alan Johnston” and the results are ordered by dates in its content, but not the timestamp of the content. There are not much news items on recent his disappearance. So I guess they are intended as biography.

What I expected was more like search results at News Archive like this. Maybe it’s different context. Anyway I’d like to see a timeline slider added to its timeline view, too.

Timelined view of search results are not new. Topix.net has had it for some time and FT.com powered by FAST enterprise search has a timeline slider to refine search results by date.

I also came across Tony Hirst’s Jörn Clausen’s live earthquake mashup which combines a SIMLE Timeline with Google map. Very nice. [via Tony Hirst]

Related Posts:


Don’t Hurt The Web
Use Open Standard Mozilla Developer Center

I realised some of BBC Timelines were shown in Flash with XML data over HTTP. Firebug revealed their XML links! Thanks to Ben Metcalfe’s post for the pointer.

For example, “Fifteen years of the web” page loads XML data from here. It’s interesting, but the data is not re-usable for me to draw them in SIMILE Timeline easily.

The XML data contains Flash proprietary “textformat” tags! I know this particular example is not intended to be used openly, but it could have been a good “open” data source for mashup if they did not use the proprietary standards.

I have no experience in Flash programming at all, but my advice would be:

  1. Don’t use the proprietary Flash “textformat” tag in XML data.
  2. Use other supported HTML tags if necessary and put all inside a CDATA section.
  3. Use CSS to format text when needed.

BTW, “Timeline: The Blair Years” was shown in Flash when first published last week, but it has been replaced with HTML for some reason. Although its XML is still available, I can’t use it in SIMILE Timeline. Shame.

Related Posts:


The City
Originally uploaded by sunny-drunk.

  1. One in 10 web pages scrutinised by search giant Google contained malicious code that could infect a user’s PC.
  2. Fly-tipping (illegally dumping waste) and Bestselling US author Bill Bryson is the new president of the Campaign to Protect Rural England.
  3. It’s a good idea to power island’s cars by locally produced coconut oil, but achieving the EU target 10% of all fuel in cars from biofuels by 2020 could have a severe environmental impact.
  4. Newly rich couples can afford to pay fines to have more than one child. China has about 1.3 billion people, 20% of the world’s total.
  5. London’s bendy buses can’t reverse!
  6. The UK consumes 80 per cent of European cod and one third of global stocks, most in batter with chips.
  7. New findings in how bats fly could help in the development of machines which fly by flapping.
  8. “A picture tells a thousand words, but a sound tells a thousand pictures.” Sounds bring Google Earth to life
  9. Poodle Milo helps epilepsy woman. 456,000 or one in every 131 people in the UK has epilepsy.
  10. Fasterfox Firefox add-on allows you to tweak many network and rendering settings.


Google Analytics MapOverlay
Originally uploaded by Lilly.

A few days ago Steve pointed me at New Google Analytics tour and I signed myself up to check out its user interface. Phil also pointed me at Jeffrey Veen’s post on his work, which led me to Avinash Kaushik’s comprehensive overview post.

It’s well worth checking out the user interface yourself. If you have a gmail account and want to try it out without setting it up, I am happy to give you an access to my reports for your “wow” experience. Please contact me from here.

I don’t mean to hack Google (thanks to Firebug), but they seem to have a sparkline webservice similar to Joe Gregorio’s. Jeffrey also had the sparkline in the Google Reader trends prototype.

I like the Map Overlay in the city level which looks like ClusterMaps, though the navigation is not like Google Map.

I am happy with the WordPress stats of my blog and I know they don’t allow to add any javascript to posts. Did you know that they have been running the Google Analytics for wordpress.com domain? Check out the source code of this page and search for “www.google-analytics.com“.

BTW, WordPress.com’s April stats is impressive. Woulnd’t it be great if we could view their Google Analytics reports in addition to their own stats? WordPress.com is now a OpenID provider. I wish Google were a OpenID consumer and had the Access Manager of Google Analytics OpenID enabled.

Related Posts:

Archives

Blog Stats

  • 87,646 hits

Identitiy