A blog about software development, primarily in Java and about web applications.

Thursday, June 9, 2011

Reverting commits with Subversion

This is actually fairly straightforward, but to do, but it came up again today at work so I thought I would document how to do it.

If you commit some changes that you want to revert immediately after the commit (before anyone else has done anything), you simply find the revision number you want to go back to and run:

$ svn merge --dry-run -rHEAD:86540 .

$ svn merge -rHEAD:86540 .

$ svn commit -m "revert to revision 86540" .


A few comments about this. You are changing your local working copy. In the above example, I'm assuming your local copy has been updated to the HEAD of your repository.

The first command is a dry-run and will show you the changes that will occur. I'm using HEAD as a shortcut, you could also specify a specific SVN revision number. Generally speaking, using HEAD is a bad idea, because HEAD is a moving target if you ware working with a team of people. So it's always best to use the specific revision number your local working copy is updated with.

The second command is the actual merge. Since the changes are being done to your local working copy, the commit is done to save your changes. You could alternately revert if something went awry.

Friday, November 5, 2010

Cleaning up log files on Unix/Linux

We run many different tomcat instances on a Unix box and need to keep the log files from getting to big and filling up our filesystem. Typically we have logging turned up high since we need the information for debugging.

Instead of using a cron job, we decide to create a Hudson job that periodically loops through the tomcat log directories and removes any old log files. Here's the shell command we periodically run:

/usr/bin/find /opt/*/*/logs/* -type f -mtime +2 | grep -v cruise | grep -v /opt/tools/confluence | xargs --no-run-if-empty rm -v

Note: /opt/tools/confluence is a sym link so we exclude it since it should already be cleaned up via it's real directory name. "cruise" is a directory that I don't want touched by this so I use grep -v to exclude it.

This is a development server so we don't need log files over 2 days old (not modified in over 2 days).  We also compress files that are over a day old to save space.  You can then use zgrep to grep through compressed files.  The compression is done with this shell command:

/usr/bin/find . -type f -mtime +1 | grep -v cruise | grep -v /opt/tools/confluence |xargs --no-run-if-empty /bin/gzip -v

Note 2:  I use "rm -v" and "gzip -v" so that the hudson console output includes verbose output about what was removed or compressed.

Wednesday, September 1, 2010

Confluence children and pagetree macros breaking

One of my side tasks is to provide some technical support for our Confluence wiki instance. We recently had a space stop working. The symptom was that the children and pagetree macros would never load. Because of this it made it impossible to view the space pages in tree view mode and move pages out of there to find the problem page.

The problem seems to have boiled down to a page somehow getting created without a page name. From Confluence's knowledge base: http://confluence.atlassian.com/display/CONFKB/Accessing+a+Space+via+Webdav+Returns+a+Blank+Page

Resolution

You need to identify the page title(s) that is null.

Run the following database query:

SELECT CONTENTID
FROM SPACES s, CONTENT c
WHERE s.SPACEID = c.SPACEID AND s.SPACEKEY = 'YourSpaceKey' AND c.CONTENTTYPE = 'PAGE' AND c.TITLE IS NULL;

Once identified, you can delete the page from the database or update it via these queries:

update content set title = 'title' where contentid = ;

Make sure that the titles are unique to the space.

Monday, August 16, 2010

Spring WAR configuration for Development, QA, and Production

Configuring applications with Spring

This is an excellent article on how to configure a Spring web application. The main point that I would like to echo is that it's important to have your build procedure create the same exact artifact for each of your environments and just externalize the configuration where necessary. This is a point often missed by developers and operations staff.

Wednesday, June 16, 2010

Tips on Evaluating UI Wireframes

I received this while working with a design firm, Rolling Orange. It's an excellent concise description of how to react to an initial set of wireframes. People often skimp on this step and that's a big problem that will come back to haunt you. This description makes that clear and more importantly gives people a guide to interpret and analyze the wireframes.

Elaboration Phase: Concept & Design: Wireframes

ABOUT THIS MILESTONE
This is the first draft of the wireframes for the new site. This represents our initial recommendations for navigation, functionality, and content, based on the findings of our Research and Strategy phase. The purpose of these wireframes is to create a site structure, functionality, and messaging platform that will serve as the foundation of your site. We will address visual design ("look and feel") only after we have approved wireframes.

WHAT SHOULD I EVALUATE?
- Look at this phase as an opportunity‚ now is the time to make it right.
- This draft is a starting point, so it's flexible and we expect it will evolve. Now is the time to suggest changes and explore new solutions.
- Does the architecture reflect the recommendations made in the Research & Strategy phase?
- Does the navigation and architecture address the functional needs of the audience per the Persona document?
- Is the proposed design "buildable" based on your understanding of supporting technologies and systems?
- Can your organization sufficiently manage and sustain the proposed design?
- Did we miss anything?

WHAT'S NEXT?
We will refine these wireframes based on your feedback.

PROJECT TIP
Think like your customer! Think about user goals and their frame of mind (“I’m researching, I’m applying, I’m managing”). Pretend you don’t know any of this—would you understand it as a first-time reader? Think simple—include just what users need and no more. If it’s “nice to have,” cut it.

Wednesday, June 9, 2010

TCP Window Scaling with Solaris and Linux

We've been having an annoying problem in which we can not insert large blobs to our Oracle 11g database. The solution was found by one of our security engineers. We needed to turn the tcp window scaling off. To temporarily test this out you can run this command as root:
bash-3.00# ndd -set /dev/tcp tcp_wscale_always 0

The original value for this tunable option was '1'. Interesting, running this command on the Linux (Oracle 11g) side had no effect. Running it on the Solaris (Tomcat Application Server) side solved the problem.

Fyi...to view the current setting of this property, you can run:
$ /usr/sbin/ndd -get /dev/tcp tcp_wscale_always

A value of 0 is off. A value of 1 is on. I'm able to run this command as myself. I don't need to be root.

Friday, March 19, 2010

Cygwin 1.7 Upgrade

I'm a big fan of Cygwin and have used it for years. Without it, it's possible for me to be productive on Windows. The latest version of Cygwin is 1.7. This version changed a few things for.

The first was one they warned about, how Cygwin stores mount points. These are no longer stored in the Windows registry, but are instead read from /etc/fstab. Cygwin comes with a script who's purpose appears to be to create this file for you, but when I ran it nothing happened. So I was left creating my own /etc/fstab. Here's what mine looks like:

C:/cygwin/bin /bin ntfs binary,user 0 0
C:/cygwin/etc /etc ntfs binary,user 0 0
C:/cygwin/home /home ntfs binary,user 0 0
C:/cygwin/var /var ntfs binary,user 0 0
C: /c ntfs binary,user 0 0
C:/Documents\040and\040Settings/don/Application\040Data /n ntfs binary,user 0 0
C:/Documents\040and\040Settings/don/My\040Documents /m ntfs binary,user 0 0
W: /w ntfs binary,user 0 0
Y: /y webdrive binary,user 0

The second issue I ran into was that I didn't have /bin or /usr/bin in my PATH. The previous versions of bash/cygwin did this for me. I actually had a line in my .profile commented out that would have done this. I simply put it back in and was good to go.

So far these are the only issues I've had with the upgrade and they were relatively easy to fix.