2008-12-08

Maven breaks binary resources

The fun thing is that after checking in the change the Bamboo build was also correct. My colleagues, who were still trying to resolve the font error, were quite amazed, as was I. For some reason Maven had messed up the files while filtering and copying. Quite bizarre if you think of the fact that the XSD file which caused my error didn’t have a keyword in it that should be substituted and the font file that caused the Bamboo error was binary…
I'd be plainer than that developer: Maven breaks your binary resources once you turn resource filtering on. I've spotted this twice: with an attached dll, and with a license file.

2008-12-06

Self-stabilizing protocol design

The number of processors and the sometimes noisy communication media in a distributed system impose the need for a fault tolerant design. One strong notion of fault tolerance is self-stabilization. Roughly speaking, a self-stabilizing protocol can cope with any kind of faults in the history. A distributed system is self-stabilizing if it can be started in any possible global state. Once started, the system runs for a while until it reaches a legitimate global state in which the system is consistent. The self-stabilization property makes the system tolerant to faults in which processors exhibit a faulty behavior for a while and then recover spontaneously in an arbitrary state. When the intermediate period between one recovery and the next faulty period is long enough, the system stabilizes.
(c) Shlomi Dolev, Amos Israeli, and Shlomo Moran; Uniform Dynamic Self-Stabilizing Leader Election

2008-12-02

Maven rake field

When you first experience Maven, it's like the cinematic cliché of two lovers running across a grassy field to embrace: It takes care of getting the right JARs for you, keeps test and build dependencies separate, and generates configuration artifacts for your favorite IDE, too. Even though it's XML, it's still a sweet five-minute user experience, but then you start stepping on the rakes in the grass.
<snip>
I do like where Matthieu is headed with raven or Russel Winder is headed with gant, but I'd really like the two together: non-XML syntax, dependency management, fully-stocked and up-to-date repositories, well-supported by continuous integration systems, and works with everything that Ant works with. Maybe gant plus the Maven2 Ant tasks or Ivy is the most silver-ish bullet for the time being, but seeing as I don't need to shoot any werewolves, Maven fits the bill for the moment

2008-12-01

Web Frameworks

jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development.
Lift is an expressive and elegant framework for writing web applications. Lift stresses the importance of security, maintainability, scalability and performance, while allowing for high levels of developer productivity. Lift open source software licensed under an Apache 2.0 license. Lift borrows from the best of existing frameworks, providing
  • Seaside's highly granular sessions and security
  • Rails fast flash-to-bang
  • Django's "more than just CRUD is included"
  • Wicket's designer-friendly templating style
And because Lift applications are written in Scala, an elegant new JVM language, you can still use your favorite Java libraries and deploy to your favorite Servlet Container. Use the code you've already written and deploy to the container you've already configured!
Spring Web MVC allows you to use any object as a command or form object - there is no need to implement a framework-specific interface or base class. Spring's data binding is highly flexible: for example, it treats type mismatches as validation errors that can be evaluated by the application, not as system errors. All this means that you don't need to duplicate your business objects' properties as simple, untyped strings in your form objects just to be able to handle invalid submissions, or to convert the Strings properly. Instead, it is often preferable to bind directly to your business objects.
Grails aims to bring the "coding by convention" paradigm to Groovy. It's an open-source web application framework that leverages the Groovy language and complements Java Web development. You can use Grails as a standalone development environment that hides all configuration details or integrate your Java business logic.
See also: appcelerator, thrift

Project build and dependency management tools

