Saturday, November 20, 2010

Using the camera (from your programs) on Android is easy ...

... if you know how to do it.

If you don't know it, it can be a PITA as I have e.g. described at the Android-Tech-Talk in Stuttgart.

For Zwitscher I was for quite some time trying to enable it to take pictures and upload them to pictures services like with other Twitter clients. So I started looking at the documentation and found a How To entry which basically points to the documentation for the Camera.  So I've been trying around with the preview stuff and was googling like crazy and so on, but this turned out to be too complicated for me to follow in the short term.

Yesterday I was reading about Intents in the Documentation and what Google Intents are available. This brought me to the idea of investigating if the camera could also be called that way.

So I've googled for "android camera app intent" and found this forum post which explains how to do it.

Basically start the camera via:

Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, 1);

and then later when the picture has been taken fetch the picture in the onActivityResult() callback:

@Override
public void onActivityResult(int requestCode, int resultCode,Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode==1&& resultCode==RESULT_OK) {
Bitmap bitmap = (Bitmap) data.getExtras().get("data");
}
}

This takes a small picture suitable for e.g. Twitter.

To take a larger picture you need to tell the intent where to store a larger picture and pick it up from that location.

intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, path)

So you see - if you know all this, it is fairly easy to start the camera, take a picture and then use it later. No dealing with PreviewHolder and all that stuff.

 

Thursday, November 04, 2010

Small tip when repeatedly doing upgrade testing

Suppose you want to test upgrading your software from version x to y. This often includes updates of database schemas, tables and content.

The obvious way to do this is

do {
install version x
quit x
install version y
verify upgrade
} while (upgrade was bad)

The install version x step here is usually time consuming and involves UI interactions.

A better approach here is to

install version x
create a db backup
verified = false
while (not verified ) {
install version y
if ( upgrade good )
verified = true
else
install db backup
}

With PostgreSQL taking a backup would look like this:

pg_dump -f outfile -b -C dbname

e.g.:

pg_dump -f ~/jon231.dump -b -C jon231

and then the re-install:

pg_restore outfile

e.g.:

pg_restore ~/jon231.dump

Wednesday, November 03, 2010

Mein erster Android-Vortrag - und wie geht nun es weiter?

Gestern habe ich bei der STUGTUG in Zusammenarbeit mit der JUGS beim Android TechTalk meinen ersten Vortrag zum Thema gehalten.

Ich wurde gefragt, ob ich so über meine ersten Erfahrungen erzählen könne, was ich dann auch gemacht habe - nachdem ich mich an Hand von konkreten Beispielen in eine Materie einarbeiten muss habe ich eben von den Erfahrungen mit meiner ersten App, Zwitscher, berichtet (Folien gibt es hier und hier das Video). Peter Hoffmann hat einen Review geschrieben, wie auch Benny. Alle Videos sind in diesem Album zusammengefasst.

Die Auswertung der Feedback-Bögen gibt ein eher gemischtes Bild. Von "Sehr gut" bis "Kann ich nichts mit anfangen, weil ..."  "... ich nicht weiss was eine Activity ist", "... ich das schon seit Jahren mache" war alles dabei. Der Notendurchschnitt lag bei 2,8.

Mein Fehler war hier offensichtlich, für Anfänger in der Android-Programmierung schon zu tief in der Materie gewesen zu sein, während für die "alten Hasen" nicht so viel Neues dabei war.

Deswegen habe ich mir jetzt mal vorgenommen, möglichst bald einen Workshop für Einsteiger anzubieten, bei dem eine kleine Applikation von Null aus aufgebaut werden soll. Der Workshop wird dabei nicht nur "Frontalunterricht" sein, sondern die Teilnehmer sollen / müssen selbst Hand anlegen (Java SE Kenntnisse müssen vorhanden sein).

Hierzu nun ein paar Fragen:

  • Wird so was (= Einsteiger-Workshop) überhaupt gewünscht?
  • Was ist ein möglicher Zeitrahmen (am Abend, Samstag, Wochenende, Weihnachtsfeiertag, ...)
  • Was darf es kosten? Der Workshop ist non-Profit, aber Räume, WLAN, Getränke und Brötchen / Pizza kosten einfach Geld
  • Was für eine App soll es werden?

Ich habe auch eine Idee für einen umfangreicheren Workshop im Hinterkopf, möchte dazu erst mal noch nichts verraten ;-)

 

 

Tuesday, November 02, 2010

RHQ tab sweep

It has been a while since the last tab sweep, so quite some material has accumulated:

First and notably: we now have contributor guidelines, which should make it easier for everyone to get contributions into RHQ.

