Java程序优化过程及linux相关

March 5th, 2010

1.Jprofile找到程序性能的瓶颈
2.需要很长时间完成的过程由单线程转多线程或线程池。假如是IO之类的问题(普遍IO是系统的瓶颈),采用NIO即rector模式处理
3.大量小文件压缩后存入内存,定量写入硬盘。大量中间变量存入内存,或序列化压缩后存入内存,后解压反序列化调用
4.使用Queue进行不同过程的缓冲
5.Linux下普遍有打开文件个数限制,消除1024限制:ulimit -n 8192
6.JVM普遍内存限制,消除内存限制:增加运行参数 -Xms20m -Xmx200m

另:
1.如何执行jar中某个类的main方法: java -cp test.jar com.acosys.clawer.GetContent
2.如何让java程序在linux后台运行: nohup … &
3.如何查看linux后台运行的nohup程序列表: jobs
4.后台FTP上传下载工具: ncftpget ncftpput
5.如何查找linux后台程序列表 ps aux | grep …
6.强行终止linux程序: kill -9 …
7.查某文件夹下文件数目: ls -l |grep “^-”|wc -l
8.执行多个依赖库的java程序:java -cp nutch-1.0.jar:commons-logging-1.0.4.jar:hadoop-0.19.1-core.jar:xerces-2_6_2.jar org.apache.nutch.tools.DmozParser content.rdf.u8 > domz/urls

Google对信息的索引已经接近实时了

March 1st, 2010

请看最新添加的1篇博客文章的索引时间。

目前博客发表一篇文章,在1分钟之内即可在google内搜索到,也许Google对博客提高了实时性。

Java nio 实现的爬虫性能

March 1st, 2010

这两天用NIO实现的爬虫,本机测试一下。
Test result:
————————–
Transfer: 3.66 MB
Complete content: 64
Peak connection num: 50
Used 24807 ms

Scrapy-优秀的网页信息解析框架

February 25th, 2010

最近在做world wide数据信息的分析,偶然发现这个不错的工具。

Scrapy是用python语言写的网页信息抓取和解析的框架,可以用来采集网页然后导出格式化的数据。很多地方可以用到Scrapy比如数据挖掘或者数据监控以及自动化测试。

特别适合针对目标网站的信息采集以及有用信息的监控。你只需要写出需要解析的数据的规则,Scrapy就能从整个网站获取你需要的信息。据官方网站介绍Scrapy能分析500多个网站每天每台服务器。而且它的扩展性很好,可以轻松的做自己的定制。现在很多商业网站都用了这个100% 用Python写的工具。Python的东西总是看起来很灵巧,敏捷。

网站上有完整的简单应用的例子。抓取的信息的规则可以用Xpath来写。

Scray是我最近发现的最优秀的银弹之一。

How to change Collation of tables or data in mysql

February 23rd, 2010

The default collation in mysql is not always utf-8. Because the company of mysql localed in Sweden, so the encoding or collation is latin1_swedish_ci by default. You should change this feature after you installed the mysql DB server. But If you have  operated your web site for a long time, then you want to update your site for reasons. There are lots of data existed in Mysql in the encoding latin or other not UTF8. How to change the encoding or Collation to UTF-8 ?

Just download this tool to change the collation of tables or data to UTF8:

http://www.phoca.cz/phoca-changing-collation/

The Phoca Changing collation tool changes the database collation of database, tables and columns. And it is easy to use.