Showing posts with label geek. Show all posts
Showing posts with label geek. Show all posts

Sunday, December 19, 2010

Yes, Riding on Linux

I received a free WiMAX USB dongle (called the Yes Go) last Tuesday, given how busy week days usually are, I only managed to really get it working on my Ubuntu now. In this blog, I am not going write about the Yes site usability, how interesting the speed can go (by the way, if you think 10Mb/s is impressive enough, that's the speed HSDPA can give. WiMAX can run up to 40Mb/s.); Instead, I speak about what I went through getting it to work on my Linux machine.

Yes Go doesn't have (publicly) a Linux driver (and its source), just like the Clearwire USB dongle and many others. Yes Go is manufactured by Infomark, IMW-U300, which uses GCT chip (GDM7205 most likely, with uClinux. It can push >30Mbps of download and 6Mbps of upload):

(Note: I'm not a Linux hacker, so all I could do is usb_modeswitch and some simple digging. I'm happy to learn how to grab the image and boot into it when I have the time.)
$ screen /dev/ttyUSB0
Model name: IMW-U300   
 Manufacturere: INFOMARK
%WIMAX MAC: ff:ff:ff:ff:ff:ff
/dev/usb0
3Parameter block: version 2 in NVRAM EEPROM

$ lsusb | grep 1076
Bus 001 Device 039: ID 1076:7f00 GCT Semiconductor, Inc.
Given that (and I-ANAL - I Am Not A Lawyer), GCT could have violated the GPL (see also this Taiwanese post).

After hours of research, I contacted @YesCare for the driver, the case has been escalated and am still pending for solution at the time I'm writing this blog. This left me with one ugly workaround to use Yes Go -- bridging from a virtual machine (I use Sun's/Oracle's VirtualBox) running Windows.

The basic steps (more discussions in this VirtualBox's forum thread):
  • Create an ad-hoc wireless network in NetworkManager.
  • Add a bridge adapter in VirtualBox, select your wireless LAN (e.g. wlan0).
  • Turn off usb_modeswitch before plugging in the USB dongle. See /etc/usb_modeswitch.conf.
  • Start VirtualBox with root (or configure fstab to allow current user to read/write the USB device nodes).
  • Setup Yes Go, once connected, bridge it with your adapter added earlier.

That ends a chapter.

Meanwhile, for preregistered users, today is the last day to activate your account in order to retain your reserved phone number.

To make myself to really know what I'm going to pay for, I wrote a JS-based calculator last night using mvc.js (before Yes updated their site with the new calculator this afternoon). Feel free to fork it with jsfiddle or github.

Thursday, October 7, 2010

Zend Debugger > XDebug makes PDT > Netbeans

Displaying variable values - including breakdown values of their attributes - of current scope has been the most important thing to my debugging practice.

AFAIK, Netbeans PHP IDE only supports XDebug. XDebug is known to be unstable with watches and balloons (and I have had too many crashes experience) and having this defect yields Netbeans useless IMO.

I use PDT together with XDebug over the past 3 years of active PHP development and for the past few days (finally) I started using Zend Debugger. Then I realized that it has the "problem" of only displaying variables in scope (e.g. function scope), meaning, global variables and $this will not be shown, due to usability and performance concern.

The fix is pretty simple (after reading this forum response), just place watches if you want to monitor out-of-scope variables.

Thursday, December 17, 2009

3 Spring Stuff Worth Sharing

Firstly, Spring 3.0.0 is released not more than 2 days ago. Juergen (if you have the habit of reading source code, you shall know him) blogged about the features at Spring Framework 3.0 goes GA. I am particularly interested to explore more (possibly make changes to my existing project) in the area of @Configuration, SpEL, REST, OXM and validation.

I also upgraded my project this morning, with less than 10 lines of code changes to switch the plug from 2.5.6 to 3.0.0 - the compilation errors were some casting issues of generics type - yes, Spring 3 is now compile-time type safe. If you use Maven, you may want to read about the pom and repository configurations here.

Second-and-thirdly, below are some notes I wrote down in company's intranet. :)

Spring Resolves Dependencies and Initializes Accordingly, Not You

Before that, I thought implementing the Ordered interface could impact the order of which beans shall first be loaded. Then I realized, it doesn't work. Ordered is used.. as far as I can tell right now, two on top of my head: during invocation of Bean and BeanFactory post processing and the order of Advices - just not Bean initialization!

So how does it really work (for which bean to be loaded before any other)? One thing that I found (or maybe really just one): dependencies - bean references and @DependsOn/depends-on. When the BeanFactory preinstantiates the beans, it resolves its dependencies (via BeanDefinitionValueResolver) and eventually the beans who are referenced/dependent by others will be initialized first.

Do take note that, you rarely use @DependsOn unless you have static (*ugh!!*) references. For my case, HibernateSessionFactoryBean depends on SubEntityManager and those enums in it are accessed via the static (*ugh!!*) method SubEntityManager.getInstance() by the SubEntityUserType.

Spring Shutdown Hook and Unit Testing

A Spring ApplicationContext has a close() method, things like HibernateSessionFactoryBean will only be destroyed when the context is destroyed via the close() method - which is triggered by shutdown hook. See AbstractApplicationContext.registerShutdownHook(). So what is important here to know is, if you are running unit tests, a series of them, destroy can only happen when the shutdown hook is called.

Here's an example, I was running two test fixtures but the first one didn't shutdown until the whole test execution exited.
[12-16 16:26:45] INFO  GenericApplicationContext [Thread-4]: Closing org.springframework.context.support.GenericApplicationContext@1923ca5: ...startup date [Wed Dec 16 16:26:42 MYT 2009]; root of context hierarchy
[12-16 16:26:45] INFO  GenericApplicationContext [Thread-3]: Closing org.springframework.context.support.GenericApplicationContext@19b5217: ...startup date [Wed Dec 16 16:26:34 MYT 2009]; root of context hierarchy
[12-16 16:26:45] INFO  HibernateSessionFactoryBean [Thread-4]: Closing Hibernate SessionFactory
[12-16 16:26:45] INFO  HibernateSessionFactoryBean [Thread-3]: Closing Hibernate SessionFactory

Saturday, November 7, 2009

Wireless Network disappeared after Ubuntu 9.10 (Karmic) upgrade

Upgraded to 9.10 this morning but funny thing was - wireless networking wasn't working anymore - ath_pci module is gone from the release.

Fixed by loading the ath5k module, as suggested by the ThinkPad wiki. You can append it to /etc/modules for it to be automatically loaded.

Thursday, July 23, 2009

Measuring Your Engineers

To say that I am managing an Agile team is not entirely accurate, we are just trying to be agile. Anyway, skipping the story, the team's velocity increased more than 800% for the last 2 iterations, mainly due to management pressure. Put aside other reasons such as requirement gathering, design, headcount, etc.

1. Engineers are most probably working within their comfort zone.

For the past 3 months, I had passed/failed/extended the probation period of the engineers. During the session, they discussed with us their strength, weaknesses and areas for improvement.

2. Most engineers highlighted that they're lacking some knowledge to perform better.

So, last weekend, after having a discussion with the management, I was given a task - create KPIs to give engineers a direction as well as to provide management a way to measure their performance. So there are two things - KPIs and Performance Review. The first thing that got into my mind was - how did my ex-company do it?

In the support team that I worked in, we used a ladder-based system where there were 4 skill levels defined with skills to achieve. We would also set KPIs such as "resolving 30 support cases with customer satisfaction above 75%" or "to be SCJP certified". The progress, results and data would be presented to the management during our performance review. Trust me, people seldom stepped out the room wyith a happy face because the management loved to tell you where you did not do good enough.

I was thinking of the ladder since then.

I then looked into some blogs and Stack Overflow questions, such as this (Joel), this, this (Steve Yegge), this and this, which in general send the same message:

3. Management focuses too much on measuring the performance than improving the products and getting things done.

Something quite similar to this will be - timesheet and the reason I abolished it because it is irrelevant with the team velocity and business values. What does it mean then, shall we not measure the engineers at all? Your HR is certainly expecting some kind of metrics for her as a parameter to make salary adjustment.

What shall we look into then? Let's start from things that we shall never use to measure an engineer:
  • SLOC - Source Lines of Code, the dumbest ever metric. Good programmers write lesser lines.
  • Number of bug fixes - No way! The engineers would have figured out how to compromise this by writing more buggy code. I strongly against this just like how I disagree with giving points to bug fixes.
  • Hours logged - Timesheet is a waste of time.

I had like a 10-minute talk with the engineers yesterday to find out how they want to be evaluated and paid. I think this is important instead of me making decision and guesses based on how other software houses do it. It turned out that they want to be reviewed by the peers, by stories delivered, by code quality, and by having salary within different range they expect to be put an expectation on the skill set they possess.

So here is my summary, the performance metrics will be generally based on the expectations, the results, and the feedbacks:
  • The rating from their team members.
  • The rating from their direct supervisor, basically this person also knows the agility, code quality, velocity, etc. of this person.
  • The total stories delivered.
  • The skill set, which KPIs can be related with this, not entirely though.
Are KPIs necessary? KPIs shall not be mandated, they have to be discussed and proposed by the individuals, based on their comfort level and see how far we want to go above it. If a KPI is not going to help an engineer to produce quality code and better product, drop it. Also, if one doesn't want to play this KPI game as he really has a clear idea about every thing he is doing, don't force him to change the way he handles and manages his job and directions.

The last reminder is that, we shall not expect to have a perfect and fair formula that objectively measure and rate an engineer. Whether someone will be promoted or given a good salary shall be based on human judgments, as we are dealing with humans and humans make important decisions like you always do.

Saturday, April 11, 2009

"Autoboxing" Array is Illegal

Wrote some array methods today then I had a question about auto-converting an int[] to Integer[] (auto-boxing) while I was driving back home.

For instance, this works,
public static  V wrapper(V v, Class clazz){
return v;
}

int i = wrapper(1, Integer.class);

But this is not compilable,
public static  V[] wrapperArray(V[] v, Class clazz){
return v;
}

int[] i2 = wrapperArray(i2, int.class);

int.class will be auto-converted to Integer.class but int[] will not. I can't find the exact line in JLS describing this, do leave a comment if you could.

Friday, April 10, 2009

Strange Maven Plugin Metadata Problem

Not too sure when, my Maven Eclipse plugin has been upgraded to 2.6 and probably due to some metadata "corruption", its dependencies were not downloaded, running it caused ClassNotFoundException:

[INFO] ------------------------------------------------------------------------
[INFO] Building Whatever
[INFO] task-segment: [eclipse:eclipse]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing eclipse:eclipse
...
-----------------------------------------------------
this realm = app0.child-container[org.apache.maven.plugins:maven-eclipse-plugin:2.6]
urls[0] = file:/home/yclian/.m2/repository/org/apache/maven/plugins/maven-eclipse-plugin/2.6/maven-eclipse-plugin-2.6.jar
urls[1] = file:/home/yclian/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
Number of imports: 10
import: org.codehaus.classworlds.Entry@a6c57a42
import: org.codehaus.classworlds.Entry@12f43f3b
import: org.codehaus.classworlds.Entry@20025374
import: org.codehaus.classworlds.Entry@f8e44ca4
import: org.codehaus.classworlds.Entry@92758522
import: org.codehaus.classworlds.Entry@ebf2705b
import: org.codehaus.classworlds.Entry@bb25e54
import: org.codehaus.classworlds.Entry@bece5185
import: org.codehaus.classworlds.Entry@3fee8e37
import: org.codehaus.classworlds.Entry@3fee19d8


this realm = plexus.core
urls[0] = file:/opt/maven-2/lib/maven-2.1.0-uber.jar
Number of imports: 10
import: org.codehaus.classworlds.Entry@a6c57a42
import: org.codehaus.classworlds.Entry@12f43f3b
import: org.codehaus.classworlds.Entry@20025374
import: org.codehaus.classworlds.Entry@f8e44ca4
import: org.codehaus.classworlds.Entry@92758522
import: org.codehaus.classworlds.Entry@ebf2705b
import: org.codehaus.classworlds.Entry@bb25e54
import: org.codehaus.classworlds.Entry@bece5185
import: org.codehaus.classworlds.Entry@3fee8e37
import: org.codehaus.classworlds.Entry@3fee19d8
-----------------------------------------------------
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Internal error in the plugin manager executing goal 'org.apache.maven.plugins:maven-eclipse-plugin:2.6:eclipse': Unable to load the mojo 'org.apache.maven.plugins:maven-eclipse-plugin:2.6:eclipse' in the plugin 'org.apache.maven.plugins:maven-eclipse-plugin'. A required class is missing: org/codehaus/plexus/resource/loader/ResourceNotFoundException
org.codehaus.plexus.resource.loader.ResourceNotFoundException

Tried running Maven with the -cpu argument but it didn't help. maven-metadata-central.xml showed the latest as 2.5.1 and others got 2.6. Fixed by deleting metadata files then re-run Maven.

Bah.

Tuesday, March 31, 2009

RTFL - Read the Fucking Logs

Read the fucking logs? Yes, it happened so many times, on so many guys. Something that I always try to avoid.

Say, you hit into a problem, you looked into the log file, you could see a bunch of error messages and stacktrace, you read the first line, you didn't bother to read the second and further.

You tried to change the configurations or something that you thought would make sense but the same (or new) error came out. You spent quite some time on it like an hour or a day.

You asked me / your supervisor to look into it and they found clear error messages or indications somewhere down the error log. You felt sorry, you found yourself stupid to waste so much time, you wished to be in the hall of shame for that day.

If this is a recurring habit of your, can you make "reading logs carefully" as a troubleshooting principle?

Thursday, March 5, 2009

404 on Nexus

Was stuck for a few minutes as Sonatype Nexus was reporting 404 while I tried to access a POM file. Expiring the cache (right clicking on the troubled repository) is the fix of it.

Wednesday, March 4, 2009

Working on Branches and the Stable Trunk

I used to work on the trunk because for all the projects I worked on, it's either I was the sole developer or the team ensured that everyone code check-in has passed the local tests. Otherwise, we created (we still) branches for bug fixes, large code for new features, etc.

About 2 months ago, I had a short git session with Kamal and he shared with me the idea of story/branch. And as my team started to grow with more dev guys, I feel the need of encouraging more branching and now this has become a rule. For a project with automated tests defined with CI set up, a stable trunk is guaranteed and this practice can fit very well into it.

We don't use git but Subversion because that's how we started and we are still comfortable with it now (most of the time).

If you have a working copy on trunk, here're some simple steps to switch to a branch (svn switch won't work):

svn cp https://repo/trunk https://repo/branches/module-version-storyname
cd /path/to/trunk/working/copy
svn diff > /tmp/diff
svn co https://repo/branches/module-version-storyname
cd module-version-storyname
patch -p0 < /tmp/diff

Thursday, February 19, 2009

Wireless Network not working on Ubuntu after Suspend/Hibernate

It never happened to me til about a month plus ago. Didn't bother to fix it 'til just now.

It's a bug reported at 53310, and it's fixed (on my machine) by doing:
modprobe -r ath_pci
modprobe ath_pci

Sunday, February 15, 2009

InflaterIjputStream.class

Exception in thread "main" java.lang.NoClassDefFoundError:
java/util/zip/InflaterInputStream
at java.util.zip.ZipFile.getInputStream(ZipFile.java:212)
at java.util.zip.ZipFile.getInputStream(ZipFile.java:180)
at java.util.jar.JarFile.hasClassPathAttribute(JarFile.java:463)
...

In the rt.jar, InflaterInputStream.class was named InflaterIjputStream.class. How could this happen? Fixed the issue by repackaging the zip.

yc

Tuesday, February 10, 2009

JVM failed with Segmentation Fault

This happened completely out of a sudden and truly random. The JVM that runs our business logic app died last night and could never be brought up anymore due to segmentation fault. (It suicided quietly)

The last few lines via strace:

DEBUG DefaultListableBeanFactory [main]: Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
[02-10 10:22:30] DEBUG AnnotationTransactionAttributeSource [main]: Adding transactional method [createUser] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
) = ? ERESTARTSYS (To be restarted)
+++ killed by SIGSEGV +++