Gant is a tool for scripting Ant tasks using Groovy instead of XML to specify the logic. A Gant specification is a Groovy script and so can bring all the power of Groovy to bear directly, something not possible with Ant scripts. Whilst it might be seen as a competitor to Ant, Gant uses Ant tasks for many of the actions, so Gant is really an alternative way of doing things using Ant, but using a programming language rather than XML to specify the rules.
Ivy is a very powerful dependency manager oriented toward Java dependency management, even though it could be used to manage dependencies of any kind. Of course, Ivy is integrated with the most popular build management system for Java projects. But the integration goes way beyond common Ant integration. Indeed Ivy has been designed with Ant integration and design principles in mind. If you have Ant skills, you already have Ivy skills! The plugin mechanism in Ivy follows the same design as Ant, you will find macrodef and files import in Ivy configuration, many things Ant users are already familiar with.
Gradle is a build system which provides:
  • A very flexible general purpose build tool like Ant.
  • Switchable, build-by-convention frameworks a la Maven (for Java and Groovy projects). But we never lock you in!
  • Powerful support for multi-project builds.
  • Powerful dependency management (based on Apache Ivy).
  • Full support for your existing Maven or Ivy repository infrastructure.
  • Support for transitive dependency management without the need for remote repositories and pom.xml or ivy.xml files (optional).
  • Ant tasks as first class citizens.
  • Groovy build scripts.

2008-11-20

Garbage First

The new garbage collector that we're currently developing called Garbage First or G1 for short. G1 straddles the young generation - tenured generation boundary because it is a generational collector only in the logical sense. G1 divides the heap into regions and during a GC can collect a subset of the regions. It is logically generational because it dynamically selects a set of regions to act as a young generation which will then be collected at the next GC (as the young generation would be). G1 can choose the regions with the most garbage to collect first (Garbage First, get it?) so gets the biggest bang for the collection buck.
(c) Jon Masamitsu, Our Collectors
That G1 is now a part of JDK 7.

2008-11-04

Object emission matters

When we go looking at java performance, there are really 2 areas of the runtime that matter: the JIT and the GC. The job of the JIT is to make the code that is running execute as fast as possible. The GC is designed to take as little time away from the executing of code as possible (while still managing memory). Thus java performance is all about making the JIT generate more optimal code (more registers helps), and reducing the time the GC has to use to mange memory (bigger pointers makes this harder).

2008-10-30

caida.org

Wow again. Cooperative Association for Internet Data Analysis. Found lots of free internet topology data available. Network round trip times measurement and visualization, 65k nodes Some links:

svn mergeinfo

Wow. Now svn 1.5+ tracks which specific revisions were merged in, so some fraction of merging pain swould be relieved.
Mergeinfo, or more specifically the versioned property svn:mergeinfo, is the history of merges made into a given file or directory. This article gives a detailed look at mergeinfo; what it means and how it works. The svn:mergeinfo property value is simply a newline separated list of merge source paths (relative to the repository root), each source path is followed by a colon, and after the colon a list of revisions previously merged from that source.
As always, some gotchas burried here and there:
Note that unlike the familiar -rX:Y notation used by many Subversion subcommands, the version ranges in svn:mergeinfo use an A-B format in which the revision A is inclusive. In other words, if you merge -r3:7 expect to see mergeinfo with range 4-7.
(c) CollabNet Community, Subversion 1.5 Mergeinfo - Understanding the Internals

2008-10-06

maven repo magic

The same idea in another head means I am more or less correct: maven artifact caching is good, but not perfect. There're scenarios when it should be turned off.
you can pass -Dmaven.repo.local=..... That´s very usefull too, if you have a Continuous Build system running, where each build should work on its own "local repository".

2008-09-29

Indirection or abstraction?

A famous aphorism of Butler Lampson goes: All problems in computer science can be solved by another level of indirection; this is often deliberately mis-quoted with "abstraction" substituted for "indirection". Kevlin Henney's corollary to this is, "...except for the problem of too many layers of indirection."
Abstraction and indirection are very different yet cooperating concepts with two completely different purposes in software development. Abstraction is used to reduce complexity. Indirection is used to reduce coupling or dependence. The problem is that programmers frequently mix these up, using one for the other purpose and just generally screwing things up. By not knowing the difference between the two, and not knowing when to use one vs. the other or both, we end up with insanely convoluted systems with no real advantages.

