[en] Fix irregularity of Java Timer and ScheduledThreadPoolExecutor

Using Java Timer class one can sche­du­le a task for recur­ring exe­cu­tion. Even tho­ugh Sche­du­led­Th­re­ad­Po­olE­xe­cu­tor makes it possi­ble to cre­ate timers with nano­se­cond reso­lu­tion (but bewa­re of under­ly­ing ope­ra­ting sys­tem clock pre­ci­sion!), regu­la­ri­ty of task exe­cu­tion is by default awful.

I have run into this once and had to expla­in the custo­mer that it’s not fixa­ble. When I measu­red the delay betwe­en timer exe­cu­tions, etc. it tur­ned out that doing as much as new Thread(runnable).start() usu­al­ly takes 1 – 5 mil­li­se­conds, but at times it takes two orders of magni­tu­de lon­ger: even half a second!

Same custo­mer, other pro­ject and this time I tho­ught of a reason for this beha­vio­ur: gar­ba­ge col­lec­tion. I star­ted with cal­ling System.gc() expli­ci­tly insi­de measu­red code and it takes 200 – 500 mil­li­se­conds! So it must be it.

Is the­re a solu­tion? Of cour­se the­re is. It’s cal­led The Con­cur­rent Low Pau­se Col­lec­tor and has been in Java sin­ce ver­sion 5. Read the lin­ked artic­le for many, many deta­ils, but shor­tly just add:

-XX:+UseConcMarkSweepGC

to the usu­al java ‑jar com­mand and the gar­ba­ge col­lec­tion will be done in paral­lel with your code exe­cu­tion. Of cour­se it’s no gol­den bul­let, it makes ove­rall per­for­man­ce wor­se (now inste­ad of 1 – 5 mil­li­se­conds, a sin­gle loop pass takes 4 – 10 mil­li­se­conds), but for this par­ti­cu­lar use, it makes Timer regu­la­ri­ty bet­ter by two orders of magnitude.

[en] Solution to SIL3124‑2 „no valid device”

SIL3124 is a PCI (as in old PCI, not PCI express) SATA-II con­trol­ler which I had to buy becau­se my NAS’ old Giga­by­te mother­bo­ard sup­ports (down­spe­eded) SATA-II dri­ves only to 750GB size. Of cour­se I got to know this AFTER buy­ing 1,5TB drive 😉

Any­way, it’s always uphill and even tho­ugh SIL3124 card sees the dri­ve and I’ve instal­led Ubun­tu Server with no pro­blems to it, I could­n’t boot the card. It kept say­ing „no valid devi­ce”. Turns out it has a RAID-only BIOS by default so if some­one — like me — wants to use it as an JBOD (Just a Bunch Of Disks) con­trol­ler, BIOS upgra­de is needed. How user frien­dly not to men­tion it in a — Czech-lan­gu­age — manual.

Of cour­se, being main­ly a Linux user with no CD- or DVD-dri­ve, I have it even more uphill. BIOS fla­shing tools are ava­ila­ble for Win­dows and DOS. Soooo the solu­tion is:

  1. Use HP USB Disk Sto­ra­ge For­mat Tool to cre­ate boota­ble DOS pen­dri­ve, here­’s Polish lan­gu­age tuto­rial: http://​forum​.purepc​.pl/​D​y​s​k​i​-​t​w​a​r​d​e​-​c​d​r​o​m​y​-​d​v​d​-​p​e​n​d​r​i​v​e​-​i​n​n​e​-​p​a​m​i​e​c​i​-​f​5​5​/​B​o​o​t​-​P​e​n​d​r​i​v​e​-​t​2​5​4​0​0​5​.​h​tml if You don’t spe­ak Polish, just google „boot pen­dri­ve dos”, in the tuto­rial is a link to Win98 boot files You might use.
  2. Down­lo­ad UPDFLASH and the newest BIOS zip from http://​www​.sili​co​ni​ma​ge​.com/​s​u​p​p​ort
  3. The zip file has more than one BIOS insi­de, read the README and see which one is „IDEBIOS or „non-RAID” BIOS. Copy the file toge­ther with UPDFLASH to the pendrive.
  4. Boot the PC with the PCI SATA Con­trol­ler from the pendrive.
  5. Run „upd­flash biosfile.bin”
  6. If you don’t have a UPS, pray to Athe­ist’s God™ that the­re­’s no blac­ko­ut during fla­shing process.
  7. Use mother­bo­ar­d’s (not SATA con­trol­le­r’s) BIOS to set Hard Dri­ve as first boot prio­ri­ty, make sure the­re­’s „Boota­ble Add-In Cards” ena­bled somewhere.
  8. Reset and enjoy boota­ble lar­ge drives.