Alexander Kiefer has finsihed his master thesis work on the Nagios Plugin and the dynamic types detection. The later work needs to picked up and worked on further. A big part of the resource type (and metric scheduling and .... code depends on the static nature of the metadata in the plugin descriptors. The code is currently in the nagios branch in git.

Anyway: congrats Alex and many thanks for your work and also thanks to your employer, AG der Dillinger Hütten,for sponsoring this work.

Steve Millidge contributed a large overhaul of the MySQL plugin to RHQ - thanks Steve!

The team is currently working on transitioning the UI to GWT for RHQ 4. To see what is going on, you can have a look at a short video overview or play with the first developer preview.

And then there was conference season for me and I gave talks at JUDCon Berlin and 1daytalk Munich:

Mazz has written an interesting article on how to do some RHQ agent profiling via Byteman. He also wrote about remotely installing agents on yet unmanaged machines.

Joseph Marques has written a short article on the new search functionality and a longer analysis on GWT compile performance - this is quite interesting and for sure also helpful for other projects that want to use GWT.

John Sanda has written a whole series of articles on usage of the RHQ cli:

Jay Shaughnessy has also written an article about the RHQ CLI. He is talking about using the provisioning feature from the CLI.

Lukáš Krejčí has also written a series of articles:

 

As always, please give us (and / or the article writers feedback).

Monday, October 18, 2010

Overhauled MySQL plugin for RHQ

I have just pushed a contribution by Steve Millidge to RHQ master. He overhauled the existing MySQL plugin big time, so that it now auto discovers the MySQL server with its databases and users.

Also the number of gathered metrics is vastly improved. The new code is currently only in master (in git), but will also show up in the next RHQ build.

Here is a small screen shot (with the current state of the RHQ 4 UI) that shows what has been discovered on my local MySQL 5.1.51 instance.

 

 

Bildschirmfoto 2010-10-18 um 11.58.06.png

 

As always, try it out and please give us and Steve feedback ( I am sure he also accepts pints as feedback :-)

 

Saturday, October 16, 2010

Android and the title bar progress indicator

 

I just spent quite some time trying to figure out how to get a tiny little spinning progress thingy in the title bar of my application. And to be honest, while there is a lot of documentation out there, it is far from trivial to finally implement it.

The best "how to" is just  few weeks old and the author also wanted to have such a thing.

Basically steps are: define a custom layout for the title bar, ask the system to allow replacing the title bar, set the content layout, only then set the custom title bar layout and then obtain a reference to the ProgressBar object.

As the post above is quite extensive, I just want to emphasis on the latter points:

 

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
   requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); // 1
   setContentView(R.layout.single_tweet);        // 2
   getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
                              R.layout.window_title); // 3
   pg = (ProgressBar) findViewById(R.id.title_progress_bar); // 4

 

Comments for the lines above:

  1. Ask the system to allow for a custom window title
  2. Set the content view of the whole window
  3. set the layout for the custom title
  4. Obtain the reference to the progress bar

If this order is not honored, pg, the reference to the ProgressBar will be null.

The layout for the title is shown in above post, so I'll not repeat it here.

The second important aspect is the usage of the ProgressBar. The main thread of execution in Android is the UI thread. And when a callback is running, the UI is not updating while such a callback is running. So, the following is not starting the progress indicator:

   public void myButtonPressedCallback(View v) {
      pg.setVisibility(ProgressBar.VISIBLE);
      doSomeThingLongRunning();
      pg.setVisibility(ProgressBar.INVISIBLE);
}

The state of the progress indicator will only be set after myButton..() has returned. In oder to correclty handle this, you need to e.g. use an AsyncTask:

 

    private class DownloadImageTask extends AsyncTask<User, Void,Bitmap> {
        protected void onPreExecute() {
            super.onPreExecute();
            pg.setVisibility(ProgressBar.VISIBLE);
        }
        protected Bitmap doInBackground(User... users) {
          doSomeThingLongRunning();
        }
        protected void onPostExecute(Bitmap result) {
           pg.setVisibility(ProgressBar.INVISIBLE);
        }

 

   }

