mardi 8 mai 2012

Software Industrialization presentation

Few days ago I had to make a presentation about the software industrialization approaches at Octetis (the international IT company for whom I'm currently working).

The result is here - one page PDF document:


The one thing to share is about very beautiful and complete Project Gallery from MS Word for Mac.

All styles, fonts, document structure, etc. were available out of the box. All the other stuff was created using PowerPoint for Mac as well.

Merci Microsoft & Apple.

jeudi 9 février 2012

Maven BuildNumber plugin - short revision id for Git

Today, I would like to explain the improvement for maven plugin - buildNumber, that I talked in my previous message - short revision id for Git SCM.

IMPORTANT : This feature is present in the maven-buildnumber-plugin 1.1 version.

You can specify the length for the Git revision. To enable this feature you have to specify the new tag
<shortRevisionLength>
in the
<configuration>
section. For exemple:

The associated maven output informs us about the detection of shortRevisionLength tag and print the length of the revision that will be used in buildNumber formatting:


Some implementation details

This feature uses internally the git rev-pasre --short (see associated git help section) command and the revision length is set to minimum 4 characters. So you can't have the revision id shorter then 4 characters. Even if you specify the length between 0 and 4, the plugin will inform you about this situation and the minimum value (4) will be used.

UPDATED: If your maven build can't find the dependency for maven-buildnumber-plugin 1.1 , try to force the dependency update  by adding option "-U" for your mvn command.

mercredi 8 février 2012

My first Open Source commitment - Git short revision

Today, my patches for 2 maven projects have been accepted by the maven-buildNumber-plugin's project lead Olivier Lamy.

One of the web Java project, I currently working on, is fully automated with Maven. One interesting and useful thing is to have the date & the revision number at the bottom of the web page. Like this:
It was done with excellent maven plugin buildNumber - http://mojo.codehaus.org/buildnumber-maven-plugin

The problem was that the project SCM migrated from the SVN to Git. And the revision ID in Git is too long. In fact it's SHA-1 sequence that should be unique across the world and all possible revisions... So the build id at the bottom of the page was so ugly for business users that I receive the task to make it shorter.

After asking the question about the git short revision id in StackOverflow.com and in the user's mailing lists of the maven, I understood that the buildNumber plugin does not support this feature. And the project Lead, Olivier Lamy, gracefully proposed to me to make a patch and pointed out the first java class I have to look at.
The code he sent me was very clear and I quickly figured out how to add the new feature that I called shortRevisionLength.
After one day of working I have sent the patch to Olivier and created 2 issues on the codehouse JIRA server:
  1. http://jira.codehaus.org/browse/MBUILDNUM-86
  2. http://jira.codehaus.org/browse/SCM-664
I added some test cases and the documentation patch as well.

The next day the patch has been approved and integrated in the SVN. So, the next version of buildNumber plugin 1.1 contains some peace of code from Ukraine :) Nice.

jeudi 12 janvier 2012

Install Pear on Windows 7

Just a little tips about installing PEAR for PHP on Windows 7.

I have spent 3 hours today to install PEAR on Windows. I had systematically the error, when I was trying to execute config-set auto_discover 1 in the CMD:
PEAR_Config::writeConfigFile fopen('C:/Windows/pear.ini', 'w') failed... permission denied

It was clear that the problem in the PEAR installation - the location of pear.ini file was wrong. It's important to note, that all installation and manipulation with pear I made with basic CMD.

If you have the same problems, you have to reinstall your PEAR with PowerShell.
With PowerShell the pear.ini is in the PHP folder and it will fixe all the problems

lundi 26 décembre 2011

Free MySQL backup with Dropbox

Recently, I've been working on creating an automatic service for backing up our RedmineMySQL database on the Debian server.

So I've decide to share there how I made a free backup service for the MySQL database.

I set several goals that should be attempted in order to consider that backup service is useful

  1. Only free & open source applications.
  2. Remote disk storage also for free.
  3. Backup must be automatic.
  4. Backup encryption.
