Posts Tagged java

Java Simon 1.0, monitoring API, released

It is some time ago when we wanted to use JaMON API to add some monitoring capabilities to our applications. After a few we found it to lack some featrues – especially it was difficult to organize monitors. Hence we decided to create our own alternative that brings two features JaMON can’t provide – monitors organized in a tree hierarchy (similar to JDK14 logging API) and nanosecond precision (which bind us to JDK 1.5 or higher – which we see as no problem for most newly developed applications).

That’s how Java Simon API was born – the project is hosted on Google Code: http://code.google.com/p/javasimon/

Short description from our page:

Java Simon is a simple monitoring API that allows you to follow and better understand your application. Monitors (familiarly called Simons) are placed directly into your code and you can choose whether you want to count something or measure time/duration. Access to Simons is provided via static SimonManager.

We hope all necessary documentation is there and it will be extended in the future for sure. Aside from core functionality featuring standard stopwatch/counter monitor types we provide Simon JDBC proxy driver featuring these monitors – so you can check how various JDBC calls perform, pin down slowest selects, etc. Driver is JDBC 3 compliant with data source implementations available and it was tested with Glassfish/XA datasource with Oracle as the underlying database.

What can typical Stopwatch do?

  •  it can measure time splits, parallel measurement is supported;
  • it provides total time, number of time splits, tracks max/min time, time stamp when extremes were measured, deviation, …;
  • and like every Simon it tracks first/last usage time stamp and features like enable/disable/reset are also available.

Why we brought in a new API when there is JaMON available? Well, we tried it with JaMON but than we wanted to crucial things that JaMON doesn’t provide:

  • as said – we wanted to measure time in nanoseconds (hence JDK 1.5 or higher is required);
  • we wanted all monitors to be organized somehow – so we implemented tree hierarchy similar to java.util.logging API – this provides powerful features like enable/disable/reset of the whole subtrees of this monitor hierarchy.

Version 1.0 contains core functionality and we realize it lacks many important features in the bigger picture of application monitoring. Our plans in the future covers:

  • Declarative Simon configuration.
  • JMX access to Simons, their values and enable/disable features.
  • Sampling, collecting, agregating with persistence backend (file/DB).
  • …and probably more, but not all in the next major release. ;-)

Leave a Comment

Installing Java… in doubts

Of course I have no serious doubts about Java. But often when I install new version on Windows they get back to me. This is how Installer screen looks like:

I hope you know what I mean. Jittered picture in the left corner, more jittered in the right corner and that OpenOffice promotion… geez, I hope more people will not hate OpenOffice because of this ugly screen. :-) Sometimes I am nitpicking – but this time I don’t see this as a little detail. It’s 2008, 13 years after Java launched and virtually anybody’s little project has much nicer (yet perhaps simpler) splash-screens and/or installers. Maybe it’s just my computer and/or Windows XP, but I don’t buy it, really. Even than it’s only Java installer that looks so ugly! In moments like this I really appreciate that self-extracting command-line installation on Solaris/Linux.

As a side-note to “Java on desktop” topic: I’ve also recently read news about the future of SwingX API and I’m a bit worried. I ask myself what’s the future of Java on desktop? It was never a complete success story, but it was still better and better. Now I’m not sure. And that ugly installer only makes me think even worse about it. Still – I’m a Java professional – but imagine how scarred must common users be! ;-)

Comments (1)

JPA, PostgreSQL and bytea vs. oid type

I started to work on a private project using JBoss Seam, Facelets, RichFaces (proven stack from Seam’s Booking demo :-) ) with PostgreSQL 8.3 as a backing database – database I prefer for years for whatever reason. Hibernate is used as the JPA provider (packaged with Seam anyway) and the most recent JDBC 4 driver for PostgreSQL is used.

I added column:

picture bytea;

Somehow – after reading 8.4 Binary Data Types – I thought that bytea is the right guy for the job. Of course I had an entity with proper annotation and field:

    private byte[] picture;
    @Lob
    @Basic(fetch = FetchType.LAZY)
    public byte[] getPicture() {
        return picture;
    }

    public void setPicture(byte[] picture) {
        this.picture = picture;
    }

What was my surprise when following exception occurred:

java.sql.SQLException: ERROR: column "picture"
  is of type bytea but expression is of type oid

Now – when I know the solution – this message is pretty clear. It would be in case different types were mentioned in the message. While I understood that “he” somehow dislikes bytea, I couldn’t understand what the hell “oid” (as an “object identifier”) has to do with it?

I started my investigation with Google in one hand and PostgreSQL in the other. While 8.16 Object Identifier Types was not very helpful – as in “what does have ‘unsigned four-byte integer’ to do with my byte array?!” – some googled pages convinced me that oid indeed is that type I should use – mostly one from postgresql.com domain. Truth is that I didn’t understand why and how that oid type manages to store my byte array. But I’ve tried it, it stores it, it reads it, no exception is thrown.

Now I’ve finished second part of my investigation and the results are:

  • There is special Large Object facility in PostgreSQL and it’s based on using oid type that references actual large object stored in different table behind the scene.
  • JDBC documentation also mentions that you can use oid instead of bytea.
  • In that same chapter you can learn that bytea is supported since JDBC 7.2 version – that is not very long ago.
  • I don’t know if JPA/Hibernate can use bytea, but – honestly – I don’t care while this works fine. And it does.

So if you use PostgreSQL along with JPA and bytea type is throwing an exception, try oid. I’m not sure how well JDBC supports bytea, I don’t know why JPA wants to use oid and if other JPA providers (Toplink?) can use bytea. It’s not straightforward to use oid as a type for binary data – because you can learn this only in JDBC documentation and not in the mainstream PostgreSQL manual (I don’t count that chapter 31 because you’ll likely never use it while creating your tables). If you google this with along with “JPA” or “@Lob” your results might not lead you to proper articles quickly enough… so hopefully this post might help it a bit.

If you have some facts to add, feel free to comment.

Comments (10)