In this case, the ProgressBar is made visible in onPreExecute() (which runs in the UI thread. Then the background thread is started to do the long running computation and after this has finished, onPostExecute() runs again in the UI thread, where you can 'switch off' the ProgressBar again.

 

Friday, October 15, 2010

Android app lifecycle or "why do I sometimes get an empty screen?"

 

Many examples on the net for Android programs use something like this:

  public class MyActivity extends Activity {
    protected void onCreate(Bundle savedState) {
         super.onCreate(savedState);
         doSomeSetup(); // e.g. login to a remote site
dispatchToOtherActivity();
   }
}

This is usually fine, but in some situations you end up with an application that just shows an empty screen. You may wonder what happens here.

Actually if you have a look the Android Application Lifecycle , you will see that onCreate() will only be called when the application is 'cold started'.

If the application is just resumed, onCreate() is not called again and and thus the dispatch to the next activity never happens. The application just sits on the empty screen.

There is an easy solution: onResume() is always called when the application comes to foreground again no matter if the app was cold started or just came to foreground again. So the above code could also read:

public class MyActivity extends Activity {
   protected void onCreate(Bundle savedState) {
         super.onCreate(savedState);
         doSomeSetup(); // e.g. login to a remote site
   }
protected void onResume() {
         super.onResume();
         if (!loggedIn()) 
                doSomeSetup()
         dispatchToOtherActivity();
}
}

Now on cold start, the login is done in onCreate() and then control goes to onResume() that dispatches to the next activity. On warm start, onResume() is directly called, that can check if the login is still valid.

 

Monday, October 11, 2010

JUDCon Berlin review (with pictures)

judconberline_logo.png

I've been at JUDCon Berlin for the last two days and this has been a very good experience. The conference venue (Radialsystem V) was just perfect, my hotel was next door to the venue, and we had a lot of good presentations.

 

Radialsystem V
(Radialsystem V from outside)

 

Ok, this was a little sparse.

After last JUDCon in Boston was well received, the JBoss team decided to do another JUDCon outside of the US to meet more of the community. The choice was made to go to Berlin (probably because JBossWorld Berlin was huge too :-)

I've submitted a talk on plugin development for RHQ and the JBossAS admin-console, which was accepted, so I had the luck to go to JUDCon.

I arrived already on Wednesday evening, went to the hotel and later to a cocktail bar (Sanatorium 23) together with Tobias Hartwig, Mark Little, Bruno Georges, Marek Goldmann, Bela Ban and some others.

On Thursday JUDCon started with a "keynote" by Mark Little and then continued in two parallel tracks. I first went to the BlackTie talk by Tom Jenkinson - and after the talk it became apparent that the next presenter, Bill Burke, was not able to make it to the conference in time (he still was in Krakow at the JDD). So I took over and presented an overview over RHQ. The room was still full, nearly no one left even as Galder was advertising his Infinispan talk :-) As I did not prepare slides for the talk, I took the ones I used the week before at OneDayTalk (they are linked there). The biggest time of the talk I did a live demo of RHQ 3 including installing RHQ from scratch, taking my computer into inventory and showing the UI. As time was running out (45 mins aren't that much :-), I could not show provisioning. After the talk I got a lot of questions - directly at the end of the session and also throughout the day.

Next, there was lunch in the big room with a speech given by a representative from Ingres, the sponsor of JUDCon. After lunch, sessions continued and I attended the two talks by Jesper Pedersen (IronJacamar and Tattletale - the latter is definitively something I need to look into) and then one by Steve Ross-Talbot about Savara before I gave my talk about writing plugins for RHQ.

This talk went quite well until the point where I tried to load my generated plugin into the IDE and the IDE just hang. And then when trying to compile, mvn gave me an error about some git problem. This something I need to look into. Nevertheless, I guess my audience got the idea on what is needed to do.

After dinner, where an iPad was given away by Ingres (Red Hat employees were not eligible :-( ) Hackfest started with some lightning talks were Jesper was quickly presenting about JBoss AS 7 (now on GitHub). Hackfest went until 1am when were thrown out of the venue.

Friday started with another series of talks. targeted around jBPM and Rules and other relevant themes like Errai and CDi or performance. I sneaked in many talks for a bit.

JUDCon has finished at 5:30pm with most of the participants staying 'til then end. I went to the airport and back to Stuttgart.

JUDCon was a great experience with lots of good talks and conversations. Participants were happy to get information from the source, from the people who know the stuff best as they have written it in the first place.

And for me it was a great pleasure too to meet my colleagues, who I normally only read in emails, blog posts or on Irc.

Slides to all talks are supposed to show up on the JUDCon page very soon.

 

IMAG0127.jpg
(Tom Jenkinson)
IMAG0131.jpg
(Jesper Pedersen on JBossAS 7)
IMAG0132.jpg
(Heiko Braun on Errai)

 

Tuesday, October 05, 2010

Re-write Excel files with POI 3.6

 

Apache POI is a well known (java) project to handle reading and writing MS-Office documents. Another project in that area is jexcel (Lars Vogel has written a tutorial on its usage).

I was using POI in the past to just write new documents. Now I needed to read a worksheet and update it. POI has a nice "busy developers guide" on this, which did not directly work for me, so I've updated it to work for me:

import org.apache.poi.ss.usermodel.Row;

import org.apache.poi.ss.usermodel.Sheet;

import org.apache.poi.ss.usermodel.Workbook;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;

import org.apache.poi.ss.usermodel.Cell;

...

 

public void run() {

 

Workbook wb;

// Check if Workbook is present - otherwise create it

try {

InputStream inp = new FileInputStream(WB_NAME);

wb = new HSSFWorkbook(inp);

} catch (Exception e) {

wb = new HSSFWorkbook();

}

// Now write to it

try {

// Check if we have our sheet

if (wb.getNumberOfSheets()==0) {

wb.createSheet("Overview");

}

Sheet sheet = wb.getSheetAt(0);

 

// Write row=2, cell=3 ==> D3

Row row = sheet.getRow(2);

if (row==null) // empty sheet

row = sheet.createRow(2);

Cell cell = row.getCell(3);

if (cell == null)

cell = row.createCell(3);

cell.setCellType(Cell.CELL_TYPE_STRING);

cell.setCellValue("a test");

 

// Write the output to a file

FileOutputStream fileOut = new FileOutputStream(WB_NAME);

wb.write(fileOut);

fileOut.close();

}

catch (Exception e) {

e.printStackTrace();

}

}

 

 

Of course your mileage may wary :-)

 

Monday, October 04, 2010

RHQ 4 UI preview video

I've put a video on Youtube, that shows a quick preview of the RHQ 4 UI work. As you know the UI is being rewritten in GWT and we have posted a developer preview some time ago.


If you did not install this preview, here is a chance to get a glance at what we're working on.


As always: please give us feedback!

Saturday, October 02, 2010

Small review of OneDayTalk (with pictures)

Yesterday I was in Munich at the JBoss One Day Talk conference, talking about RHQ. The conference was organized by the Munich JBoss User Group.

Conference was very nice - like a big family event. Met some (JBoss) colleagues like Emmanuel Bernard, Manik and Navin Surtani, Thomas Diesler and Heiko Braun, as well as others like Andreas and the organizing Serge Pagop (who also works for Red Hat now). Also met Java Rockstar Adam Bien.

My talk about RHQ went mostly well - had around 40-50 listeners and got some good questions after the talk. The downside was that I spending a little too much time on the slides and general aspects so that I was not able to fully show the new RHQ 4 UI or even the provisioning subsystem.

If you want to new about the new UI, you can download the developer preview we released some time ago or checkout this video on YouTube. And come to JUDCon in Berlin next week to see it in action as well, as learn about plugin development.

My slides from the talk are also available as PDF.

Here are some impressions from the OneDayTalk:

Adam Bien on stage
(Adam Bien, hacking live on stage)
Manik Surtani
(Manik Surtani, talking about Infinispan)
Volker Bergmann
(Volker Bergman on performance testing)
Navin Surtani and Emanuel
(Navin Surtani and Emanuel Bernard)
Löwenbräukeller
(After-talk-Party at Löwenbräukeller)

Sunday, September 26, 2010

Zwitscher, a twitter client for Android

Today I finally came around implementing list support for what is my Hello World of learning Android, a Twitter client called Zwitscher.

Main screen looks like this:

main-screen.png

 

You can see support for lists as first class citizens.

Zwitscher is still in a very early stage and of course contains bugs and unimplemented features.

Zwitscher is released as open source - to learn more about it, visit its home page at http://bsd.de/zwitscher/

Wednesday, September 22, 2010

First developer preview of RHQ4 available

We have just put a first developer preview of the new RHQ 4 UI online.

This preview is NOT intended FOR PRODUCTION or serious testing, but should rather be seen as an insight on what we are working on.

RHQ4 Dashboard
To learn more about the preview, visit the release notes page from where you can also download it.
As always feedback is very welcome (this includes patches and other code submissions) -- check the contributions page.
If you want to use RHQ for more more serious work, please use RHQ 3.

Friday, July 30, 2010

RHQ (Jopr) tab sweep (updated)

So since the last tab sweep I have accumulated quite some links.

First and foremost there is the Release of RHQ 3.0 (final). As we are phasing out the word "Jopr", the Jopr bits are now always included in RHQ.
This release has been reflected in other publications like



RHQ 3 has a new bundle provisioning feature. This article talks about bundle formats and a simple generator to create bundles for deployment by RHQ.
Mazz explains how to deploy in his article provisioning content via RHQ.

Greg Hinkle wrote three articles that talk about the upcoming GWT UI (parts of this are already in RHQ 3 in the bundle provisioning):
New UI technology, Exposing domain objects to GWT and RHQ and customizable dashboards

Joseph Marques has posted a very good in-depth analysis of the GWT compile performance (in RHQ) and shows how to tweak the settings to get the best results.

Tom Jenkins created a video on how to administrate BlackTie via RHQ plugin - the video actually features the admin console in AS 5

Wednesday, July 14, 2010

Simple Bundle generator for RHQ provisioning feature

So in RHQ 3 we've added this cool new provisioning feature.
This allows you to deploy a bundle to a group of platforms or other resources like e..g JBossAS servers.

So what is a bundle? Basically it is some piece of software to be deployed and a matching recipe file. There are two kinds of recipe files: FileTemplateBundle and AntBundle - I'll only talk about the ant-style recipes here.


When I started looking at the bundle UI, I remembered Mazz' great video, but being on the train, I had no access to it. So how do I deploy?
First thing you need to have is either a valid bundle distribution file or at least a valid recipe file.

A bundle distribution file is (by default) a zip file where all entries lie directly in the root directory like this (actually other is possible):

$ unzip -l bundle.zip
Archive: bundle.zip
Length Date Time Name
-------- ---- ---- ----
1150 07-12-10 16:27 demo.war
948 07-12-10 16:38 deploy.xml
-------- -------
2098 2 files


In the bundle I have demo.war to provision and the deploy.xml file as recipe. Lets have a look at the recipe file:


<?xml version="1.0"?>
<project name="demo" default="main"
xmlns:rhq="antlib:org.rhq.bundle">
 
<rhq:bundle name="demo" version="1.0"
description="Just some bundle">
 
<rhq:input-property
name="test.name"
description="Who do we greet?"
required="true"/>
 
<rhq:deployment-unit name="war">
<rhq:archive name="demo.war">
<rhq:replace>
<rhq:fileset>
<include name="*.jsp"/>
</rhq:fileset>
</rhq:replace>
</rhq:archive>
</rhq:deployment-unit>
 
</rhq:bundle>
 
<target name="main"/>
</project>


Some of you will see that this is an ant file with some extra tags in the rhq namespace. Lets go through the sections.

First is the boilerplate code that defines an ant project and then
within that we see one bundle denoted by the <rhq:bundle> tag. The bundle has a name of demo and is at version 1.0.

Next there is an <rhq:input-property> tag which defines that the deploy UI should ask for a property test.name which may be used to replace tokens by the users input. This input-property is optional and can show up multiple times.

The most important part is the <rhq:deployment-unit> tag, which defines the content to deploy in its embedded <archive> tag - demo.war in our case. And then we have a <rhq:replace> element embedded in this which defines a standard ant fileset that defines files in which token replacements can occur, like .jsp files in our example.

While this recipe file is not complicated, it still needs some typing, so I started writing a bundle generator, which is in RHQ 4 master in modules/helpers/bundleGen/ (actually you can use that to define bundles for RHQ 3)

Using the bundle generator




$ java -jar bundleGen-4.0.0-SNAPSHOT-jar-with-dependencies.jar
Please give the project name[myProject]:
Please give the bundle name: demoBundle
Please specify the bundle version[1.0]:
Please describe your bundle: Just testing
Please give the name (only) of your bundle content file: demo.war
Please give the directory (only) of your bundle content file: /tmp/
Please give a patten of files to replace templates: *.jsp
Jul 14, 2010 9:24:31 AM org.rhq.helpers.bundleGen.BundleGen createFile
INFO: Trying to generate /var/folders/m9/m9pXAK2WHoyq22G2P9J8L++++TI/-Tmp-//bundleGen/deploy.xml
Jul 14, 2010 9:24:31 AM org.rhq.helpers.bundleGen.BundleGen run
INFO: Your bundle is now ready in [/tmp/generatedBundle.zip]


So this is asking some questions - those with [text] have this text as default, so you can just press return to accept it.

When the generator has finished it prints where you can obtain the created bundle from - /tmp/generatedBundle.zip in our case.

The generator is far from finished; for example there is no way to specify <rhq:input-property> tags so far.

XmlQuestionsReader



One interesting detail is the XmlQuestionsReader which takes input from an XML file about the questions to ask. It partially supports internationalization in the form that you can have basename_lang.xml variants of the input, as you can see here. I am not yet exactly happy with this, as there is no fallback to the default version if a question is not defined.

Also there is no way yet to tell that a certain <question> can be repeated to form a List/Set (as it would be needed for the <rhq:input-property> tags).

So please give me feedback and if you want to help improving the generator, you are free to do so.

Friday, July 09, 2010

RHQ 3 released, but where is Jopr ?



So we've released RHQ 3 two days ago -- but what about Jopr? Isn't that supposed to build on top of RHQ? Shouldn't there be a release as well?

Actually we did release Jopr too -- those bits are now (since last September) included in RHQ, so there will be no more separate artifacts or downloads. When you download RHQ, you'll get Jopr too -- so simple :-)


The documentation wiki has full install instructions.

Btw: DZone has a nice article about all the new features, check it out and vote it up. They also have my announcement post online.

Installing OpenSolaris on Parallels Desktop on Mac

To try some things I wanted to install OpenSolaris 2009.6 on Parallels Desktop on my Mac.

Install of OpenSolaris itself went well, but network was not available.
Searching around the net led to

http://www.opensolaris.com/use/network_administration.pdf
http://blogs.sun.com/lr/entry/opensolaris_in_parallels_vm_on

http://dlc.sun.com/osol/docs/content/2009.06/getstart/parallels.html
and finally

http://kb.parallels.com/de/7060 (or English: http://kb.parallels.com/en/7060)

But still no avail.

It turned out that the script change is almost complete, but is missing
one additional line. Below "Compiling driver ..." it should read


cd $tmpdir/$driver && /usr/ccs/bin/make install > /dev/null


After this change dladm show-phys shows the interface and ifconfig ni0 plumb is able to use it. After a reboot, networking is working :-)