2008-09-26

HP RAM extension

Here is the manual for RAM extension for HP Compaq nx9420. I'm now considering Linux (preferrably Suse as before) featuring VirtualBox running Windows and Mac OS for solid testing of the application we develop. This would obviously eat lots of RAM, but I know people are able to do Linux and virtualized Windows (some office apps mainly) using only 2 gigabytes, not 4 as I would like. Also it would be nice to swap on the memory of GPU (256 MB there), and use its (GPU's) processing power to boil some coffee. Anyway, KDE seemed more productive and convenient for me half a year ago when I was using it. The only problem was input language switching, but I would figure how to use my favorite Ctrl+Shift+number to switch that sooner rather than later. BTW, IntelliJ Idea (under Windows) still does not allow me to extract constant via Ctrl+Alt+C and Alt+R does not get to the Refactoring menu pulldown. Some kind of global shortcut override I guess?

2008-09-25

Limelight Networks :: Modern CDN

I don't believe this venture relies on sole hardware bandwidth, some academia needs to be involved. Looks like the infrastructure of this content delivery network does not rely on standard internet BGP routes for data replication among core peers.

2008-09-19

IO, NIO and Threading

Well, never thought about the issue, but apparently InputStream.read() is able to throw an instance of InterruptedException at its caller, while the interface states only the IOException. It's quite possible that I miss something, but anyway. Java NIO is a bit leaner in this regard as we have the ClosedByInterruptException.

2008-09-17

mock-testing and threads

Once again was badly burned on issues with moving code across threads. JMock reported failed tests as soon as some call made through the thread boundary. Apparently, we need ExecutorService injections and tinkering with our BaseWorker pattern to keep unit-testing effectiveness and maintainer sanity at the optimum. Those injections were discussed in great detail in the JMock Cookbook.

2008-09-10

Fast file digesting

Well, in case someone would ever try rock-solid digesting, here're my five cents on this matter:
Whirlpool is slow
Btw, the implemetation done by Paulo S.L.M. Barreto and Vincent Rijmen seems to be rarely used. There's no method to update with an array of bytes from a given offs position. Kinda ugly when you try to inject digesting amid a stack of Streams and/or ByteChannels.
I guess it's better to stick with CRC32, or something that very basic.

2008-08-31

Enterprise Foo

Really inspiring and quite realistic sample (from the Wikipedia Dependency Injection article).
EnterpriseFactoryObserverFactoryCreator efofc = new EnterpriseFactoryObserverFactoryCreator("bar"); efofc.creatify(); efofc.preparify(); efofc.configurise(); efofc.makeAwardWinning(); efofc.opportunities.leverage();

2008-08-28

The longest route

Not immediately obvious for me: 35 -> 10 -> 1 -> 17 -> 25 -> 14 (total 34) I have other sparse samples, but those seem to be human-intractable (and thus not that interesting). Rendered and laid out by Pajek.

2008-08-22

Standalone JConsole

Well, recently I had to tinker with JMX-enabled application, without installing the full JDK to bring up JConsole. So, I tried to continue stripping the JDK of irrelevant stuff while JConsole remains functional. So, here's what I ended up with:
jdk.root
  bin
    attach.dll // copied from jdk.root/jre/bin/attach.dll
    jconsole.exe
    jli.dll
    msvcr.dll
  lib
    jconsole.jar
    tools.jar
That worked fine for me. I've used JDK 1.6.0_05, the same JRE version was installed on PC's I was testing this on. DISCLAIMER: it's a dirty hack which is unsupported by the vendor and would apparently get broken for some other JDK/JRE version combinations.

2008-08-20

P-Grid and The Good Wine