It could just be a JVM bug (not exactly sure which, but suggested by John Raymond Wold, W_work in #java@irc.freenode.net) and upgrading to the newest version fixed the problem.

- yc

Thursday, December 18, 2008

My Maxis Broadband is Fast

It is, always. I use it 24/7, when I work in the morning, when I travel in the afternoon and when I'm home in the evening.

It is crap when it's in Port Dickson or some concrete buildings with poor signals, but not most of the time. I have also noticed the trend that it can go amazingly fast in the midnight til around 8am+ in the morning (so if you have a long connected connection, maybe you want to redial for a good speed), like this:

:)

yc

Thursday, December 11, 2008

Upgrading/Uninstalling AIR Runtime on Linux

While upgrading my AIR on Linux from Alpha to Beta, I hit into:

An error occurred while installing Adobe AIR. Installation may not be allowed by your administrator. Please contact your administrator.


That's not too helpful so I guessed I would have to remove the older version before upgrading. You can't uninstall using the installer as it doesn't provide an uninstallation option, you have to look into your package manager, e.g.

dpkg -S "*air*" | grep adobe


The Alpha version appears as adobeair-enu and Beta as adobeair1.0.

yc

Sunday, November 23, 2008

Where is the log file of Eclipse TPTP Agent Controller?

I have a problem to use the integrated agent controller, which RAServer.sh reported that it has actually been running. Still finding and just learned that the logs are available at:

$TPTP_AC_HOME/config/servicelog.log

yc

Wednesday, November 12, 2008

Firefox works offline due to NetworkManager interfaces being inactive

There's one improvement in Ubuntu 8.10 which is causing me some problems - NetworkManager can now detect my HSDPA. But it doesn't work and here's the log:

Nov 12 22:32:40 kimmy pppd[9724]: Plugin /usr/lib/pppd/2.4.4/nm-pppd-plugin.so loaded.
Nov 12 22:32:40 kimmy pppd[9724]: pppd 2.4.4 started by root, uid 0
Nov 12 22:32:40 kimmy pppd[9724]: Using interface ppp0
Nov 12 22:32:40 kimmy pppd[9724]: Connect: ppp0 <--> /dev/ttyUSB0
Nov 12 22:32:40 kimmy NetworkManager: (ttyUSB0): device state change: 5 -> 6
Nov 12 22:32:40 kimmy pppd[9724]: CHAP authentication succeeded
Nov 12 22:32:40 kimmy pppd[9724]: CHAP authentication succeeded
Nov 12 22:32:40 kimmy NetworkManager: (ttyUSB0): device state change: 6 -> 7
Nov 12 22:32:40 kimmy kernel: [ 2143.619828] PPP BSD Compression module registered
Nov 12 22:32:40 kimmy kernel: [ 2143.681813] PPP Deflate Compression module registered
Nov 12 22:32:42 kimmy pppd[9724]: Modem hangup
Nov 12 22:32:42 kimmy NetworkManager: (ttyUSB0): device state change: 7 -> 9
Nov 12 22:32:42 kimmy NetworkManager: [1226500362.016832] nm_serial_device_close(): Closing device 'ttyUSB0'
Nov 12 22:32:42 kimmy pppd[9724]: Connection terminated.