Wednesday, July 07, 2010

RHQ 3.0.0 final has been released



The RHQ team is proud to announce the immediate availability of RHQ 3.0.0.

This release features several month of hard work by the development team and external contributors. Many of the changes have been already made available in the past through seven community releases.

Highlights of this release are:

  • Pluggable alert senders
  • Provisioning of
  • Improved search capabilities



You can browse the full release notes on the RHQ wiki.

The release can be downloaded via the RHQ web site or directly from SourceForge

Thursday, June 17, 2010

Upcoming talks about JBossON / RHQ / Jopr

Below is a list of upcoming talks about
JBoss Operations Network (JBoss ON), RHQ and Jopr

Please inform me if you know of more talks around those topics, to that I can announce them here as well.

Thursday, June 10, 2010

RHQ - how to monitor local JMX servers

If you are using tools like JConsole or VisualVM, you may have seen that it is possible to monitor JVMs that don't have explicit jmx-remoting settings.
This post shows how you can easily achieve the very same in your plugin.

Basically you need to do four things:

  1. Have your plugin use the jmx-plugin:

    <plugin name="hadoop"
    displayName="hadoopPlugin"
    <depends plugin="JMX" useClasses="true"/>


  2. In the Discovery Class (could also be done in ResourceComponent.start() at the very beginning), you put some additional plugin properties:


    public Set<DiscoveredResourceDetails> discoverResources(
    ResourceDiscoveryContext context)
    throws Exception
    {
    Configuration pluginConfiguration = context.getDefaultPluginConfiguration();
    pluginConfiguration.put(new PropertySimple(
    JMXDiscoveryComponent.COMMAND_LINE_CONFIG_PROPERTY,
    javaClazz));
    pluginConfiguration.put(new PropertySimple(
    JMXDiscoveryComponent.CONNECTION_TYPE,
    LocalVMTypeDescriptor.class.getName()));
    ...

    The javaClazz is the fully qualified name of the main class as it would
    appear with jps -l :


    $ jps -l
    3299 org.apache.hadoop.mapred.TaskTracker
    12311
    3177 org.apache.hadoop.hdfs.server.namenode.SecondaryNameNode
    3037 org.apache.hadoop.hdfs.server.namenode.NameNode

    (the output is vmid and class, where the vmid is usually the process id)

  3. Have your component class extend JMXComponent

    public class HadoopServiceComponent extends JMXServerComponent, ...


  4. In component.start() call the JMXServerComponent

        
    public void start(ResourceContext context) throws Exception
    {
    super.start(context);
    ...
    }



From there on, you can get the JMX connection by a simple

     EmsConnection conn = getEmsConnection();


and so on ...

Back from Linuxtag





So I am back from a quick trip to Linuxtag 2010 in Berlin where I was presenting "Systemmanagement with RHQ - also for Linux". My talk featured an overview of RHQ by slides and live demo and a demonstration of the Nagios plugin, Alexander Kiefer has written.

The meeting room wasn't exactly crowded with around 20 people, but I saw them writing down stuff and they were asking questions, so I consider this good anyway.

At Linuxtag I also met Dalibor Topic from OpenJDK, my colleague David Lutterkort (who was presenting about deltacloud) and Hardy Ferentschik who was presenting about Hibernate Search. Unfortunately I was not able to attend any of those, as either I was still on my way to the conference or already back.

While I spent a good part of the day in trains (5h30 in the morning + commuter train within Berlin and 5h in the evening + commuter train), I was also able to walk around Linuxtag and have a glance at the exhibition. Many (larger) Open Source Projects were present (Fedora was missing to my surprise) and Debian even hold their own mini conference.
Also some system integrators and other companies like Google, O'Reilly or Addison-Weseley had a booth.


In the train I started hacking a plugin to monitor Hadoop clusters. It will find the various instances and already connects via JMX to them. The NameNode even has some statistics exposed. I'll put that into RHQ git within the next days.


You can find slides of my talk online - those are rather sparse as I was doing a long demo session showing RHQ, the Nagios integration and how easy it is to put an agent on a new platform and get this platform into inventory (literally took 2mins incl. downloading)

Sorry that there are no photos or even a video - I just did not feel like carrying the appropriate equipment around.

Friday, June 04, 2010

RHQ at Linuxtag






I will present "Systemmanagement mit RHQ - auch für Linux" at Linuxtag
Berlin next wednesday, June 9 at 3pm in room Europa 1.

I will talk about the architecture of RHQ and how it can be used
for Linux monitoring and will especially mention the Nagios integration by Alex Kiefer.

Wednesday schedule for Linuxtag is here (Don't worry, if you still see the CDI talk in this slot. I am sure my talk will soon show up at 3pm in room "Europa 1")

Monday, May 31, 2010

RHQ / Jopr tab sweep

RHQ release 3.0.0.B06 is out and contains support for provisioning of new software.

Alex Kiefer has worked hard and now we have Nagios support in RHQ.

Episode 6 of the Jopr podcast has been released and is talking about the new pluggable alert senders in RHQ.

And finally we've got portuguese translations of the installer messages by Rafael Soares Tuelho.

As always, give us feedback.

Thursday, May 27, 2010

Nagios Plugin for RHQ and Jopr available



As previously written, Nagios support is coming to RHQ.

Well, Alex has done more work and actually it is here now in its first version and is out-of the box able to monitor the standard services that are in a Nagios install:

Screenshot of resource tree and metric

(Screenshot with standard services and metrics)


This picture shows again the setup:
#alttext#


To take the nagios server into inventory, you need to go to a platform and use the Manually Add functionality, where you have to give the connection properties "host, where nagios is on" and "port" (6557 in the image)

But before you can start you have to:

  • install mk_livestatus within Nagios and xinetd.
    Alex has documented this in the Wiki; the mk_livestatus installation is very well described on the livestatus web page.
  • For all services in addition to the standard ones supplied in the plugin descriptor you need to update the plugin-descriptor of the plugin. This is described below.





As we know the second step is somewhat cumbersome, we will in the future work to make the detection of the resource types dynamic, so that you basically need to point the plugin at a Nagios install and the plugin will then "learn" all the types of service (e.g. SSH, Swap , ..).

PLEASE give feedback on the plugin on the rhq-devel mailing list.
Be it because you know more cool metrics to look at or because you want to help with the parser issue mentioned below. Also the source has a TODO file, that lists more ideas for contributions :-)

Source



You can get the source from the RHQ git repository in the nagios branch.
This first version has been tagged as RHQ_NAGIOS_PLUGIN_V1



Adding additional services



The following is an excerpt from the plugin descriptor:

   <service name="Root Partition"  
class="NagiosMonitorComponent"
discovery="NagiosMonitorDiscovery"
description="root partition service">
<metric property="free_space|plugin_output|.*/ ([\d]+).*"
displayName="Free space" measurementType="dynamic"
units="megabytes" displayType="summary"/>
</service>


The first thing you need to provide is the name of the RHQ-resourceType, which is used in <service name="Root Partition"... To obtain those, you can do the following query against mk_livestatus:

$ cat service-query
GET services
Columns: display_name
$ nc localhost 6557 < service-query
Root Partition
SSH
...
$

So in this example services were 'Root Partition' and 'SSH'

The next thing is to provide the metrics. The property="free_space|plugin_output|.*/ ([\d]+).*" attribute is used here. It actually consists of three parts separated by a bar (|) symbol:

  1. Text identifier - currently unused
  2. The column of the livestatus service query output (see below)
  3. A regular expression where the first capturing group is used as return value


Let's have a look at an extended service query (actually in version 1.0 of the plugin, only he plugin_output column is supported, as the parser in the plugin needs some more work (see below):
$ cat service-query
GET services
Columns: display_name plugin_output
$ nc localhost 6557 < service-query
Root Partition;DISK OK - free space: / 3611 MB (48% inode=71%)
...
$


So Root Partition delivered "DISK OK - free space: / 3611 MB (48% inode=71%)" which is then matched by .*/ ([\d]+).* to extract the value of 3611.

The parser issue



mk_livestatus delivers as default data separated by semicolon (;), but some columns like 'perf_data' (not shown above) can also return data that consist of multiple items separated by semicolon, so that the parser counts wrong and delivers bad answers.

Luckily mk_livestatus can do some
output formatting that can help to work around this. Please ping us if you want to help here.


RHQ community build 3.0.0.B06 released



The RHQ team is pleased to announce the immediate availability of community release 3.0.0.B06 of the RHQ systems management and monitoring platform. As before this release includes the Jopr bits.

This release features a lot of bug fixes as you can see on the
Release Notes.

New features include optimized search in Inventory and especially provisioning of software (like JBossAS servers). See below.

You can download the release from SourceForge

Provisioning...

To enable this you need to go to Administration -> System Configuration -> Settings and enable debug mode

#alttext#


This will then show a new menu "Debug" with a "GWT GUI" entry:

#alttext#


Click on "GWT GUI" and you'll get to a GUI written in GWT with a new "Bundle" menu item.

To learn more about this, have a look at the Wiki and especially
this flash demo video by Mazz

Translations for RHQ (we want you!)

Thanks to Rafael Soares, we now have Brazilian-Portuguese installer messages forRHQ

#alttext#

Click for a larger version


Those translated messages currently live in the 'translations' branch in git (which will shadow the master branch).

While we use I18Nlog for I18N output, there is no need to modify the java file, but one can just supply the "classical" .properties files for it.

We want you!

So if you want to help translate messages to your language, contact us and/or just start right away :) Make sure to also to check out the contributions page on our wiki.