Sometimes things turn upside down and lonesome middleware debugging session feels like... a good movie or some other kind of enjoyable free time. That's possibly because the time pressure is gone this week, and/or due to the wine I've opened couple of minutes ago. Went back to heal unbalanced splits in P-Grid protocol (one of most advanced distributed hash-table protocols I've seen to date).

2008-07-11

Pointer, setter and retriever

(17:50:53) dkorduban: были у программиста три собаки: пойнтер, сеттер и геттер
(17:51:22) akraievoy: гы
(17:51:56) akraievoy ...но не геттер, а ретривер :)
(17:52:09) dkorduban: =)

2008-07-06

The weight of the software

Whenever you build an airplane, you have to make sure that each part weighs no more than allocated by the designers, and you have to control where the weight it located to keep the center of gravity with limits. So there is an organization called Weights which tracks that. For the 747-100, one of the configuration items was the software for the navigation computer. In those days (mid-1960s), the concept of software was not widely understood. The weight of the software was 0. The Weights people didn't understand this so they sent a guy to the software group to understand this. The software people tried mightily to explain that the software was weightless, and the Weights guy eventually went away, dubious. Thtn the Weights guy comes back, a few days later, with a box of punch cards (if you don't know what a punch card is, e-mail me and I will explain). The box weighed about 15 pounds. The weights guy said "This box contains software". The software guys inspected the cards and it was, in fact, a computer program. "See?", the Weights guy said, "This box weighs about 15 pounds". "You don't understand", the software guys responded, "The software is in the holes"...

2008-06-30

Decent pool worker thread loop

UPD as of April 2011. The code below is of course more or less okay, but Google's Guava has nice AbstractExecutionThreadService and couple of even more nicely elaborated worker primitives. I guess we don't need to implement that stuff by hand anymore...

    public void run() {
       boolean interrupted = false;
       
       while (!interrupted && !Thread.currentThread().isInterrupted()) {
           try {
               runInternal(); //  do your stuff here
           } catch (Throwable t) {
               //  recommended to use your favorite logging system to complain
               interrupted |= t instanceof InterruptedException;   //  recommended to unwrap to root cause here
           }
       }
   }

2008-06-25

2008-06-24

Why no backporting from 1.5 to 1.4

Unfortunately -source 1.5 does use minor enhancements to the libraries and class files. for-each loops use java.lang.Iterable. generics uses Signature attributes, Bridge attributes, and new flags on the class files. Boxing/unboxing uses new static factories on the wrapper classes. In order to support these on -source 1.4 we would need a separate but incompatible specification for how these features are supposed to work on 1.4. Moreover, this mode of the compiler would violate the JCK run rules, which state that each available mode of a Java compiler must comply with some platform specification.

2008-06-23

Kernel swear counts

275 credited kernel authors wrote over 1,895,964 lines of code and documentation (6,856,723 words) and only managed to cuss 29 times -- it would seem that these developers show incredible self restraint when expressing frustration, are complete professionals, are sedated, or are just enjoying what they do!
UPD: more up-to-date info here

2008-06-19

IntelliJ revisited

That's the first day I've morphed IntelliJ Idea module from java to web kind via manual xml editing. Nothing really special, but helped to avoid retyping all the library paths out there. XML is not that unhuman (for a programmer), but IMO JSON is better (untill you need to defend your API with namespaces, schemas and a learning curve).

2008-06-14

Echo of release of our integrated product

"File transfer reliability and performance is critical in a global workflow context. BLUE's new hi-res file transfer capabilities can be utilized in the most challenging environments, helping companies improve the quality of files and their speed to market," noted Bradford.

2008-05-29

Erasure...

I suspect one of the predominant stumbling blocks in Java Generics will be the fact that you must always remind yourself "Oh, yeah, it only seems like we know something about the type parameter. That information has actually been erased." So here, you mean T[] array = new T[sz];, but erasure forgets about T so that's not legal. To solve the problem, you create an array of objects and cast it.
Stumbled on this while reviving two-year old code of mine, which was pretty 1.3-based. The code has not rotten all over and seems to be quite understandable. Let's do some generics to mess things up. ;)