App inventor first fiddlings

I’m finally getting a chance to try out App Inventor.

The first thing I found is that Java applets and jnlp seem to crash firefox on Fedora 13. That’s a shame. But the Chrome browser seems to do better, so I proceeded forward with that. Also, it looks like Google heard my complaint and, in addition to a .deb package, now provides a simple tarball for non-deb Linux users (that wasn’t so hard, was it?).

The first thing that comes up when you visit the site and have access is some kind of UI builder thing. Among the first things I noticed about this is that it only has LinearLayout and TableLayout. I guess that’s for the sake of simplicity, but… no RelativeLayout? It’s not obvious how to use everything that’s there, or how to hook anything up to actions. Things became more interesting when I discovered the “Blocks Editor”.

BTW, was there some kind of manual to read? I don’t remember seeing one, but I probably breezed by it. Ah yes – I started there and headed down the installation rabbit trail. Back to the intro; it brings up both the Designer (that’s the first thingy) and the Blocks Editor right away. So there it is.

Of course I quickly built a layout with a text editor and button and deployed it to my phone (emulator, actually) right off to see it in action. That worked. However later on when I was working on a regular app in Eclipse and tried to deploy it, that seemed to fail. The log was full of errors I’m not used to – something about not matching a certificate. Did app inventor’s tooling ruin my emulator for other development? Good to find out before I try it on my actual phone.

So, I just tried the first tutorial. It’s fairly cool that while you’re building your app in the tool, it’s being updated at the same time on the phone. Obviously, there’s an app inventor component running on the phone to make that happen. When you’re done building it, you can package it as a standalone app. While I was waiting for that to finish, I brought up adb logcat to see what was going on. It said that the adb server was “out of date” and restarted it – this apparently cut app inventor’s connection. I don’t know if this is specific to Linux or even my system, but it doesn’t seem like you can use it in parallel with the other SDK tools. Then again, logcat didn’t get cut off when I reconnected app inventor.

As I read initially, there doesn’t seem to be any ability to create multiple screens. But there’s a “canvas” block that looks promising for achieving a multi-screen effect.

When I went to add some contacts for the second tutorial, the act of leaving the app inventor setup evidently triggered the “server is out of date” problem again. I wasn’t able to reconnect app inventor to the emulator; I eventually restarted the Blocks Editor. It seems to be necessary to re-download the Blocks Editor each time – I can’t just re-start the one I already have, or it doesn’t come up with the project contents.

That’s about all I have time for now. It looks like an interesting way to introduce someone to creating simple apps to the phone – especially if they’re graphically minded. I’ll show this to my Android group tomorrow.

 

Advertisements

Clustering Tomcat (part III): the HTTPS connector

Refer to my earlier posts on the subject for background. Here are further explorations, not having much to do with clustering as it turns out, but everything to do with proxying.

In a number of situations you might want to set up encrypted communication between the proxy and backend. For this, Tomcat supplies an HTTPS connector (as far as I know, the only way to encrypt requests to Tomcat).

Connector setup

Setup is actually fairly simple with just a few surprises. Mainly, the protocol setting on the connector remains “HTTP/1.1” not some version of “HTTPS” – the protocol being the language spoken, and SSL encryption being a layer on top of that which you specify with SSLProtocol. Basically, HTTPS connectors look like HTTP connectors with some extra SSL properties specifying the encryption:

<Connector executor="tomcatThreadPool"
 port="${https.port}"
 protocol="HTTP/1.1"
 connectionTimeout="20000"
 acceptCount="100"
 maxKeepAliveRequests="15"
 SSLEnabled="true"
 SSLProtocol="TLS"
 scheme="https"
 secure="true"
 keystorePass="changeit"
 clientAuth="false"
/>

If I really wanted to be thorough I would set clientAuth=”true” and set up the proxy with a client certificate signed by this server’s truststore, thereby guaranteeing only the proxy can even make a request. But not right now.

