Thursday, April 26, 2007

Compile maze client error

Recently, I reinstalled my Windows XP system because of virus. Then I installed the Borland C++ builder to compile and build maze client. However, error occurred during compiling.
Firstly, what should do is described here http://zhenhua-guo.blogspot.com/2006/12/compile-and-build-maze-client.html.
However, I don't know why the shellctrl component in C++ builder is different from my previous one. I used my previous shellctrl component because it worked well before I reinstalled my system.

When compiling, error occurred:
in crtdbg.h,
__inline int __ASSERTE_Helper(bool expr, char *file, int line){
TCHAR msg[256*2];
::wsprintf(msg, _T("%s failed - %s/%d"), expr, file, line);/* throw (msg); */
_ErrorExit(msg); return 0;
/* Never really gets here */}
error message: call to undefined function _T.

I searched the _T in BCB, I found that this is a macro which is defined in file tchar.h.
So I tried to add this line "#include " to file crtdbg.h and it worked.

However, another error occurred: unable to open file dclusr.lib.
In the "Lib" directory which is in the directory where you install BCB, there is a package called "dclusr.bpk". Then I compiled and installed this package.
After all, I can successfully compiled and built Maze client.

Saturday, April 21, 2007

Why search function does not work?

After I copy all code to gridfarm001 and run all maze server components, I found that search functionality does not well. However, in my lab linux machine, search functionality works!! There must be something wrong.
I checked for a long time. At last, I found out the reason. In IndexSvr.cpp file, the heartbeat server ip address is hard coded. I must change it manually to the corresponding ip address of gridfarm001.
Note: the port number if also hard coded, so if the port number in client configuration file is modified this port number must be modified as well.

Thursday, April 19, 2007

Status Report for Date 04/06/2007 to Date 04/19/2007

I installed the search components at server.
To support functionality of search, a http server is needed. So I installed apache in gridfarm001 and it listens at port 1983.
Program ftpsearch.exe is a CGI program that is used to handle the search request from clients. I configured the cgi-bin directory used by apache and put ftpsearch.exe into that directory.
Configuration file for ftpsearch.exe: bingle.conf. The format of this file is described on http://zhenhua-guo.blogspot.com/2006/11/search-engine-in-maze.html

One xml file needed by ftpsearch.exe: xmlresult.xml.
<?xml version="1.0" encoding="GB2312"?>
<TianwangSearch>
<Word></Word>
<ElapseTime></ElapseTime><
ResultNum></ResultNum><
FirstResultID></FirstResultID>
<LastResultID></LastResultID>
<SortType></SortType>
<ResultList></ResultList>
<Copyright></Copyright>
</TianwangSearch>
Then Inexer was run manually to build index for collection of directory information of clients.
IndexSvr provides search functionality in fact and it is used by ftpsearch.exe to get result.
Detailed description:
http://zhenhua-guo.blogspot.com/2006/11/memorandum-for-maze.html
Note: after running Indexer, three new files tmpcontent.dat, tmpdisplay.dat, tmpindex.dat are generated at the basepathn directory. And these files need to be renamed to content.dat display.dat and index.dat respectively.

So far, I successfully installed all server components in Gridfarm001.

Maze client program:
I checked every source file and resource file to see whether there are Chinese characters in these files. I translated all Chinese characters into English. However, it is not so simple.
For example, to translate a Chinese word "目录" which means directory into English, I can use "Directory", "directory", "dir", "Dir", etc. In English there is lower case and upper case, which is different from Chinese. I must be careful, or else it may incur strange behaviors of Maze client.

For example:
Original Program:
string str="收集目录";
string str2=str;
//losts of source code here
if( str2=="收集目录" )
do something; //this expression should be executed at run time

Wrong translation:
string str="Collect Directory";
string str2=str;
//lots of source code here
if( str2=="collect directory" )
do something;

These kind of associations are hard to discover because it is possible that two expressions are interralted through several intermediate expressions.
To avoid possible errors, I keep the translation consistent, including upper/lower case. Although I am very careful during translation, it is still possible that some indetectable flaws appear.

So, in next step, test for Maze Client is necessary to guarantee the correctness.

Thursday, April 05, 2007

Status Report for Date 02/08/2007 to Date 04/05/2007

Recently, I am working on migrating Maze Server from my lab desktop linux machine to our new server.
prerequisite:
Library stlport is needed by Maze server programs. So, firstly, I tried to build stlport on our server--gridfarm001. In Maze's documents, there is no description about the building of stlport. As a result, I built it as usual. I tried to build stlport-5.1.3, stlport-5.0.2, stlport-4.6.2. Every time I could build library stlport successfully. However, when I compiled and linked Maze server programs, link errors appeared. From my experience, the source of failure was the configuration of stlport. In other words, I should modify some config files of stlport before building to satisfy the requirement of Maze. I looked up solution on the internet, which did not help a lot. Then I carefully read the documents of Stlport. After lots of trials, I solved this problem. I used Stlport-5.0.2, which can be obtained at http://sourceforge.net/project/showfiles.php?group_id=146814.
Then this file--stlport/stl/_site_config.h must be modified by adding one line:
#define _PTHREADS.
This seems simple. However, it took me lots of time to find out the solution.
Build Maze:
Because layout of the source files is chaotic, I reorganized the directory tree to make it clear and readable. I separated the server programs from client programs and constructed an individual tarball for server programs. Then I wrote a bash script to generate the files and directories needed to run Maze servers. After that, I built Maze servers.
Note:
1) Makefiles used to build Maze servers must be modified to indicate location of library stlport and the location of header files!! (-L and -I options)
2) To run Maze server, LD_LIBRARY_PATH must be set to contain the directory where library stlport is located.
Potential Problems during Building:
(1) special characters
(a)Some source files were written in Windows, so it is possible some srouce files have different line-break characters(\n or \r\n) from unix standard. Some compilers may handle these characters correctly while other compilers may not compile successfully. So, if strange compile error messages are displayed, it may result from this reason.
(b) some comments in Maze Programs are written in Chinese, and it may span several lines. It is possible that some compilers can not handle these characters correctly because they do not support Chinese character encoding.
(2)Some directories are hard coded in source file.
This directory--/home/maze/resource/ is used to store the directory information of users. It is hard coded in file DServer/Server.cpp. I changed it to point to my directory.

Ports Used:
By default, the HeartBeatSvr listens at ports 974. In linux, those ports that are below 1024 can not be used by general user. In other words, only root can listen those ports. So, I change the port to 1974.
UserSvr: 30604
DirServer:30605
HeartBeatSvr:1974 and 30607

Start Up servers:
(1) copy HearBeatSvr, DirServer, UserSvr to maze/bin directory;
(2) create heartbeat.log, log.txt, punishs.dat, traffic.log, userdb.dat
details:
UserSvr needs: userdb.dat
HeartBeatSvr needs: log.txt(write log), heartbeat.log(restart records for HeartBeatSvr)
(3) copy a config.xml to maze/bin. This file is needed by HeartBeatSvr
(4) Start up server:
./UserSvr
./HeartBeatSvr &
./DirServer &

building Enviroments:
my desktop:
gcc version 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)
gridfarm001:
gcc version 3.3.2 20031022 (Red Hat Linux 3.3.2-1)

Next step:
run programs that supports building index and search.