October 29, 2010
by Richard
So it turns out I lied in my blog post a few hours ago. I just can’t stay away from a good programming problem. I thought about all the possible options and decided to go with my gut response, a SIMON spike.
And boy am I glad I did.
As I wrote in the comment when I committed the spike, you know you’re doing something right when you switch client-server communication frameworks and barely have to change any code to do it. Refitting the code from the Cajo spike was trivial and only took about 15 minutes.
The results? Fabulous.
As promised on the SIMON wiki, firewalls were no trouble at all. I was able to run the file upload tests with no problems and verify that everything comes out on the other side the same way it went in, despite having different processor architectures and different operating systems in play. Performance was a little on the slow side, but we can always optimize later. Right now, I’m just glad to have something that actually works.
Truth be told, I like SIMON better than Cajo for more than just the fact that it eats firewalls for breakfast, lunch, and dinner. It also has, in some respects, much better semantics. For instance, with Cajo, I had to explicitly create a proxy object to pass to the server when I wanted to have callbacks to the client, like so:
ISubmissionSystem ss = (ISubmissionSystem) submissionClient.proxy(refs[0], ISubmissionSystem.class);
…
ISubmissionCallback sc = (ISubmissionCallback) Cajo.proxy(new SubmissionCallback());
ss.testCallback(sc);
Not horribly ugly, but not exactly pretty either. With SIMON, I don’t have to do that. I just mark the classes that should be remoted with the appropriate annotation and SIMON handles the rest. This code accomplishes the same thing as the Cajo code above:
ISubmissionSystem ss = (ISubmissionSystem) serverLookup.lookup(“submitSys”);
…
ss.testCallback(new SubmissionCallback());
The one place that I consider to be a little weaker semantically under SIMON is the lookup mechanism. Cajo had the right idea there, in my opinion, by doing lookups using the target interface’s method signatures. SIMON uses names instead. Not a huge problem, but it is a slight drawback.
Of course, there is also still that niggling legal issue. As mentioned, SIMON is licensed under the GPL. Personally, I don’t much care whether our code is licensed under the GPL or the EPL or any other license, but Professor Pollice might. Something to ask about when we meet on Monday. If GPL is a problem, then I’ll have to go back to the drawing board. Alternatively, I suppose there’s a slim chance the author might agree to grant us a free commercial license, which would allow us to license our code however we please, but I wouldn’t bank on it.
The one other outstanding issue is that I haven’t finished examining failure cases yet. I know that if the server fails, the client throws lots of big red exceptions. I know that if the client fails, the server is silent, much as it was with Cajo. At some point, probably over the weekend, I’ll bust out JConsole again to see what’s happening under the hood. If the thread doesn’t go away, though, I don’t think that’s a problem. SIMON has a thread pooling mechanism where the same thread can be reused and can even handle multiple connections at once. I’m not sure what the default settings are though.
Anyway, it’s 2AM and I’m calling it quits for the night morning. Expect to see more on this over the next few days.
(Vaguely related addendum: the fact that we’re using t1k1 and t1k2 is really starting to bug the crap out of me. I installed Eclipse on t1k1 so I could run the spikes, and the latest version available under the Package Manager is Ganymede! So I downloaded Helios for SPARC/Solaris from Eclipse.org and tried that. It runs, but it crashes at the drop of a hat, so it’s basically unusable.)