Then, the supposingly working gnome-ppp will start hanging up too and in order to bring it back to live, I have to run the vodafone-mobile-connect-card-driver-for-linux:

Nov 12 22:34:03 kimmy pppd[9843]: pppd 2.4.4 started by yclian, uid 1000
Nov 12 22:34:03 kimmy pppd[9843]: using channel 7
Nov 12 22:34:03 kimmy pppd[9843]: Using interface ppp0
Nov 12 22:34:03 kimmy pppd[9843]: Connect: ppp0 <--> /dev/ttyUSB0
Nov 12 22:34:03 kimmy pppd[9843]: Warning - secret file /etc/ppp/pap-secrets has world and/or group access
Nov 12 22:34:03 kimmy pppd[9843]: sent [LCP ConfReq id=0x1 ]
Nov 12 22:34:03 kimmy pppd[9843]: rcvd [LCP ConfReq id=0x12 ]
Nov 12 22:34:03 kimmy pppd[9843]: sent [LCP ConfRej id=0x12 ]
Nov 12 22:34:03 kimmy pppd[9843]: rcvd [LCP ConfAck id=0x1 ]
Nov 12 22:34:03 kimmy pppd[9843]: rcvd [LCP ConfReq id=0x13 ]
Nov 12 22:34:03 kimmy pppd[9843]: sent [LCP ConfAck id=0x13 ]
Nov 12 22:34:03 kimmy pppd[9843]: sent [LCP EchoReq id=0x0 magic=0x0]
Nov 12 22:34:03 kimmy pppd[9843]: rcvd [LCP DiscReq id=0x14 magic=0xe0777e]
Nov 12 22:34:03 kimmy pppd[9843]: rcvd [CHAP Challenge id=0x1 <5053860912aec751b049750c32c838e8>, name = "UMTS_CHAP_SRVR"]
Nov 12 22:34:03 kimmy pppd[9843]: Warning - secret file /etc/ppp/chap-secrets has world and/or group access
Nov 12 22:34:03 kimmy pppd[9843]: sent [CHAP Response id=0x1 <2fb0aedcf34cb0db311ad1a157c5be04>, name = "admin"]
Nov 12 22:34:03 kimmy pppd[9843]: rcvd [LCP EchoRep id=0x0 magic=0xe0777e 00 00 00 00]
Nov 12 22:34:03 kimmy pppd[9843]: rcvd [CHAP Success id=0x1 ""]
Nov 12 22:34:03 kimmy pppd[9843]: CHAP authentication succeeded
Nov 12 22:34:03 kimmy pppd[9843]: CHAP authentication succeeded
...
Nov 12 22:34:08 kimmy pppd[9843]: local IP address 121.120.201.243
Nov 12 22:34:08 kimmy pppd[9843]: remote IP address 10.64.64.64
Nov 12 22:34:08 kimmy pppd[9843]: primary DNS address 58.71.136.10
Nov 12 22:34:08 kimmy pppd[9843]: secondary DNS address 58.71.132.10
Nov 12 22:34:08 kimmy pppd[9843]: Script /etc/ppp/ip-up started (pid 9845)

