Houston we have a failure!

No Comments

I was working on my trusty and crusty (15 year old!) desktop Pyg which just got a recent Manjaro reinstall, when suddenly the LVM partitions disappeared. The only clue I had is that the 3 directories that I use to access the logical volumes started throwing Input/Output error. I rebooted and it went straight to the recovery console (which is not a good place to be). I tried manually mounting the LVM partitions and it gave this error:

This was a bit of a shock and no reboot or safe mode can restore the directories. I put it off for the night and took it up again today. I was thinking maybe it was a recent Manjaro system in-place upgrade so I tried booting to the latest Ubuntu livecd (using Ventoy, which is very good for creating a multi-system bootable drive) hoping it will show up my lost LVM partitions.

I booted up to the Ubuntu live desktop and I didnt see any LVM mapper entries either. I see the same 800++GB unallocated space at the tail end of the SSD. I launched a filesystem check which didn’t reveal anything and started searching on how to manually input the the LVM sectors in the GPT metadata.

I searched my Google keep for Pyg’s partition layout and then it hit me that all I am seeing is the SSD. There is a WD Blue mechanical drive in this machine before I upgraded to SSD and I used that for storage for files before they are backed up to either DVD or BlueRay. I checked the BIOS of the desktop and it confimred that the HDD is not showing up. Opening up Pyg seems to be my next weekend project.