To accomplish these requirements finally I have selected the next tools:
  1. AutoMysqlBackup - http://sourceforge.net/projects/automysqlbackup - the core of theservice.
  2. DropBox free account (2 Gb for free) - www.dropbox.com
  3. crontab - a standard Linux job automation tool
  4. openssl - for encryptionHow does this it works together.A little description.
First of all you will be need a DropBox account - there your MySQL backups will arrive and willbe stored. You have to download the DropBox client application or a DropBox daemon. I suggest you to use a dropboxd (daemon) for the server use:

https://www.dropbox.com/install?os=lnx - install DropBox as a daemon

Downlaod & install AutoMysqlBackup tool. After the installation you have to modify the script /etc/automysqlbackup/automysqlbackup.conf

You should uncomment the line you need band put the appropriate values. Each line in this script is well documented and you will find all the options you need. Just a brief description of what can you configure with it : mysql server address, mysql credentials for the command mysqldump, location where the dump will be stored, the regularity of the backuping, etc.

Next step, is creating your own bash script that will be called by cron, make a backup with autoMysqlBackup, copy the backup files into the local dropBox folder.

Download my example : http://dl.dropbox.com/u/3839545/backup.sh

Make sure that your own backup.sh is runnable (don't forget chmod u+x backup.sh)

The next step is to configure your crontab. In the crontab I've defined the period of time the script backup.sh will be called. I set up the backup everyday at 3:00 AM.
Make sure you have the root privileges and run the following command :
crontab -e
and at the end of the file add the line :
00 03 * * * /root/backup.sh

And the last step is about the encryption. The openSSL encryption is made by the AutoMysqlBackup, for this you have to uncomment in your /etc/automysqlbackup/automysqlbackup.conf the following line:
CONFIG_encrypt='yes'
don't forget to set the password to encrypt!

That's all, make a test that prove that your backup is working fine before moving all this stuff in the production environment.

mercredi 25 mai 2011

Git killer features

After 3 weeks of working with Git (the DCVS written by Linus Torwalds), I definitely can say that it is a great technology.

If you are asking yourself what you need to learn right now? What is the next major revolution in the IT world? Maybe, the answer will be Git.


What are the killer features of Git for me:
  • Distributed – I can develop normally even without Internet and access to the central repository. It’s a great feature to make small and concise commits while developing at home, during the weekend.
  • Rich history revision mechanism – the search within the log-history is wonderful. With
    git log –sSecurityManager
    I can find, for example, all commits that introduce or remove the SecurityManager class. Attention, the search is performed on the source code and not on the commit log. It’s a best tool for making the code live analysis.
  • Git bisect – automatically find a failing commit using the binary search and a set of unit tests. If you don’t use the CI server (shame on you :)), you can nevertheless quickly find a bad commit. Git bisect command will run the tests against the project snapshots. Each snapshot is associated with a particular commit. I did not try to use this command yet. But, the concept is great.
  • CMD – git is a command line based tool. You can script the commands, make aliasing etc. CMD speed up your productivity. Of course, for making the merge it’s not so trivial, but the guys from Eclipse will soon release a completely functional version of the plugin eGit.
  • git cherry-pick - reintegate an existing commit to the current branch. How many times you have forgot to switch to the correct branch before making a commit? I have been confronted with this painfull mistake quite often. Now you don't have to report your commit manually to the correct branch. The magic cherry-pick command will make it four you!

I have worked with git on Windows and Mac. Git for Mac is a stable and I have not noticed any problem. It is not the case for Windows...

Git remote tags problems

For running Git on Windows box, you have to install msysgit (I used 1.7.4.msysgit.0). The one problem I encountered with msysgit, it was that I could not push my tag to the remote repo. The command
git push --tags origin master
did not create a tag remotely. The same command executed on Mac did the job correctly
.

Git - pdf book about git

I can recommend to download a free PDF book "Git Community Book" about git from http://book.git-scm.com

As long as I learning Git, as more I understand its powerfull.

mardi 3 mai 2011

Tools : free screenshot capture

The tool of the day is gadwin printScreen (only for Windows users).

A really powerful and free screenshot capture tool that I used on my Windows box.

You can download it here

Log4j : Customize LoggingEvent for SMTPAppender

Hi,