Thursday, May 06, 2010

No wonder Mighty Mouse refused to work

I am for a long time user of a Mighty Mouse (actually 2 of them. And as every user of a Mighty Mouse, I have the issues of the mouse ball being stuck and needing some cleanup.

In the past I've turned the mouse around and rolled it over some issue, which helped more or less. But just now I had the urge to finally open it and really clean it. There are many "how-to"s on the web for this.

When the mouse was open, it became very obvious why it did not really work well anymore:

IMG_8664.JPG
(click for a larger version)


opening the white cage an removing the ball (which itself was totally clean) revealed more dirt:

IMG_8666.JPG
(click for a larger version)


Cleaning the little rolls was no issue, but putting them back was somewhat harder, as the thicker black rolls are magnetic and would directly attach to a screwdriver.

After assembling everything, the mouse responds well again, so problem solved for the years to come :)

Tuesday, May 04, 2010

RHQ community build 3.0.0.B05 released



The RHQ development team is happy to announce the availability of the 3.0.0.B05 community build of RHQ. As in previous community releases, this also contains the Jopr bits.

As usual, changes have been recorded on the change log page.

Most notable changes were:

  • Support for obfuscated db passwords

  • A fix for postgres 8.4+ servers to display statistics again
  • Completion of the alert sender plugins. This includes the possibility to finally execute resource operations on any resource as result of an alert
  • Suport for Oracle 11g database