Note: Dri­ve­’s UUIDs chan­ge becau­se of that so it’s best to do it BEFORE instal­ling Ubun­tu, other­wi­se You get a main­ta­nan­ce console.

[en] Ubuntu 9.04 Jaunty on my AMD64 system — notes to myself

Upda­te 2009-11-18, using Ubun­tu 9.10 now

  • Wine has final­ly font anti-alia­sing, to ena­ble do this in rege­dit: ============ REGEDIT4 [HKEY_CURRENT_USER\Control Panel\Desktop] "FontSmoothing"="2" "FontSmoothingType"=dword:00000002 "FontSmoothingGamma"=dword:00000578 "FontSmoothingOrientation"=dword:00000001 ============

Main­ly notes to myself, but may­be some ran­dom Googlers will find some of them use­ful. I may add more in time.

  • If many of texts in your sys­tem, inc­lu­ding Fire­fox are not in your nati­ve lan­gu­age, make sure you have instal­led appro­pria­te lan­gu­age-pack-XX pac­ka­ge (lan­gu­age-pack-pl for Polish). It sho­uld be down­lo­aded by Ubun­tu instal­ler but it never ful­ly wor­ked for me sin­ce 5.04.
  • Pid­gin has a plu­gin for Tlen pro­to­col. Just down­lo­ad the newest .tar.gz, unpack and make. You sho­uld have pid­gin-dev pac­ka­ge instal­led for it to suc­ce­ed. I did­n’t try make install, just copied over resul­ting lib​tlen​.so to /usr/lib/purple‑2 and .png files to /usr/share/pixmaps/pidgin/protocols, one file — rena­med to just tlen.png — to each folder.
  • Nice Pid­gin smi­ley pack which has ori­gi­nal emo­ti­kons for pro­to­cols I use. Just go to Pid­gin set­tings, smi­ley sets tab and click add. 
  • Fire­tray con­tra­ry to what its name sug­ge­sts, also works in Thun­der­bird, allo­wing it to mini­mi­ze itself to sys­tem tray. Just open Thun­der­bir­d’s Add-ons win­dow and drag install link the­re from Fire­fox to install this extension.
  • Polish set of Adblock fil­ters I’ve been using for some time now.
  • Instal­ling Auro­ra GTK The­me engi­ne (most good the­mes seem to use it):
    aptitude install build-essential libgtk2.0-dev
    # download from 
    # http://www.gnome-look.org/content/show.php/Aurora+Gtk+Engine?content=56438 
    # unpack and cd to source directory
    ./configure --prefix=/usr --enable-animation
    make
    sudo make install
    
  • Down­lo­ad Myriad Pro font. Here­’s Myriad in TTF ver­sion (thanks Misiek) which looks bet­ter in Java pro­grams (think OpenOffice).
  • Fresh Dark — a very nice dark the­me for Gno­me. Also see mat­ching icons. If Metacity/Emerald (win­dow bor­ders) the­me doesn’t work, just check file and direc­to­ry per­mis­sions of the unpac­ked the­me. If win­dows run as root look ugly, make sure you copy the the­me to /usr/share/themes inste­ad of just ~/.themes.
  • Wine repo­si­to­ry which usu­al­ly has newer ver­sion than default Ubun­tu repos.
  • A nice way to inte­gra­te MS Offi­ce (I have a licen­se so I use it thro­ugh Wine inste­ad of Ope­nOf­fi­ce, same goes to Pho­to­shop which I pre­fer over Gimp in spi­te of all tho­se holy wars abo­ut it) is to cre­ate /opt/wine-start.sh script with fol­lo­wing contents
    #!/bin/bash
    wine start "z:$1"
    
    and then chmod +x it and use it with Gno­me­’s Open With func­tion on .doc, .xls and .ppt files. That way I’m able to open tho­se files in Word, Excel and Power­Po­int just by double clic­king them.
  • The­re is Java Plu­gin for Fire­fox on AMD64 at last (just install sun-java6-plu­gin package).
  • Wam­mu (nice mobi­le pho­ne mana­ger with a gre­at featu­re of copy­ing your SMSes to your e‑mail inbox) just works in Jaun­ty with my Nokia 6021 over blu­eto­oth which was never a case before.
  • SSH Menu is a nice lit­tle gno­me applet to build a fast-access menu of SSH servers you con­nect to. Ubun­tu repo­si­to­ry is also there.
  • I always for­get that Eclip­se PDT (PHP Deve­lop­ment Tools) all-in-one down­lo­ad is for 32bits only. To install it on AMD64 archi­tec­tu­re, down­lo­ad 64-bit ver­sion of Eclip­se for Java­EE and do the following:
    tar xzvf eclipse-jee-ganymede-SR1-linux-gtk-x86_64.tar.gz
    sudo mv eclipse /opt
    # you probably should think twice about chown and chmod, 
    # but I myself make my PC physically secure so don't care
    sudo chown -R user.group /opt/eclipse
    sudo chmod -R 770 /opt/eclipse
    sudo nano /etc/environment # put path to JDK by adding a 
    # line something like JAVA_HOME="/usr/lib/jvm/java-6-sun"
    /opt/eclipse/eclipse # choose your workspace location and start Eclipse
    
    When in Eclip­se, just use the­ir instruc­tions on instal­ling PDT
    Help > Software Updates... > Available Software > Manage Sites...
      Add... > add the DLTK 1.0 interim site: http://download.eclipse.org/technology/dltk/updates-dev/1.0/
      Add... > add the PDT 2.0 interim site: http://download.eclipse.org/tools/pdt/updates/2.0/
      Enable the Ganymede Update site (if not already enabled): http://download.eclipse.org/releases/ganymede/
      Expand the DLTK site and select the Dynamic Languages Toolkit - Core Frameworks or Dynamic Languages Toolkit - 
                                                                                              Core Frameworks SDK Feature 
      Select the PDT or PDT SDK Feature
      Install...
    
  • To make Sub­c­lip­se plu­gin work in Eclip­se (to be able to use Sub­ver­sion repo­si­to­ries), apti­tu­de install lib­svn-javahl and then nano /opt/eclipse/eclipse.ini and add a line that says (sans quotes) „-Djava.library.path=/usr/lib/jni” just under „-vmargs” line.
  • I’ve final­ly found a way to chan­ge Gno­me­’s clock appe­aran­ce, fire up gconf-edi­tor, go to /apps/panel/applets/clock_screen0/prefs, chan­ge „for­mat” to „custom”, „custom_format” to some­thing like „<span color=”#99ccff”><sup><b>%A, %d %B %Y</b></sup></span> <big><b><big>%H</big><sup>%M</sup></b></big>” and voila!
  • Even tho­ugh daily­strips (a script that down­lo­ad comic strips for you) at sour­ce­for­ge seems to be aban­do­ned, they have upda­ted daily­strips and strips.def at Mister­Ho­use project. 