Now, disconnecting it again, connecting with gnome-ppp will start working:

Nov 12 22:34:24 kimmy pppd[9936]: pppd 2.4.4 started by yclian, uid 1000
Nov 12 22:34:24 kimmy pppd[9936]: using channel 8
Nov 12 22:34:24 kimmy pppd[9936]: Using interface ppp0
Nov 12 22:34:24 kimmy pppd[9936]: Connect: ppp0 <--> /dev/ttyUSB0
Nov 12 22:34:24 kimmy pppd[9936]: Warning - secret file /etc/ppp/pap-secrets has world and/or group access
Nov 12 22:34:24 kimmy pppd[9936]: sent [LCP ConfReq id=0x1 ]
Nov 12 22:34:24 kimmy pppd[9936]: rcvd [LCP ConfReq id=0x15 ]
Nov 12 22:34:24 kimmy pppd[9936]: sent [LCP ConfRej id=0x15 ]
Nov 12 22:34:24 kimmy pppd[9936]: rcvd [LCP ConfAck id=0x1 ]
Nov 12 22:34:24 kimmy pppd[9936]: rcvd [LCP ConfReq id=0x16 ]
Nov 12 22:34:24 kimmy pppd[9936]: sent [LCP ConfAck id=0x16 ]
Nov 12 22:34:24 kimmy pppd[9936]: sent [LCP EchoReq id=0x0 magic=0x0]
Nov 12 22:34:24 kimmy pppd[9936]: rcvd [LCP DiscReq id=0x17 magic=0xe0cb68]
Nov 12 22:34:24 kimmy pppd[9936]: rcvd [CHAP Challenge id=0x1 <7c2c8c8e00cabc94481272f65eb30ebb>, name = "UMTS_CHAP_SRVR"]
Nov 12 22:34:24 kimmy pppd[9936]: Warning - secret file /etc/ppp/chap-secrets has world and/or group access
Nov 12 22:34:24 kimmy pppd[9936]: sent [CHAP Response id=0x1 , name = "maxis"]
Nov 12 22:34:24 kimmy pppd[9936]: rcvd [LCP EchoRep id=0x0 magic=0xe0cb68 00 00 00 00]
Nov 12 22:34:24 kimmy pppd[9936]: rcvd [CHAP Success id=0x1 ""]
Nov 12 22:34:24 kimmy pppd[9936]: CHAP authentication succeeded
Nov 12 22:34:24 kimmy pppd[9936]: CHAP authentication succeeded
...
Nov 12 22:34:27 kimmy pppd[9936]: local IP address 121.120.187.27
Nov 12 22:34:27 kimmy pppd[9936]: remote IP address 10.64.64.64
Nov 12 22:34:27 kimmy pppd[9936]: primary DNS address 58.71.136.10
Nov 12 22:34:27 kimmy pppd[9936]: secondary DNS address 58.71.132.10
Nov 12 22:34:27 kimmy pppd[9936]: Script /etc/ppp/ip-up started (pid 9938)