Please use and test this release and report issues or feature requests in Bugzilla. If you want to contribute to the project, please have a look at the Contributions page on the wiki.

You can download the release from SourceForge.

If you want to develop plugins against this version, you can find the respective artifacts in the new JBoss Maven repository at https://repository.jboss.org/nexus/content/repositories/releases/org/rhq/.

Monday, May 03, 2010

Neues Maskottchen für die -T---kom ?

Heute auf dem Heimweg beim Alten Landtag gesehen:

DSC00106.JPG

(click auf's Bild für eine größere Version)


Die Farbe scheint nicht so ganz das Original-Magenta zu sein, aber das gibt dem Konzern ja auch ein ganz neues Image :-)

Friday, April 30, 2010

RHQ/Jopr plugin development and versions

Recently a user showed up on IRC and said he had written a plugin and that deploying it is throwing this error:

2010-04-30 14:26:10,601 WARN [org.rhq.enterprise.server.core.plugin.AgentPluginDeploymentScanner] Failed to scan plugin [...../myPlugin-1.0.jar] found on filesystem. Skipping it.

Cause: java.lang.Exception: No version is defined for plugin jar [..../myPlugin-1.0.jar]. A version must be defined either via the MANIFEST.MF [Implementation-Version] attribute or via the plugin descriptor 'version' attribute.