Note the “scheme” and “secure” properties here. These don’t actually affect the connection; instead, they specify what Tomcat should answer when a servlet asks questions about its request. Specifically, request.getScheme() is likely to be used to create self-referential URLs, while request.isSecure() is used to make several security-related decisions. Defaults are for a non-secure HTTP connector but they can be set to whatever makes sense in context – in fact, AFAICS the scheme can be set to anything and the connector will still serve data fine. Read on for clarity on uses of these properties. Continue reading

Android UI – making the simple things virtually impossible

Know what I need? A “Stupid Android UI Tricks” book. I swear, there’s just so much about programming the native UI that just seems completely random and ass-backward. Are all UI APIs this bad?

Here’s the latest fun: I created a dialog where you can enter something in a text editor field. Only, you can’t on my Nexus, because the soft keyboard won’t come up. I don’t know if that’s normal behavior or if I attached something to the field that gets in the way of the keyboard showing up. I thought maybe it was the OnFocusChangeListener I’d set, but I commented that bit out and it still won’t come up. As an aside, sort of, it’s stupid that you can only add one listener for any given event. I have a dialog where I attach a listener in the generic superclass, and then I want to add to that event’s behavior in a subclass. Can’t  do it. I’d have to duplicate or proxy all of the behavior from the parent listener. Where’s the reuse of code? Why aren’t listeners all implemented as daisy chains?

While I’m ranting, why do I even bother creating dialogs? Every time I do, I find something about its intended behavior that requires an Activity to be in play. The latest: I have a dialog where I want to let the user pick a ringtone. Problem is, the only API exposed for this involves a call to startActivityForResult, and how is that result returned? By the onActivityResult callback on the calling Activity. So if you have a dialog and want the user to pick a ringtone, you have to get the Activity to relay the result to the dialog, which means recording the current dialog in a field somewhere in the activity, and adding a callback method on the activity that could have been totally avoided just by adding an implementation of startActivityForResult that accepted a listener for the result. Would that be so hard? Anyway I think the lesson is to create all non-trivial dialogs as Activities that are just styled as dialogs.

Back to the problem at hand. What else might be going on with my missing keyboard? Here’s someone with a similar problem, (and a long thread on the same topic), though I think they’re just not getting the keyboard at dialog start, not failing to get it ever. Anyway I shouldn’t have to add a listener just to get a keyboard. That’s ridiculous. Android should handle this automatically. What could I be doing that’s interfering?

BTW, its layout looks like this:

<EditText
 android:id="@+id/editor"
 android:layout_height="wrap_content"
 android:inputType="number"
 android:maxLength="5"
 android:layout_weight="1"
 android:layout_width="wrap_content" />

I created a completely unattached text editor (no listeners or anything) in my dialog and also couldn’t get a keyboard to come up for that.

Another random ranty aside: seriously, WordPress, why is the post input text area so small by default? The post is the center of attention; it should be as big as possible without crowding out the editing icons. Yeah, I know I can drag around the corner to resize, but I don’t wanna, ok?

Reverse proxy resource usage – httpd 2.2.15

Recently I had reason to find out what happens when your httpd config includes a LOT of ProxyPass statements. The particular use case involved an application farm with one VirtualHost per domain for hundreds of domains, each very similar (though not identical) with dozens of ProxyPass statements to shared backend apps. But just a few dozen domains resulted in very high memory and CPU use.

I set up a simple test rig (CentOS 5 VM,1GB RAM, single x86 CPU, ERS 4.0.2 httpd 2.2.15) and ran some unscientific tests where the config included 20,000 ProxyPass statements with these variables:

  1. Unique vs. repeated – unique statements each proxied to a unique destination, while repeated ones proxied different locations to the same destination.
  2. Balancer – the statements either proxy directly to the URL, or use a pre-defined balancer:// address.
  3. Vhost – the ProxyPass statements were either all in the main_server definition or inside vhosts, one per.
  4. MPM – either prefork or worker MPM is used.

No actual load was applied to the server – I just wanted to see what it took to read the config and start up. Settings were defaults per MPM (5 children for prefork, 3 children for  worker) – obviously you’d tune these depending on usage. I tried to wait for things to settle down a bit after startup before reading “top” sorted by memory usage.

I also tried some other methods for accomplishing this task to see what the memory footprint would be.

Continue reading