That's not annoying enough. NetworkManager now marks my network as inactive unless I'm connected either to eth0 or wifi0, which I did not have to do in the past. The consequence? Every time when I start Firefox, it works offline.

I found out that there're other users that are facing similar issue, like in question #28829. I did not use the NetworkManager.conf workaround as suggested in the page since I'm not familiar with the dbus stuff, but looking at the file gave me a clue that running Firefox as root would fix the problem. That was right but who would want to do that? ;-)

A better solution would definitely be altering Firefox settings. Question #96 suggests to set network.online to true but it already is! Then I saw toolkit.networkmanager.disable and toggled it to true, restarted Firefox and.. Yes, this is the solution, it disables Firefox from consulting the NetworkManager.

Read the knowledge base if you want to know more about it.

- yc

Thursday, November 6, 2008

Profiling a Remote Application in Eclipse

I came across this guide which mentioned about attaching the Eclipse profiler to a remote Java application. I was stuck for some hours, asked my question in #java and #eclipse but got no response.. then, realized that, the instructions are old!

Instead, I visited the TPTP site, downloaded the Agent Controller and followed the instructions in this page to get things up and running. Basically,
  • Add $TPTP_AC_HOME/lib:$TPTP_AC_HOME/bin:$TPTP_AC_HOME/plugins/org.eclipse.tptp.javaprofiler to $LD_LIBRARY_PATH
  • Add $TPTP_AC_HOME/bin to $PATH
  • Run SetConfig.sh to configure the AC
  • Run ACStart.sh to start AC
  • Add '-agentlib:JPIBootLoader=JPIAgent:server=enabled;CGProf' to your JAVA_OPTS (ldd and nm are good commands)
  • Start your Java application
  • Profile and hook into the application by selecting "Attach to Agent" in the Eclipse's dialog