While the error message is accurate, it is still not obvious, what is going on, as most of the plugins in the RHQ source tree do not explicitly set a version number.

As the message says you need to:

  • either explicitly set a version in the plugin descriptor like

    <plugin name="myPlugin" version="1.2.3" ... >

  • or tell maven to add a Specification-Version: in MANIFEST.MF, which automatically happens when you have the rhq-parent pom as (indirect) parent of your pom, which then contains this:
    <plugin>

    <artifactId>maven-jar-plugin</artifactId>

    <configuration>

    <archive>

    <manifest>

    <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>



In most cases, following the RHQ-version is easiest, as you don't have to do anything. If you want to do release-cycles outside of RHQ, the explicit version is for sure better.

Monday, April 26, 2010

Nagios support coming to RHQ...

Alexander Kiefer started working on supporting the Nagios monitoring system from within RHQ. The idea here is not to plugin the Nagios plugins directly into RHQ, but to talk from RHQ (better, a RHQ plugin) to the Nagios instance via mk_livestatus for Nagios. And overview of the setup is shown in the next figure.

NagiosSetup.png


The first cut of the implementation is mainly about talking to Nagios via mk_livestatus. Next steps will be

  • Implement the plugin in a way that the user only needs to modify the plugin descriptor to monitor additional Nagios resources
  • Implement dynamic metadata so that the plugin can automatically detect resource types present in Nagios and detect resources of the given types.


Alex has started documenting the Plugin in the RHQ Wiki

Code for this is in the nagios branch in git.

PLEASE try it and give feedback on the rhq-devel mailing list

Monday, April 19, 2010

Muskelkater (German)

Vorgestern bin ich das erste Mal dieses Jahr wieder die 21km gelaufen und merke deutlich, dass ich noch nicht so richtig in der Form für die Strecke bin. Ab Kilometer 14 fiel es mir zunehmend schwerer und die letzten Kilometer waren eine reine Willensleistung, nicht aufzugeben. Aber immerhin war ich mit < 1:58h etwas schneller als beim Stuttgart-Lauf letztes Jahr. Es bestehen also berechtigte Hoffnungen, dass es mit diesem einen Jahresziel hinhaut.

Auf jeden Fall habe ich heute noch einen granatenmäßigen Muskelkater - speziell in den Waden.

Aber noch sind 2 Monate Zeit, um für den diesjährigen Stuttgart-Lauf zu trainieren.

Der vorherige Lauf in Kiew war weniger beschwerlich :-) (aber auch deutlich kürzer).

Wednesday, March 03, 2010

Multiple usage of the maven exec plugin

So I was trying to use the maven exec plugin in my alert-operations sender pom in RHQ to automatically run a java class and generate some documentation.

I've added the maven exec plugin to the pom like this:


<build>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<!-- Generate tokens.xml file -->
<phase>install</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>java</executable>
...


As soon as I added this and tried to build after a mvn clean, the build failed without an obvious message why. Commenting out this plugin made the build succeed. Digging around showed that we have an other call to this plugin in the root pom. So there was some clash - but which?

