Thursday, June 23, 2005
dynamic link in windows and linux
Quoted from

In Unix,
(1) .a :contains code from several object files (.o).
(2) .so :contains code to be used by the program, and also the names of functions and data that it expects to find in the program. When the file is joined to the program, all references to those functions and data in the file's code are changed to point to the actual locations in the program where the functions and data are placed in memory. This is basically a link operation.

In Windows, there are three types of library, a static library and an import library (both called .lib) and a dynamic-link library(.dll).

(1) .dll file has a lookup table. An access from DLL to functions or data in the program goes through a lookup table. So the DLL code does not have to be fixed up at runtime to refer to the program's memory; instead, the code in DLL already uses the DLL's lookup table, and the lookup table is modified at runtime to point to the functions and data.

(2) A static library is like a Unix .a file; it contains code to be included as necessary.

(3) An import library is basically used only to reassure the linker that a certain identifier is legal, and will be present in the program when the .dll is loaded. So the linker uses the information from the import library to build the lookup table for using identifiers that aren't included in the .dll. When an application or a .dll is linked, an import library may be generated, which will need to be used for all future .dll's that depend on the symbols in the application or .dll.

I call the following scenario The diamond puzzle:
A program Aa needs two dynamic linked libraries, say, Db and Dc. These two libraries share a common static library Sd. In linux, this situaion causes Sd to be linked into Aa twice which will lead to name confliction error. While in windows, this puzzle could be solve by import library since the code in Sd is not copied into Db or Dc. Only the reference information is copied.