[en] How to mount LVM VG and restore data from it when one of its PV drives has failed

Howe­ver gre­at LVM is in Linux, allo­wing one to span sin­gle „par­ti­tion” over seve­ral hard dri­ves, if the under­ly­ing „dri­ves” are real hard dri­ves and not RAID volu­mes, You can get pret­ty fuc­ked when one of tho­se disks fails.

It took me seve­ral hours of googling aro­und and trials to find out how to reco­ver as much data as is possi­ble (meaning: all the data that is on rema­ining disks, the data on failed dri­ve is obvio­usly lost). So let’s try to add a short and wor­king reci­pe to Google.

  1. You do NOT have to pvcre­ate any bogus emp­ty PVs with fake UUIDs to repla­ce the failed dri­ve. LVM2 can be used in „par­tial” mode witho­ut all the drives.
  2. To use par­tial mode, You need to cre­ate /dev/ioerror devi­ce like this (I use Ubun­tu, in other distros it might be different): 
    • nano filename to cre­ate a text file whe­re a sin­gle line „0 9999999999 error” sans quotes sho­uld be placed
    • dmsetup create ioerror filename to cre­ate a devi­ce LVM will read inste­ad of mis­sing PV
    • ln -s /dev/mapper/ioerror /dev/ioerror so it’s just whe­re LVM will look for it
  3. After ioer­ror is cre­ated, just acti­va­te your volu­me gro­up in par­tial mode using vgchange -P -ay VOLNAME
  4. Mount it (it will mount in read only mode) and copy your pre­cio­us data

Che­ers to the­se guys who final­ly writ­ten some­thing I could use inste­ad of pvcre­ate and bogus hard dri­ves discussions.

Virtualmin on Ubuntu 8.04 Server

Notes to myself and Googlers on instal­ling a vir­tu­al hosting con­trol panel Vir­tu­al­min (a gre­at add-on to Webmin) on Ubun­tu server:

  • wget http://software.virtualmin.com/gpl/scripts/install.sh
    chmod 755 install.sh
    ./install.sh
     — installs Vir­tu­al­min auto­ma­ti­cal­ly with all depen­den­cies, with a nice skin which is also used by Webmin (which I remem­ber used to be quite ugly by default) 
  • chmod 711 /var/spool/postfix/var/run/saslauthd  — fixes login failu­re when try­ing to send mail thro­ugh vir­tu­al server
  • it seems apa­che vhost, ftp, e‑mail and DNS is pro­per­ly con­fi­gu­red auto­ma­ti­cal­ly, will add more info here as I move on with my hosting migra­tion to Vir­tu­al­min probably