I thought "perhaps I need to include the execution from the root pom in mine as well (via copy&paste). I did that and got an error message, that it is not possible to have two executions without an <id> in a pom. So it turned out that both executions had the same implicit id - even while being in different poms, so one was overwriting the other.

Now I have


<execution>
<id>generate-tokens-xml</id>
<!-- Generate tokens.xml file -->
<phase>install</phase>
<goals>


and everything is fine again.

Saturday, February 27, 2010

Glassfish v3 - what's the deal to have Weld and REST?

<UPDATE>

It turns out I did the right thing, but obviously needed a few more mvn clean install cycles (or in other words I have no obvious clue why this consistently failed at the start

</UPDATE>

---------------

So I've been trying to write an app that uses CDI (Weld) and JAX-RS.
As I want separate layers, I coded everything up to have a web.war, an ejb.jar and packaged everything together in an ear-file.

I've coded a bean like this:

@Stateless
@Path("/xx")
@Produces({MediaType.TEXT_PLAIN})
@Named
public class StatusManager {

public String foo() {
...
}
}


Now I can use it in a JSF like

 <h:commandButton value="Submit!" action="#{statusManager.foo}"/>

Works like a charm.

When I try to accces the REST endpoint I get a "resource not found". Ok,
so I add some stuff to web.xml:

    <servlet>
<servlet-name>ServletAdaptor</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ServletAdaptor</servlet-name>
<url-pattern>/xxx/*</url-pattern>
</servlet-mapping>


Now accessing the JAX-RS endpoint works like a charm, but the above JSF action breaks and the container shows the following in the logs:

com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes.


Does anyone know what is going on and how to use both at a time?

Monday, February 22, 2010

RHQ / Jopr tab sweep

Lot has happened since the last tab sweep ...

Releases

RHQ 3.0.0.B03 has been released. You can find more information on the release notes page and the bits at the download page.

Videos

There are several new videos available:





Talks

I've been talking about RHQ at FOSDEM X - the talk was well received and its recording is finally online (see above).


Misc

Spacewalk 0.8 has been released.

Joe Marques gives a tip about automation in web development




Quote html for MarsEdit



I am using MarsEdit to post my blog entries, which is a nice editor (ok, it could sometimes have a more wysiwig mode, but in total I am happy with it).

One thing that I find often annoying or missing when writing posts is that there is no build in quotation mechanism for '<' in a <pre> block (many of my posts are rather technical and contain XML snippets).

Luckily MarsEdit has AppleScript support, so I wrote this little AppleScript script (actually I copied a good part from the supplied Add Paragraph Tags one):


tell application "MarsEdit"
try
set currentWindow to document 1
on error errorMessage
displayErrorMessage("Can’t add paragraph tags because no post windows are open. This script works on text in the frontmost post window.") of me
return
end try

set currentTextView to selected text in currentWindow
set numChars to number of (characters in currentTextView)
set newBodyText to ""

repeat with i from 1 to numChars

set currentChar to character i in currentTextView

if (currentChar is "<") then
set newBodyText to newBodyText & "&lt;"
else
set newBodyText to newBodyText & currentChar
end if
end repeat

set (selected text in document 1) to newBodyText
end tell


This allows to quote the current selection. Save the script to
~/Library/Application Support/MarsEdit/Scripts/Quote Html.scpt.
It will then be availably in the ApppleScript Menu:

Bildschirmfoto 2010-02-22 um 09.35.54.png


To use it, just select the text and then invoke this Quote Html menu item

Monday, February 08, 2010

Small FOSDEM 2010 round up (with pics and video)

So I've spent last weekend in Brussels, Belgium at FOSDEM, gave a talk, met with some colleagues and had a great time.



Ok, this was a bit tense :)

FOSDEM 2010 was the 10th incarnation of the Free and Open Source Developer's European Meeting. There have been thousands of geeks at the ULB (UNiveristé libre de Brussels) - exact numbers are not known as there has been no official registration. THere have been tweets about being around 2000 devices with IPv4 and close to 2000 devices with IPv& active - this already shows the size of the audience.
Despite this huge number of devices online, the network was great (FOSDEM had a 1GBit link to the internet) - wireless was available in nearly every room at good strength and performance On sunday morning they even encouraged people to use more bandwidth - many much more commercial conferences should talk to the FOSDEM NOC in order to learn how to do this.

I arrived in Brussels on Saturday morning having taken an early train from Stuttgart - after Cologne I met the first two other guys heading to FOSDEM too :)

Later on saturday I gave myself a talk about Systemsmanagement with RHQ. Slides are available here.

After my talk, my colleague Mark Procter gave a presentation about Drools. When my talk was over I felt very much relieved and was more able to attend other talks. I wanted to attend some Postgres related ones, but they were already crowded.

One of the/my highlights was the talk by Andy S. Tanenbaum about Minix 3 - he presented with a good sense of humor, so it was nice to listen. His talk actually made me want to do some low-level stuff hacking again (I used to work on NetBSD in the past). Later on I was sitting in the Free Java track and was thinking that I should perhaps also start hacking on the VM. Lukily for me I did not attend all talks. Otherwise I'd probably end up with programming Drupal in Assembler for one of those little embedded boards I that the OpenEmbedded guys had on display :-)

On Sunday Dave Fetter from Postgres showed on Sunday how to compute Mandelbrot sets and solve the Traveling Salesman Problem in SQL on Postgres - totally crazy! :)

After this I have been in the Free Java dev room and met some colleagues from Red Hat, working in that area - it is always nice to finally be able to put a face behind a name.

Below are a few impressions from Fosdem and Brussels - enjoy (I will fix the image orientation as soon as I know how ... ). More pictures are e.g. on Flickr, here and here.


Below movie is also available as .ogg version (79 MB).