Tuesday, 10 May 2011

memcached-session-manager and Membase

The Tomcat memcached-session-manager and Membase do play well together, but the documentation on setting it up is a bit thin, and more focused on a memcached installation, especially if you are using Membase for the bucket replica and HA.


Membase
Set up the basic N-node Membase cluster. This part is trivial. You'll end up with N servers, all running their local Moxi proxy server on port 11211. You'll be able to telnet into any of the servers on that port and set an object. Telnet to another of the servers on port 11211 and you can get the object back out.


memcached-session-manager
The tricky part is that memcached-session-manager does not want to know about the topology of the replica data buckets in the Membase cluster. Leave that job to the Moxi memcached proxy. You get Moxi when you install Membase, or it's available as a separate installer for Linux.
Run moxi on each of your Tomcat hosts (do it for HA, though you will now need to monitor the moxi process as well as your tomcat process from the load balancer - if either dies, the server should be pulled from the pool). We use port 11311 for the moxi to separate it conceptually from the moxi's running in "gateway" mode on the Membase servers on port 11211:

/opt/moxi/bin/moxi -Z port_listen=11311 \
http://192.168.0.1:8091/pools/default/bucketsStreaming/default,\
http://192.168.0.2:8091/pools/default/bucketsStreaming/default


Then in your Tomcat <Context> configuration, you use the local moxi details in the session manager:

<Manager className="..." memcachedNodes="n1:localhost:11311" ... />


What you end up with is...

Tomcat1 -> LocalMoxi --\       
                        \      /--> Membase 1
Tomcat2 -> LocalMoxi ----\    /
                          >--<
Tomcat3 -> LocalMoxi ----/    \
                        /      \--> Membase 2
Tomcat4 -> LocalMoxi --/


And each local moxi is aware of the topology of the Membase cluster, and is aware of whcich Membase servers are running and which are down. You will still get errors in your Tomcat logs from the spymemcached library if you kill a Membase server. That will continue until you take a manual step of hitting "remove" on the dead server from the remaining server's console (and then you should rebalance the cluster).

Summary
It's possible this is overkill, but until we introduced the local moxi proxy processes, our Tomcat servers would not handle a Membase server being killed.

Wednesday, 30 March 2011

Firefox 4 - don't trim the URL preview

To stop Firefox 4 from trimming the URL in the preview and loading pop-ups, edit your <profile>/chrome/userChrome.css thus:
statuspanel {
max-width: 100% !important;
}
source: http://www.lifehacker.com.au/2011/03/stop-firefox-4-from-trimming-url-previews-in-the-status-bar/

Tuesday, 29 March 2011

Firefox 4 - make the app menu transparent

To change the "Firefox" app menu from orange to transparent in Firefox 4, edit your <profile>/chrome/userChrome.css thus:
@namespace url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul); 
#appmenu-button{
    background:transparent!important;
}
source: http://www.lifehacker.com.au/2011/03/from-the-tips-box-windows-7-favorites-the-firefox-button/

Saturday, 26 March 2011

ATV2 XBMC unofficial nightlies

ssh root@apple-tv.local
cd /private/var/tmp && \
wget 'http://hadm.net/~keith/xbmc_atv2/latest_atv2.deb' && \
dpkg -i latest_atv2.deb && \
rm latest_atv2.deb

Sunday, 20 March 2011

ATV2 xbmc.log file location

Apple TV 2 XBMC's xbmc.log file is located at:

/private/var/mobile/Library/Preferences/xbmc.log

Saturday, 19 March 2011

Showing a background image while an iframe is loading

Rather than a white rectangle on your page while an <iframe> is loading, you can set a background image in CSS. This works in IE7 & IE8 (with a bit of a flash when the iframe content is ready); Firefox 3.6 and Chrome 10 (perfectly); but in Safari 5 the background image is not shown until the iframe is loaded.

I found this useful when 'co-branding' a site to use another site's header and footer in an iframe. Since I could not trust the speed of the other sites, I grabbed their logo, then positioned it as a background image on the iframe so the logo was in the same position as the final iframe version. Then at least the user sees a nice logo straight away, and they might need a second or two before the navigation and other elements of the other sites headers show up.

This was the iframe code:
<iframe width="960" height="154" scrolling="no" frameborder="0"
marginwidth="0" marginheight="0" src="[other-site-URL]"
style="background:url('[local-logo-URL]') no-repeat scroll [X-off]px [Y-off]px;"></iframe>

Friday, 18 March 2011

iframe mysterious 3px margin

If you have some HTML like:

<iframe ...></iframe>
<div></div>

... you'll have a mysterious 3px gap between the elements even though everything says the margins are all zero. Rather than putting a margin-top="-3px" on the div, the better solution is to change the <iframe> to display:block.

Yup ... <iframe>'s default to display inline. Who would have guessed that!