Big Data/Analytics Zone is brought to you in partnership with:

I have been working for almost two years now on infrastructure and deployment automation, exploring programmatic solutions to traditional systems administration problems and configuration management. I'm fanatical about testing, the scientific method and building good tools to support awesome   Oliver is a DZone MVB and is not an employee of DZone and has posted 29 posts at DZone. You can read more from them at their website. View Full User Profile

Hadoop, Pig, and Broken Dreams of Environment Variables

09.12.2012
| 4261 views |
  • submit to reddit
Okay, this post isn't nearly as melodramatic as its title – I’m doing some log analysis with Hadoop and Pig. As the logs are coming from a webserver and are not that far from standard “combined” format, it is most logical to use the time-saving UDFs in Pig’s Piggybank. This is just a set of user-contributed code, but very useful.

Unfortunately there doesn’t seem to be a Debian package for it, at least not in the set of repositories I have available to me on this machine so I thought I’d just compile it – it is dynamically loadable from an arbitrary path in a Pig script so this is not a big issue. The process is two-fold:

  1. Compile Pig itself (or locate the pig-withouthadoop.jar pre-compiled on your system)
  2. Compile Piggybank against that version of Pig

Pig uses the Ant build system, and it really is as trivial as running ant from the top-level directory. I checked out the tagged release of 0.10.0 and successfully built Pig. Building Piggybank against it, however, errored out with something I wasn’t immediately able to find on the interwebs:

$ ant
Buildfile: /home/oliver/release-0.10.0/contrib/piggybank/java/build.xml

init:
    [mkdir] Created dir: /home/oliver/release-0.10.0/contrib/piggybank/java/build
    [mkdir] Created dir: /home/oliver/release-0.10.0/contrib/piggybank/java/build/classes
    [mkdir] Created dir: /home/oliver/release-0.10.0/contrib/piggybank/java/build/test
    [mkdir] Created dir: /home/oliver/release-0.10.0/contrib/piggybank/java/build/test/classes
    [mkdir] Created dir: /home/oliver/release-0.10.0/contrib/piggybank/java/build/docs/api

compile:
     [echo]  *** Compiling Pig UDFs ***
    [javac] /home/oliver/release-0.10.0/contrib/piggybank/java/build.xml:92: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
    [javac] Compiling 154 source files to /home/oliver/release-0.10.0/contrib/piggybank/java/build/classes
    [javac] error: error reading /home/oliver/release-0.10.0/pig-withouthadoop.jar; invalid header field
    [javac] 1 error

BUILD FAILED
/home/oliver/release-0.10.0/contrib/piggybank/java/build.xml:92: Compile failed; see the compiler error output for details.

Total time: 0 seconds

Now, I’m not a Java guy so this means very little to me. However I do at least know that a Jar file is simply a zip archive so I went digging. Assuming that the ‘invalid header field’ is in the metadata of the Jar file, I looked in the contained META-INF/MANIFEST.MF:

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.0
Created-By: 1.6.0_26-b03 (Sun Microsystems Inc.)
Main-Class: org.apache.pig.Main

Name: org/apache/pig
Implementation-Vendor: Apache
Implementation-Title: Pig
Implementation-Version: 0.10.0-SNAPSHOT
Build-TimeStamp: Sep 12 2012, 08:14:45
Svn-Revision: svnversion: warning: cannot set LC_CTYPE locale
svnversi
 on: warning: environment variable LC_CTYPE is UTF-8
svnversion: warni
 ng: please check that your locale name is correct
1383830

It seems that some locale settings in the environment are causing issues with the svnversion program, and indeed when running it separately I can confirm the same issue:

~/release-0.10.0$ svnversion
svnversion: warning: cannot set LC_CTYPE locale
svnversion: warning: environment variable LC_CTYPE is UTF-8
svnversion: warning: please check that your locale name is correct
1383830

I’ve been seeing this on a bunch of machines I’ve been using recently but frankly I haven’t had the time to diagnose it. It is easily worked around with unset LC_CTYPE:

~/release-0.10.0$ unset LC_CTYPE
~/release-0.10.0$ svnversion
1383830

There's some contention around adding superfluous metadata fields in Ant builds, but again, this is something I don’t particularly care to dive into at the moment. An acceptable alternative workaround in this case would have been to remove the additional metadata generation in the Ant build.xml.

Rebuilding Pig now and Piggybank against it works. Huzzah! On to the next problem.
Published at DZone with permission of Oliver Hookins, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)