Recently I was confronted to the need of customizing the log4j message generation. When an exception occurs, the application should sent the email to the development team in the following format:


The error message should be enclosed by the corporation information represented by the header and footer. The problem is the application URL (marked by the red ellipse). This URL can be different depending on the environment where the application is running and throwing the exception. In the complex, industrial projects where exist many environments, this can be very helpful to determine which environment has a problem.

First of all, how set the footer and header? It’s quite simple, you have to use org.apache.log4j.EnhancedPatternLayout, in the parameter ConversionPattern, you put the header, footer and the message error with some additional information (date, class name which generated the exception, etc). The standard log4j distribution(log4j.jar file) does not contain the class EnhancedPatternLayout, you have to download the additional extras companion (here)

Pay particular attention to do not use org.apache.log4j.PatternLayout which contains some issues with synchronization (see the first paragraphe of the associated JavaDoc). PatternLayout class is still widely used and all exemples on Internet use it, but for make your code robust you don’t have to use it.




And what about the environment dependent URL ? How can I put the http://myapp.production.com or http://myapp.integration-test.com in the log message? I found 2 solutions:
  1. Use ant or maven to replace a specific symbol in your log4j.xml (log4j.properties) when you are building the app. You can use filter resource maven plugin fot that. But is not the most elegant solution, because you will have a strong dependency with the build tool. For production system, it is not a choice.
  2. Use org.apache.log4j.EnhancedPatternLayout and %properties{key} mechanism
So first of all, you have to customize the SMTPAppender in order to put the specific information into the each message that will be sent. For that you have to subclass SMTPAppender and override the method append. Take a look on my test implementation:

The code is self documented. I put the URL to prod environment behind the key named "app".I hardcoded the value in order to make the explanation simpler. But in your production code you may get the correposnding value from properties file, from environment variable or from the database.

Next, the key “app” in the event property becomes available for Log4J runtime. You may see how I use it in my log4j.xml file (the 2nd screenshot).

The setProperty method is an extension point and the excellent example of a good designed API.


Updated : actually, there is a simpler method to inject the environment name into the log4j logging message - simply, change the ConversionPattern for each log4.propeperties file.

dimanche 17 avril 2011

JavaOne 2011 in Moscow. Review.

La semaine dernière j’étais en Russie, à Moscou, à la conférence JavaOne organisé par Oracle.

J’ai eu deux jours du plaisir technique. Entouré par les gens passionnés par la technique, j’ai pris une bonne dose de motivation.

La conférence se déroulait au centre de Moscou, au bâtiment épique de l’académie de science de la fédération russe (Российская Академия Наук - РАН) connu aussi sous le nom « Les Cerveaux » :)

Quelques points/événements clés que j’ai retenus à l’issue de la conférence sont présentés ci-dessous suivis de photos de ma collection.

Les nouveautés dans Java 7 présenté par une personne charismatique - Danny COWARD: join/fork mécanisme pour les traitements parallèles (map-reduce) ; le sucre syntaxique avec l’opérateur « Diamond » (<>) qui va faciliter la lecture du code qui utilise les génériques; le support de String dans l’opérateur switch ; les clauses catch avec la possibilité de préciser multiples exceptions.

Les standard Java EE 6 : avec l’API Servlet 3.0 (les appels asynchrones, configuration avec les annotations, le fichier web.xml est optionnel, l’utilisation du fichier web-fragment.xml pour les composants auto-configurable dans le contaneur, etc.), le support native de getsion de dépendence (DI) avec l’arrivé de la notation @Inject.


La présentation de Vladimir IVANOV (Oracle, Saint-Petersburg) sur la diagnostique et tuning du GC. J’ai noté un outil visualvm pour le profiling de performance des applications Java. Après la présentation, j’ai parlé avec cet ingénieur d’Oracle sur l’utilisation de Soft, Weak et Phantom références dans Java.

Une petite salle de repos pour les geeks :)

Et bien sûr, La Place Rouge avec le Kreml’.

Pour conclure, Oracle est motivé pour supporter le monde Java. L’organisation de la conférence est excellente, rien à reprocher. Merci Oracle pour ce JavaOne 2011.