- yc

Friday, October 31, 2008

XML-RPC vs. SOAP vs. REST thoughts and Spring Beans

Recently I am working on the remote API side of my project, and the protocol that we chose is XML-RPC. Somewhere in two blogs returned by Google search suggested that REST > XML-RPC > SOAP. SOAP can only be considered for its wide enterprise adoption and protocol stack (with security management, transaction control, etc.) and therefore it is complicated. Yes, the person created XML-RPC wasn't an expert in XML but it's neat.

Why not REST then? I used to work on design and technical issues of Mule ESB and I was exposed to REST of its sweetness (the simplicity, the CRUD stuff) before more people started to talk about it (now they talk about Cloud). I learned that SOAP is for SOA (Service Oriented Architecture) and REST is for ROA (Resource Oriented Architecture). They are two different paradigms, and the purpose and design of these layers are therefore different, e.g. you don't carry a service/RPC mindset when you create a REST API.

So, no REST for now as IMO it requires more effort to design a proper API. Never I'll create SOAP due to its complexity.

What about JSON-RPC? I had a short discussion regarding this with @ditesh at #myoss@irc.freenode.net. I love JSON for its interoperability and speed (vs. XML parsing). But the available implementations turned me off pretty quickly, most of them stuck in year 2005~2007. For a publicly available remote API, a well-adopted and "mature" protocol is a much better choice.