Curiously enough, I am not feeling as much worry on losing the files as I remember the first time that my WD Green drive malfunctioned. Maybe those files in the LVM partitions (warehouse [files], limbo [multimedia] and arena [game files[) are really not worth that much in the grand scheme of things. If I can still recover them then thats fine but if not then…

Docker image cleanup

No Comments

Running docker frequently can lead to mysteriously disappearing space. I kid, its not mysterious. Each image builds a layer which in turn eats up space. Logical but PITA!

Put this in your .bashrc or run it as cron on your docker host to clean up.


docker rm -v $(docker ps -a -q -f status=exited)
docker rmi $(docker images -f “dangling=true” -q)

or do it in one alias (use at your own discretion)


alias docker_janitor='docker rm -v $(docker ps -a -q -f status=exited);docker rmi $(docker images -f “dangling=true” -q)'

sounds too easy..

ciao!

Running RTC as a Windows service

No Comments

I need to run the Rational Team Concert Jazz Build Engine as a Windows service as we need it to run non-stop as part of the continuous integration service. The catches though are

  • it (theoretically) wouldn’t stop as it keeps on waiting for build requests from the RTC server. This makes it as an unlikely candidate for scheduled tasks unless I will cookup a script for terminating it before the actual run. Messy if I still have to check if there is a build in progress.
  • the machine hosting it is not a dedicated machine so a couple of admins usually login to do some stuff which kills any running processes executed by the currently logged-in user.

Windows provides the sc.exe utility for creating and removing Windows services but it only accepts executables and not scripts. I have to set some environment properties and parameters so this is out of the running. The Java Service Wrapper is a good alternative but I misread the instructions so ended up using the AutoExnt utility in the Win2003 Resourse Kit. The files are still usable in Windows XP.

Only three files are needed from the kit namely Autoexnt.exe, instexnt.exe and servmess.dll. These files are to be dropped in the %SYSTEMROOT%\system32 directory.. The next step is to create the %SYSTEMROOT%\system32\autoexnt.bat (the file needs to be named like that) with the commands to be executed. My script looked something like this:


@echo off
setlocal
REM
REM Workstation specific settings.
REM
set JBE_Eclipse_Dir=C:\Apps\IBM\jazz\buildsystem\buildengine\eclipse
set JBE_Repository_URL=https:///jazz
set JBE_EngineID=ToolingBuilder
set JBE_user=kerberos
set JBE_password=

REM
REM If proxy is not needed, switch the JBE_VMArgs_OPTS to use the empty one
REM
set proxyHost=
set proxyPort=3128

set JBE_VMArgs_OPTS=-vmargs -DhttpsproxyHost=%proxyHost% -Dhttps.proxyPort=%proxyPort%
REM set JBE_VMArgs_OPTS=

REM
REM Set the JVM to use to the IBM J9 VM otherwise the compilation will fail.
REM
set java_home=C:\Apps\IBM\SDP70\jdk
set classpath=.;%java_home%\lib
set path=%java_home%\bin;%path%

REM
REM Invoke the Jazz Build Engine client.
REM
pushd %JBE_Eclipse_Dir%
jbe.exe -repository %JBE_Repository_URL% -userId %JBE_user -pass %JBE_password% -engineId %JBE_EngineID% -sleeptime 1 %JBE_VMArgs_OPTS%

endlocal

The next step is invoking the command instexnt install to install the service. The only final thing to do is to go inside the Services console of Windows and reconfigure the AutoExNT service to start automatically at boot up. Of course, it needs to be started as well if you want to use the service immediately. 🙂

There are a few more help in the Windos 2003 Resource Kit help but the only thing of interest is using instexnt install /interactive to install the service. This will cause the service to pop out a command window wherein the user can view the console output. The downside is that the user can close the window which will terminate the service.

I have thought about migrating the system to use the Java Service Wrapper but using the AutoExNT separates the service component which allows JBE implementors to replace/delete the JBE installation directory without going through the setup process again.

[edit 20081002] Dom Weinand posted this link in the RTC user forum on how to use the Java Service Launcher to run JBE as a Windows service[/edit]

ciao!

LLTHW: Importing Eclipse projects

No Comments

I thought I was starting a new acronym but it seems NetHack has already first dibs on Lessons Learned The Hard Way. 😀 Anyway, any posts that I tag with this acronym should be self-explanatory. 😀

One of the training machines we are using is encountering a weird error because the user could not launch the plugin project for debugging. To make the matters worse, the error message just contains an empty string. The other machines does not seem to exhibit the problem.

After an hour of trial and error, we finally figured out the problem. Eclipse does not like importing projects that are placed in the C:\ (or root drive). The solution was to place the project code base in a intermediary directory (C:\Something) and then proceed with importing it in the workspace.

I do not know the rational explanation for this one and my initial google searches does not reveal anything that is remotely related. I will just chalk this one as a lesson learned the hard way.

ciao!

One liner: get the last field

No Comments

Problem: I need to get a list of all java libraries in our repository so I can create a matrix of when they are being used and what is type of license they are using. I tried using a pure Windows approach but it is taking too much time so I used Cygwin instead. Getting all JAR files is easy with find but I am having difficulty brewing the correct regexp syntax so why prolong the agony and not switch to another tool instead: awk!

find . -name *.jar | awk -F/ ´{$NF}' | sort | uniq

where:

– find searches recursively from the current directly for all files that end with ‘.jar’
– all resulting file paths are piped to awk which, using the forward slash as the column delimiter, prints out the last column
– and finally the list of JAR files are sorted alphabetically and duplicates are removed.

This could probably be done in a whole lot of ways (perl, python, sed, etc.) but the beauty of FLOSS is we can use whatever we can to get the same result. 😀

ciao!

Blog migration completed

4 Comments

The migration of the pertinent posting and comments have been completed from the blogsome account. It may look like most of the comments were made by a single man but that is one of the drawbacks of manual migration. 🙂

The xml-rpc page of this site does not seem to work as well as the feeds section but that is something to do in the future.

ciao!

Some Java and MySQL Connector/J tips

No Comments

Ok, I and others have been bitten by some of these oversights so I hope it will be of some use to some:

1. Dont use the jar file ending with -g. That will require the aspectj libraries which is a paradigm for simplifying inclusion of boiler plate code (e.G. Debugging, etc.). Use the other one.

2. At least in the development phase: DO NOT WANTONLY OVERRIDE EXCEPTION MESSAGES AND STACKTRACES. They may seem ugly but they have their purposes. Handle the exceptions but output the error somewhere to help you debug. You can remove the debugging statement later.

As an added tip, use a unique word to tag statements that you will remove later (e.g. prepending System.out.println messages with “[REMOVE]”) to facilitate search and remove later on. Or use the task feature of Eclipse if you are using it (i.e. start a comment with “//TODO” and it will appear in the task list) .

3. Use PreparedStatement calls whenever possible. However, DO NOT USE them when executing SQL INSERT statements with embedded SELECT statements. Construct your SQL statement via plain-jane string manipulation and execute them with Statement objects.

When constructing SQL statements for PreparedStatement objects, escaping strings that will be dynamically specified are not required. Just make sure that the question marks have spaces before and after.

4. The latest MySQL Connector/J drivers require JRE 1.4.x. Aside from that, aim for the lowest JDK possible to ensure maximum compatiblity. Java Runtime Environments are usually backward-compatible.

5. Modularize your code. This way you can do unit tests on your methods before integrating them to the main code structure.

6. Maximize comments. Make sure you create comments for all methods (no matter what the scope is) to describe what it needs to do. It is also good to create multi-line comments on how you would proceed in the body of the method. It gives focus on what you need to do and what will come after it.

I’ll just post additional ones as I encounter them.

ciao!

Burned by subtlety: DOM4J vs W3C DOM (Xerces/Xalan)

No Comments

I was tasked to switch a utility from using the DOM4J API to the W3C DOM API because the DOM4J implementation is transforming Scandinavian characters into garbage wihle the XMLSerializer class in Xerces does it without any sweat.

Sounds relatively easy? Not when you are inexperienced in XML programming, Java or otherwise, as well as in XSL and its likes. Another factor is that the code was deeply embedded in the DOM4J API and not all have a corresponding functionality in the target implementation.

Pass forward to 12 working days later, I have almost completed the porting process but the final output has some element starting markups (‘< ', '>‘) escaped. I searched high and low for an answer as well as played with output format options of the Transformer class but to no avail.

Then Francis helped me understand a little bit of XSL, at least he pointed me to where I should start. One man-day and a few online XSL tutorials later, I found out this link that describes my issues perfectly. It seems the interpretation of the contents of the CDATA section is parser-specific. Where was that link two days ago before I started tearing my hair apart? Grrr…

Lesson of the Day: Google might be your friend, but like any friend it can play a nasty and costly trick on you.

Onward to transforming the CDATA texts into xsl:text elements with output escaping disabled and hopefully complete this task today. I will play the good colleague role and put out a note on each stylesheet so the next person who messes with the parsers wont go through the same grief as me.

ciao!