Wednesday, June 22, 2005
IBM eServer Blade usage
  1. The host name for each blade for IBM BladeCenter is in the format ibXXbYY, XX is the chassis id and YY is the blade id in the chassis
  2., using user name: USERID password: PASSW0RD (Note, it's ZERO not O in the password)
  3. For remote console, click Remote Control under "Blade Tasks" on the left, it will open a seperate window, then you can select the right blade to control on the top of the window (in the pulldown list of "Change KVM owner")
  4. For Reboot, power on and off, click Power/Restart under "Blade Tasks" on the left, click the check boxes of the blades which you want the power operation, then click the corresponding link below.
  5. For boot from Linux to Windows, modify the file /etc/grub.conf, change the "default" from "0" to "2"
  6. Install software from \\dharma\softwares

Friday, June 17, 2005
Makefile and script
1. Commit : cvs co "module name"
2. Update: cvs up "module name" -d
3 Check in: cvs ci -m "comments" "file name"

1. Command with a leading Dash (-)

A make will terminate if any command returns a failure sta- tus. That's why you see rules like:
-rm *.o *~ core paper
Make ignores the returned status on command lines that begin with a dash. eg. who cares if there is no core file?

2. Using @ to turn off the command echo

for example: @echo "stuff"
or @if ...


4. using environment variable as branch condition instead of if...then...else
#ARCH includes w2k and linux
#TYPE includes static and dynamic

ARCH = w2k
TYPE = static

#pre_w2k_static will be triggered
all: pre_$(ARCH)_$(TYPE)

#four scenarios
@echo "w2k static"
@echo "w2k dynamic"
@echo "linux static"
@echo "linux dynamic"

1. set arg arg ...
Set the positional variables to the argument list.
For example

 TODAY=`(set \`date\`; echo $1)`
2. using cat to generate a file
cat > xgnu.c </*tell shell to automatically close input for us*/
#ifdef __GNUC__yes;#endif
EOF /*tell shell that we are finished with input*/

3. use gcc -E to only process pre-process command like #if...#endif
gcc -E xgnu.c
4. $? is the return value of command, 0 stands for success, 1 for failure
5. if .command1. then command2 else command3 fi
when command1 return 0, command2 will be executed
when command1 return 1, command3 will be executed
(Weird? It is the opposite to C/C++ if...then...else
in C/C++ if the conditional expression returns non-zero, 
the "then" part will be exectued)

Thursday, June 16, 2005
asynchronous messaging in gSoap
1. Define asynchronous style messaging interface. The point is use Void as the last parameter. gSoap will take it as the output by default. Since the output is a void, gSoap will generate asynchronous codes for this head file.

//gsoap ns service name: Calc service
//gsoap ns service style: document
//gsoap ns service encoding: literal
//gsoap ns service namespace:
//gsoap ns service location: http://localhost:2005

//gsoap ns schema namespace: urn:AsynCalc

//gsoap ns service method-action: Evaluate according to "CalcType"
int ns__AsynCalc(int opA, int opB, enum ns__CalcType calcType, int calcResult, void);

2. On server side
(1) create soap with SOAP_IO_KEEPALIVE
/*From the source code in stdsoap2.cpp, we will see soap_closesock() will not close the socket if this flag is set. */

(2) In the event handling function
int ns__AsynCalc(struct soap *soap, int opA, int opB, enum ns__CalcType calcType, int calcResult)

<1> (option) using soap_send_empty_response() to notify the receipt of request.
<2> using soap_send_ns__AsynCalc() which is defined in client side code "soapclient.cpp" to send the result back to the client. Note: both the server and the client will use the same XML message schema (defined in WSDL as input message)
And since the socket is kept alive, we dont need to specify the endpoint URL and action, e.g.
soap_send_ns__AsynCalc(resp, "http://", NULL,opA,opB,calcType,m_result);

3. On the client side
(1) create soap with SOAP_IO_KEEPALIVE
(2) using soap_send_ns__AsynCalc() to send the asynchronous request to the server, e.g.,
soap_send_ns__AsynCalc( &soap,__endpoint,__action,opA,opB,CALC_ADD,result);
(3) At some point, if the client wants to fetch the response back, it will call
Note: Since this function is non-blocking, the client needs to check the receiving status in a loop or something like that.

struct ns__AsynCalc response;
for (;;)
if (!soap_valid_socket(soap.socket))
fprintf(stderr,"connection was terminated\n");
if (soap_recv_ns__AsynCalc(&soap,&response))
if (soap.error == SOAP_EOF)
fprintf(stderr,"connection was gracefully closed by server\n");
fprintf(stderr,"result = %d\n",response.calcResult);

Friday, June 10, 2005
Symphony Experience
You can find the Symphony Taiga release package under:

/* I am using following documents to guide the my exercise */


(0) Preparation
(1) install j2sdk1.4.1_01 to /home/puliu
(2) add lines to .login file
setenv CVSROOT :pserver:puliu@cvssrv:/cvs/CVS
setenv JAVA_HOME /home/puliu/j2sdk1.4.1_01
setenv JAVACMD $JAVA_HOME/bin/java
(3) cvs -co symphony
(4) copy the appropriate Make.def file from /home/puliu/symphony/config to its parent directory /home/puliu/symphony. For the cluster in Linux, we used Make.def.linux2.4-gcc3.2-x86 as Make.def

/* It was when I tried command "Make" that I was advised to install JDK */

(1) Compile & Make distribution trees and tars
(1) login into qa4 as root
/* qa4 happened to have all the neccessary files for compilation */
(2) run "make"
/* actually got error message for not installing JDK which failed the ANT compilation. So I returned to install JDK and set the appropriate environment variables in .login file */
(3) run "make help" to get the make options
(4) run the following commands
make brelease_symphony - main distrib tree
make brel_symphony_tar - main dustrib tar
make brel_cli_tar - CLI pacakge
make brel_symphony_setup - installer
make brelease_GUI - GUI distrib tree
make brel_GUI_tar - GUI tar file

and generate the following tar files and correspondent directories


/* It takes time for me to figure out what components I need to make when I tried to run sym2.2_install. It stopped many times to warn me that I am missing some tar files */

(5) get into directory sym2.2_install and modify install.conf file as follows:


When I tried to install symphony in my home directory, I met with the disk quota full error. Thanks to Jun Zhu who told me to install it to /scratch/dev5. /scratch/dev5 is a NFS directory, and under it we created the directory puliu/symphony. It is strange that we need to "ls dev5" to see it.

(6) prepare license file
copy /pcc/lsfqa-trusted/Standard_Code/license/ to

/* Thanks to Jun Zhu who got the license file to me*/

(7) in direcrory sym2.2_install
run "syminstall"

/*At the first try, one of the host failed (qa3 as SSM), is there any easy way to re-deploy symphony without re-installation? I had to remove the installed package and repeated installation again after making the change in config file*/

(3) Run addHost on each hosts
[root@qa5 puliu]# . /scratch/dev5/puliu/symphony/conf/profile.lsf
[root@qa5 puliu]# addHost

Logging installation sequence in /scratch/dev5/puliu/symphony/2.2/install/Install.log
Adding Symphony init file ...

Adding Symphony Console init file ...

Copying /etc/rc.d/init.d/symconsole, /etc/rc.d/rc3.d/S95symconsole and /etc/rc.d/rc2.d/K05symconsole

... Symphony host setup is done.

Host qa5 already exists in the cluster configuration
file lsf.cluster.symphony.

Staying with previous configuration ...

[root@qa4 puliu]# . /scratch/dev5/puliu/symphony/conf/profile.lsf
[root@qa4 puliu]# addHost

Logging installation sequence in /scratch/dev5/puliu/symphony/2.2/install/Install.log
Adding Symphony init file ...

Adding Symphony Console init file ...

Copying /etc/rc.d/init.d/symconsole, /etc/rc.d/rc3.d/S95symconsole and /etc/rc.d/rc2.d/K05symconsole

... Symphony host setup is done.

Host qa4 already exists in the cluster configuration
file lsf.cluster.symphony.

Staying with previous configuration ...

[root@qa2 puliu]# . /scratch/dev5/puliu/symphony/conf/profile.lsf
[root@qa2 puliu]# addHost

Logging installation sequence in /scratch/dev5/puliu/symphony/2.2/install/Install.log
Adding Symphony init file ...

Adding Symphony Console init file ...

Copying /etc/rc.d/init.d/symconsole, /etc/rc.d/rc3.d/S95symconsole and /etc/rc.d/rc2.d/K05symconsole

... Symphony host setup is done.

Host qa2 already exists in the cluster configuration
file lsf.cluster.symphony.

Staying with previous configuration ...

[root@qa1 puliu]# . /scratch/dev5/puliu/symphony/conf/profile.lsf
[root@qa1 puliu]# addHost

Logging installation sequence in /scratch/dev5/puliu/symphony/2.2/install/Install.log
Adding Symphony init file ...

Adding Symphony Console init file ...

Copying /etc/rc.d/init.d/symconsole, /etc/rc.d/rc3.d/S95symconsole and /etc/rc.d/rc2.d/K05symconsole

... Symphony host setup is done.

Host qa1 already exists in the cluster configuration
file lsf.cluster.symphony.

Staying with previous configuration ...

(4) Start Platform Symphony

puliu@qa5-8: source /scratch/dev5/puliu/symphony/conf/cshrc.lsf
puliu@qa5-9: symstartup -all
Starting up LIMs on all ...
Start up LIM on ...... done
Start up LIM on ...... done
Start up LIM on ...... done
Start up LIM on ...... done

Starting up RESes on all ...
Start up RES on ...... done
Start up RES on ...... done
Start up RES on ...... done
Start up RES on ...... done

Starting up slave daemons on all LSBATCH hosts ...
Start up slave batch daemon on ...... done
Start up slave batch daemon on ...... done
Start up slave batch daemon on ...... done
Start up slave batch daemon on ...... done

Done starting up Symphony daemons on the local cluster ...

(5) Start the Management Console
puliu@qa4-2: source /scratch/dev5/puliu/symphony/conf/cshrc.lsf
puliu@qa4-3: symguistartup
Failed to start the Tomcat web server. Port(s) 8005 is(are) already in use.
The Symphony Management Console uses the port(s). Change the port number in /scratch/dev5/puliu/symphony/2.2/gui/jakarta-tomcat-4.0.4/conf/server.xml
and tyr it again.
puliu@qa4-4: vi /scratch/dev5/puliu/symphony/2.2/gui/jakarta-tomcat-4.0.4/conf/server.xml
Server port="8005" shutdown="SHUTDOWN" debug="0"
Server port="8885" shutdown="SHUTDOWN" debug="0"
puliu@qa4-5: symguistartup
Using CATALINA_BASE: /scratch/dev5/puliu/symphony/2.2/gui/jakarta-tomcat-4.0.4
Using CATALINA_HOME: /scratch/dev5/puliu/symphony/2.2/gui/jakarta-tomcat-4.0.4
Using CATALINA_TMPDIR: /scratch/dev5/puliu/symphony/2.2/gui/jakarta-tomcat-4.0.4/temp
Using JAVA_HOME: /scratch/dev5/puliu/symphony/2.2/gui/j2sdk_1_4_1_01/linux_i586

(6) Log on to the Management Console
use browser to open url

use userID: Administrator and Password: Administrator
automatically redirected to change password : 666666

Got the following info
1. Platform Symphony Client Port:

./runJavaClient SampleClient -w -q Sample
./sampleAPI -w -q Sample -u sampleOperator -p sampleOperator

Code <2>: Failed to get the address for Session manager from the soapserver. Check specified soapserver URL. Reason address(timeout)>.

Wednesday, June 08, 2005
Platform Symphony CVS setting
1. Set CVSROOT environment variable in .login file, remember to replace userID with appropriate value
setenv CVSROOT :pserver:userID@cvssrv:/cvs/CVS
or if you can not successfully ping host 'cvssrv'
setenv CVSROOT

2. For Tundra design CVS repository
cvs co design/symphony/tundra (first time)
cvs update (afterwards,make sure you are in the cvs directory e.g. with the cvs subdirectory)

3. For Taiga CVS repository
cvs co symphony (first time)
cvs update (afterwards, make sure you are in the cvs directory e.g. with the cvs subdirectory)

4. Using wincvs
(1) download wincvs from

(2) install wincvs, just following the installation instructions

(3) Menu-->[Admin]-->[login...]--> set CVSROOT to the right value (see step 1.) -->input your password

(4) Menu-->[Remote]-->[checkout module...]-->set module name (see step 2.) and CVSROOT and local directory name--> click ok and done

Tuesday, June 07, 2005
SOC/SOA website, everything you need
what is SOA, an introduction
Author: R. Kodali BLOG (

Friday, June 03, 2005
Using gsoap in .NET visual studio

From .h file, create server side project
(1) Project propery setting
[Menu Project]-->[Property]
<1> Turn off pre-compiled headers
[C/C++]-->[Precomplied Headers]-->
set [Create/Use Precomplied Headers] to "Not Using Precompiled Headers"

<2> Win32 builds need "wsock32.lib"
set [additional depedencies] to "wsock32.lib"
--> check the setting by
[Configuration Properties]-->[Linker]-->[commandline] to see if "wsock32.lib" is in the command line

<3> Add gSoap home directory to the include path
[C/C++]-->[General]-->set [Additional Include Directories] to gSoap Home Directory

(2) Specify a custom build step for .h file.
<1> Set gSoap tools path
[Menu Tools]-->[Options]-->[Projects]-->[VC++ Directories]-->
add gSoap Home directory

<2> Create the .h file and Right-click it
[properties]-->[Custom Build Step]-->[Commond Line]-->
Enter 'soapcpp2.exe "$(inputPath)"' --> [output] -->
Enter 'soapStub.h soapH.h soapC.cpp soapClient.cpp soapServer.cpp soapClientLib.cpp soapServerLib.cpp'

(3) Add gSoap files to projects
source files
1. stdsoap2.cpp [gsoap runtime in gsoap home directory]
2. soapServerLib.cpp [server library in project directory]
3. soapC.cpp [serialize/de-serialize library in project directory]
header files
1. soapH.h [project directory]

(4) write implementation functions in a separate CPP file
copy the definition from soapStub.h [Service Operations]
for example

/****************************************************************************** * *
* Service Operations *
* *

SOAP_FMAC5 int SOAP_FMAC6 mcws__installCode(struct soap*,
struct xsd__base64Binary *code,
struct mcws__retValue &result);

SOAP_FMAC5 int SOAP_FMAC6 mcws__invokeCode(struct soap*,
char *name,
struct mcws__retValue &result);

Then you can create the implementation in the CPP file

#include "soapH.h"

int mcws__installCode(struct soap*,
struct xsd__base64Binary *code,
struct mcws__retValue &result)
return SOAP_OK;
int mcws__invokeCode(struct soap*,
char *name,
struct mcws__retValue &result)
return SOAP_OK;

All the data structures are also defined in soapStub.h

(5) add including files in main.cpp
#include "soapH.h"
#include "MySoapService.nsmap"

#include "soapH.h"
#include "Mcws.nsmap"
int main()
struct soap soap;
int m, s; // master and slave sockets
m = soap_bind(&soap, "localhost", 20065, 100);
if (m < 0)
soap_print_fault(&soap, stderr);
fprintf(stderr, "Socket connection successful: master socket = %d\n", m);
for (int i = 1; ; i++)
s = soap_accept(&soap);
if (s < 0)
soap_print_fault(&soap, stderr);
fprintf(stderr, "%d: accepted connection from IP=%d.%d.%d.%d socket=%d", i,
(soap.ip >> 24)&0xFF, (soap.ip >> 16)&0xFF, (soap.ip >> 8)&0xFF, soap.ip&0xFF, s);
if (soap_serve(&soap) != SOAP_OK) // process RPC request
soap_print_fault(&soap, stderr); // print error
fprintf(stderr, "request served\n");
soap_destroy(&soap); // clean up class instances
soap_end(&soap); // clean up everything and close socket
soap_done(&soap); // close master socket and detach environment

From wsdl file, create client side project
(1)generate serviceDef.h
1. copy typemap.dat from gsoap home directory
2. copy generated wsdl file from service project directory
3. run "wsdl2h -o serviceDef.h mySoapService.wsdl"

(2) see project settings above

(3) repeat the steps above to generate gsoap files or simply
copy files "soapH.h soapC.cpp soapStub.cpp soapClient.cpp soapClientLib.cpp soapMySoapServiceProxy.h MySoapService.nsmap" to client project directory from service project directory.

(4) add including files
#include "soapMySoapServiceProxy.h"
#include "ns.nsmap"

tri-layer web services architecture

Three main components:

1. Clients

2. Service Servers

3. Implementation Components

service server will act as follows:

1. Accept requests in SOAP messages from clients.

2. gSoap library functions will dispatch the request to correspondent handling functions. At this point, the soap message is de-serialized to native C/C++ data.

3. The handling functions will invoke the implementation components at the back end which will perform the actual operations to the requests.

4. The implementation components will then return the processed results in the form of XML which is part of the payload of returned SOAP payload.

5. The handling functions will wrap up the returned XML data to the SOAP payload and send it back to clients to fulfill the web service requests.

Wednesday, June 01, 2005
Platform Inc. wireless setting
1. SSID: Platform1t
2. Security Encryption: 802.1x/LEAP
3. Data Encryption: WEP
4. domain: NOAM
5. WINS:
6. Append these DNS suffixes
7. unix machine: qa1, qa2,...,qa5
8. software machine: dharma

Some interesting questions
1. How to insert an element into a sorted array? (specify what you need)
2. How can you reverse a linked list? Why do you need this operation? Can you do it in O(1) time without extra memory? What happened if it is a double linked list? Do we need this operation? Why?
3. Design a scalable hashtable which can contain millions of entries dynamically.
4. Design a queue data structure. What if the queue is dynamic?
5. Design the data structure for Maps & Streets targeted to PADs and smart phones.
6. Given 1G memory, how will you sort a 2G array contained in a file on the disk?

Now in Toronto
50 Aurora CRT, Suite 401
, ON M1W2M6

Tel. 416 4931041 (home)
905 948 4339 (office)

Access Code: 36
Cube: 3-40

Powered by Blogger