What about the Spring beans stuff mentioned in the topic? I found the Apache XML-RPC server can't be integrated with Spring naturally (it has but not enough of bean property methods) and the API is quite ugly, e.g. XmlRpcSystemImpl.addSystemHandler() takes a PropertyHandlerMapping, why not XmlRpcListableHandlerMapping?

I took a similar approach suggested by Tomas Salfischberger in his blog and here they are:
  • An implementation of Spring's AbstractController.
  • An extension of PropertyHandlerMapping, this bean is used by the previous.

public class MyXmlRpcController extends AbstractController {
private XmlRpcServletServer server = new XmlRpcServletServer();
private boolean introspectionEnabled = false;

@Override
protected void initServletContext(ServletContext servletContext) {
super.initServletContext(servletContext);
if (this.introspectionEnabled) {
try {
XmlRpcSystemImpl.addSystemHandler((PropertyHandlerMapping) this.server.getHandlerMapping());
} catch (Exception e) {
}
}
}
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
this.server.execute(request, response);
return null;
}
@Required
public void setHandlerMapping(XmlRpcHandlerMapping serverHandlerMapping) {
this.server.setHandlerMapping(serverHandlerMapping);
}
public void setIntrospectionEnabled(boolean introspectionEnabled) {
this.introspectionEnabled = introspectionEnabled;
}
}

public class MyXmlRpcHandlerMapping extends PropertyHandlerMapping {
private Map serviceMap;

public void init() throws XmlRpcException {
this.load(Thread.currentThread().getContextClassLoader(), serviceMap);
}
@Required
public void setServicesMapping(Map serviceMap) {
this.serviceMap = serviceMap;
}
}


<bean id="xmlRpcHandlerMapping" class="my.MyXmlRpcHandlerMapping" init-method="init">
<property name="servicesMapping">
<map>
<entry key="membershipService" value="my.service.XmlRpcMembershipService"></entry>
</map>
</property>
</bean>
<bean id="urlHandlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<value>/xmlrpc=xmlRpcController</value>
</property>
</bean>
<bean id="xmlRpcController" class="my.MyXmlRpcController">
<property name="handlerMapping" ref="xmlRpcHandlerMapping"></property>
<property name="introspectionEnabled" value="true"></property>
</bean>


- yc

Thursday, September 18, 2008

Unable to open this mailbox

I just set up courier-imap on my machine but I couldn't open the INBOX:
2 SELECT INBOX
2 NO Unable to open this mailbox.
I thought it would be a permission problem but the dirs are set with 700. I also read that it could be the server's date time, which didn't seem to be the case at all.. I then bumped into this thread in the Ubuntu forum to find out that I should have used maildirmake command to create the maildir, bah.

- yc