posts - 72, comments - 66, trackbacks - 0, articles - 0

View cpu information command:
1 # dmesg | grep CPU
2 # cat /proc/cpuinfo

you can find the following from the show :AMD Athlon(tm) 64 X2 Dual Core Processor 4000+
It tell you :64bit cpu

View OS version:
# cat /proc/version
you can see information similar to the following:
Linux version 2.6.24-21-generic (buildd@palmer) (gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu7)) #1 SMP Tue Oct 21 23:43:45 UTC 2008

View OS bit num:
# getconf LONG_BIT
you can see :32 or 64.


posted @ 2009-02-26 10:42 Fingki.li 阅读(332) | 评论 (0)编辑 收藏

     摘要: If you install im gateway plugin firstly, perhaps you did not encounter this problem.
If you upgrade your im gateway plugin, perhaps you have been in trouble.
Unfortunately,I encountered this problem some days ago.
I used the openfire 3.4.5, and it contains the gateway plugins;  阅读全文

posted @ 2009-02-25 16:58 Fingki.li 阅读(1763) | 评论 (0)编辑 收藏

     摘要: sudoer application Launcher
On Ubuntu,run applications as sudo via Application Launcher  阅读全文

posted @ 2009-02-23 12:33 Fingki.li 阅读(1296) | 评论 (0)编辑 收藏

JSCalendar 日历控件 使用样例如下:

<html>
<head>
    <style type="text/css">@import url( /js/jscalendar/calendar-win2k-cold-1.css );</style>
    <script type="text/javascript" src="/js/jscalendar/calendar.js"></script>
    <script type="text/javascript" src="/js/jscalendar/i18n.jsp"></script>//不用i18n可以指定语言 如:<script type="text/javascript" src="/js/jscalendar/lang/calendar-en.js"></script>
    <script type="text/javascript" src="/js/jscalendar/calendar-setup.js"></script>
</head>
<body>
<input type="text" size="10" name="fromDate" id="fromDate" maxlength="10" onchange="checkSpecific();" value=""/>
<img src="images/icon_calendarpicker.gif" id="fromDateCal" />
<br>
<script type="text/javascript" >
    Calendar.setup(
    {
        inputField  : "fromDate",       // ID of the input field
        ifFormat    : "%m/%d/%Y",       // the date format
        button      : "fromDateCal",    // ID of the button
    });
</script>
</body>
</html>
上述示例代码在jsp容器中运行完全正常。

posted @ 2009-02-17 15:35 Fingki.li 阅读(2697) | 评论 (10)编辑 收藏

当一个类实现了序列化接口,有时会遇到 java.io.InvalidClassException 异常出现:
java.io.InvalidClassException: com.test.Test; local class incompatible: stream classdesc serialVersionUID = 7981560250804078637, local class serialVersionUID = -8334405535174160822
这是序列化兼容性所致;
java通过一个名为UID(stream unique identifier)来控制,这个UID是隐式的,它通过类名,方法名等诸多因素经过计算而得,理论上是一一映射的关系,也就是唯一的。如果UID不一 样的话,就无法实现反序列化了,并且将会得到InvalidClassException。
当要人为的产生一个新的版本(实现并没有改动),而抛弃以前的版本的话,可以通过显式的声名UID来实现:
private static final long serialVersionUID=????;//(你可以编造一个UID,但不能有重复)

对于上例我们可以在com.test.Test类中加入 :
private static final long serialVersionUID=7981560250804078637l;
这样就解决了新老版本的兼容性问题。
当然,对于序列化还有很多问题,慢慢研究吧。

posted @ 2009-01-13 11:46 Fingki.li 阅读(17563) | 评论 (3)编辑 收藏

对volatile,看到了个很清楚的解释,摘录下来如下:

volatile关键字有什么用?
恐怕比较一下volatile和synchronized的不同是最容易解释清楚的。volatile是变量修饰符,而synchronized则作用于一段代码或方法;看如下三句get代码:

  1. inti1;              intgeti1(){returni1;}
  2. volatile inti2;              intgeti2(){returni2;}
  3.          int i3; synchronizedintgeti3(){returni3;}

  geti1()得到存储在当前线程中i1的数值。多个线程有多个i1变量拷贝,而且这些i1之间可以互不相同。换句话说,另一个线程可能已经改 变了它线程内的i1值,而这个值可以和当前线程中的i1值不相同。事实上,Java有个思想叫“主”内存区域,这里存放了变量目前的“准确值”。每个线程 可以有它自己的变量拷贝,而这个变量拷贝值可以和“主”内存区域里存放的不同。因此实际上存在一种可能:“主”内存区域里的i1值是1,线程1里的i1值 是2,线程2里的i1值是3——这在线程1和线程2都改变了它们各自的i1值,而且这个改变还没来得及传递给“主”内存区域或其他线程时就会发生。
而geti2()得到的是“主”内存区域的i2数值。用volatile修饰后的变量不允许有不同于“主”内存区域的变量拷贝。换句话说,一个变量经 volatile修饰后在所有线程中必须是同步的;任何线程中改变了它的值,所有其他线程立即获取到了相同的值。理所当然的,volatile修饰的变量 存取时比一般变量消耗的资源要多一点,因为线程有它自己的变量拷贝更为高效。
既然volatile关键字已经实现了线程间数据同步,又要synchronized干什么呢?呵呵,它们之间有两点不同。首 先,synchronized获得并释放监视器——如果两个线程使用了同一个对象锁,监视器能强制保证代码块同时只被一个线程所执行——这是众所周知的事 实。但是,synchronized也同步内存:事实上,synchronized在“主”内存区域同步整个线程的内存。因此,执行geti3()方法做 了如下几步:
1. 线程请求获得监视this对象的对象锁(假设未被锁,否则线程等待直到锁释放)
2. 线程内存的数据被消除,从“主”内存区域中读入(Java虚拟机能优化此步。。。[后面的不知道怎么表达,汗])
3. 代码块被执行
4. 对于变量的任何改变现在可以安全地写到“主”内存区域中(不过geti3()方法不会改变变量值)
5. 线程释放监视this对象的对象锁
因此volatile只是在线程内存和“主”内存间同步某个变量的值,而synchronized通过锁定和解锁某个监视器同步所有变量的值。显然synchronized要比volatile消耗更多资源。

附英文原文:
What does volatile do?

This is probably best explained by comparing the effects that volatile and synchronized have on a method. volatile is a field modifier, while synchronized modifies code blocks and methods. So we can specify three variations of a simple accessor using those two keywords:

  1. inti1;              intgeti1(){returni1;}
  2. volatile inti2;              intgeti2(){returni2;}
  3.          int i3; synchronizedintgeti3(){returni3;}

geti1() accesses the value currently stored in i1 in the current thread. Threads can have local copies of variables, and the data does not have to be the same as the data held in other threads. In particular, another thread may have updated i1 in it’s thread, but the value in the current thread could be different from that updated value. In fact Java has the idea of a “main” memory, and this is the memory that holds the current “correct” value for variables. Threads can have their own copy of data for variables, and the thread copy can be different from the “main” memory. So in fact, it is possible for the “main” memory to have a value of 1 for i1, for thread1 to have a value of 2 for i1 and for thread2 to have a value of 3 for i1 if thread1 and thread2 have both updated i1 but those updated value has not yet been propagated to “main” memory or other threads.

On the other hand, geti2() effectively accesses the value of i2 from “main” memory. A volatile variable is not allowed to have a local copy of a variable that is different from the value currently held in “main” memory. Effectively, a variable declared volatile must have it’s data synchronized across all threads, so that whenever you access or update the variable in any thread, all other threads immediately see the same value. Of course, it is likely that volatile variables have a higher access and update overhead than “plain” variables, since the reason threads can have their own copy of data is for better efficiency.

Well if volatile already synchronizes data across threads, what is synchronized for? Well there are two differences. Firstly synchronized obtains and releases locks on monitors which can force only one thread at a time to execute a code block, if both threads use the same monitor (effectively the same object lock). That’s the fairly well known aspect to synchronized. But synchronized also synchronizes memory. In fact synchronized synchronizes the whole of thread memory with “main” memory. So executing geti3() does the following:

1. The thread acquires the lock on the monitor for object this (assuming the monitor is unlocked, otherwise the thread waits until the monitor is unlocked).
2. The thread memory flushes all its variables, i.e. it has all of its variables effectively read from “main” memory (JVMs can use dirty sets to optimize this so that only “dirty” variables are flushed, but conceptually this is the same. See section 17.9 of the Java language specification).
3. The code block is executed (in this case setting the return value to the current value of i3, which may have just been reset from “main” memory).
4. (Any changes to variables would normally now be written out to “main” memory, but for geti3() we have no changes.)
5. The thread releases the lock on the monitor for object this.

So where volatile only synchronizes the value of one variable between thread memory and “main” memory, synchronized synchronizes the value of all variables between thread memory and “main” memory, and locks and releases a monitor to boot. Clearly synchronized is likely to have more overhead than volatile.

摘自:http://bianbian.org/technology/java/88.html

posted @ 2009-01-06 15:24 Fingki.li 阅读(388) | 评论 (0)编辑 收藏

有synthetic标记的field和method是class内部使用的,正常的源代码里不会出现synthetic field。小颖编译工具用的就是jad.所有反编译工具都不能保证完全正确地反编译class。所以你不能要求太多。
下面我给大家介绍一下synthetic

下面的例子是最常见的synthetic field
class parent
{
public void foo()
{
}
class inner
{
inner()
{
foo();
}
}
}
非static的inner class里面都会有一个this$0的字段保存它的父对象。编译后的inner class 就像下面这样:
class parent$inner
{
synthetic parent this$0;
parent$inner(parent this$0)
{
this.this$0 = this$0;
this$0.foo();
}
}
所有父对象的非私有成员都通过 this$0来访问。

还有许多用到synthetic的地方。比如使用了assert 关键字的class会有一个
synthetic static boolean $assertionsDisabled 字段
使用了assert的地方
assert condition;
在class里被编译成
if(!$assertionsDisabled && !condition)
{
throw new AssertionError();
}

还有,在jvm里,所有class的私有成员都不允许在其他类里访问,包括它的inner class。在java语言里inner class是可以访问父类的私有成员的。在class里是用如下的方法实现的:
class parent
{
private int value = 0;
synthetic static int access$000(parent obj)
{
return value;
}
}
在inner class里通过access$000来访问value字段。

摘自:
http://www.cjsdn.net/post/print?bid=1&id=130784

posted @ 2009-01-06 12:24 Fingki.li 阅读(3442) | 评论 (0)编辑 收藏

相关资料:
IETF : http://www.potaroo.net/ietf/idref/draft-nourse-scep/
Java SCEP : http://www.urut.ch/scep/
OpenSCEP : http://openscep.othello.ch/

posted @ 2009-01-04 14:25 Fingki.li 阅读(316) | 评论 (0)编辑 收藏

一朋友推荐给我的文章,感觉很不错;摘抄过来,也给同行们提个醒!

论坛里经常可以看到关于 35 岁程序员的生涯询问, 他们之中有些人写了十年代码, 有些人则是因为对编程发生了兴趣, 中途转行, 以下四点是给那些 30 - 35 岁程序员的建议:

* 照顾自己健康

以前, 我认为 "钱" 是很重要的, 俗话说的好: "钱不是万能, 但没有钱万万不能", 所以过去我的焦点都是放在收入, 但后来我发现有比钱更重要的东西, 那是 "家", 在你没有结婚前, 这个家的概念是指你和父母的和谐关系, 而在结婚后, 家的概念是指如何维系一个家庭, 包括和太太还有孩子的关系。

在 IT 这个行业里, 很多人跟自己父母的想法是有差距的, 认为上一代保守, 食古不化, 讲到很多东西没法沟通, 另外, 我的很多朋友事业做很大, 但最后却离婚了, 没有孩子还好, 有孩子的要想更多, 只有家, 你才有奋斗的目标, 才有精神的支持, 否则就像电视里讲的那一句, 失去了你, 得到江山又如何?

但这个家的信念自从张国荣事件后, 又改变了我的看法, 那就是有比家更重要的东西, 那是你的 "健康", 这个健康包括生理和心理上的健康, 想想看你拥有了一个家, 但是因为没有健康, 全家人都被拖下去了, 每天看着你痛苦的吊瓶子, 更严重的直接轻生, 这样遗留给珍爱你的人只是更大的痛苦, 你会 C, C++, C#, Java... 又怎样? 那时候你会认为这些通通都是屁, 做人做到能够 "吃得下饭、睡得着觉、笑得出来" 就已经是莫大的幸福。

35 岁会困惑的人多半是因为二十几岁的时候就没有做好准备, 过去的已经不可追, 现在要想的应该是 45 岁怎么办? 有人说年轻比的是学问, 中年比的是财富, 老年比的是健康, 如果你现在不注意自己健康, 那么很快更大的困扰就会上门了, 人生每个阶段都有扮演的角色, 要学会未雨绸缪, 否则不用到 50 岁, 可能 40 岁就会开始后悔了, 健康要从饮食和运动着手, 多涉猎这方面的常识, 比搞那些过几年就要淘汰的技术有意义多了。

* 学会投资理财

很多人认为投资理财需要很多的钱, 这是不正确的, 会理财的人, 小钱可以积累到大, 不会理财的人, 大钱也会消耗到光, 投资理财首重的是风险管理, 没有风险管理就像在刀口舔血一样, 投资理财应该要趁早磨练, 不要等到 40 岁的时候才去冒险, 因为那时候你已经没有本钱跌倒, 投资理财的方法有很多, 并不是只有房地产, 股票这些东西, 从节约, 储蓄, 定存... 每一步都是学习, 关键是你要从投资的过程里去发现自己, 并且了解如何正确对待甚至对付自己, 这样你才有机会早一日达到经济自由, 不会提心吊胆这个那个。

投资理财要量力而为, 不要做超过你能力所能负荷的事情, 我给程序员最好的建议是关注经济, 不要浮躁, 错把投机当投资, 这样还不如定存来得可靠安全。

* 经营你的人脉

我觉得程序员除了普遍不善理财外, 另外人际沟通也多有问题, 很多人在离开公司的剎那, 整个人感觉也都被掏空了, 而且会有一种担忧, 以前别人跟我说话那是因为我是某某公司的员工, 现在不是了, 可能就没有什么人会再鸟我了, 这就是典型的人脉经营危机。

人脉的经营不是看你有没有朋友, 而是有没有能帮助你同时又有实力的朋友。有些人朋友很多, 但真正遇到困难, 只能精神上支持一下, 除此外, 帮不上任何忙, 这代表人脉还是太单薄, 不要总问别人能给你什么? 也要问问你能给别人什么? 懂得去欣赏别人, 而不要像患了红眼病一样, 漠视别人背后的辛劳的付出, 只知道妒忌表面的风头, 这样, 只会将自己的路越走越窄。

经营自己的人脉是有秘诀的, 首先你要了解自己存在的价值, 如果没有存在的价值, 那么经营的人脉是空的, 这跟有存在价值却不知道怎样经营人脉, 基本上差不多, 经营人脉并不等于趋炎附势, 而是指在得势的时候, 就要想到落难的时刻, 待人宽厚真诚, 花无百日好, 人无千日红, 多欣赏别人, 择友深交, 别把时间浪费在小屁孩身上。

* 培养广泛兴趣

一个程序员如果除了 IT 以外, 一点其它的兴趣也没有, 那真的是很危险的事情, 像我现在年龄已经超过 35 岁了, 很快就要 40, 但我现在还是每天写代码, 做项目已经不是为了维生, 而是纯粹兴趣了, 我想我会一直写下去, 同时开始加强自己经营管理或财务方面的知识。你说郭安定以后玩不了电脑怎么办? 他就去写书, 万一双手废了怎么办? 那就去配音, 万一声音也哑了怎么办? 那就重回金融市场, 让徒子徒孙帮忙着下单, 眼球看左就买, 看右就卖, 就这么一直玩下去...

所以人生不是只有一条路, 你得为自己想好方方面面, 而广泛的兴趣可以帮助你跳脱现况, 看到更多。

以上四点不仅是 35 岁的人要注意的, 很多甚至二十几岁的人也要开始关注, 说真的, 很多程序员看上去每个体型都不错, 但体格都马马虎虎, 很多人熬个两天夜就不行了, 不知该说什么... 一起加油吧。

posted @ 2008-12-26 14:59 Fingki.li 阅读(283) | 评论 (1)编辑 收藏

Tsung,压力测试的好工具。
安装过程:
1.获取tsung 的源码。http://tsung.erlang-projects.org/
2.安装依赖 erlang(从源码编译 erlang 写的程序) gnuplot perl5(如果想看 report 中的图形,就要装这个)
apt-get install erlang erlang-src gnuplot perl5 我用的是Ubuntu 8 OS.
3.编译安装
./configure
make
sudo make install

安装完成之后的 tsung 运行脚本在 /usr/bin/tsung ,在系统 path 之中,可以直接运行。

设置

从 /usr/share/doc/tsung/examples 中挑一两个例子拷贝到 ~/.tsung/tsung.xml 作为配置文件。我只需要 http 测试,所以:

cp /usr/share/doc/tsung/examples/http_simple.xml ~/.tsung/tsung.xml

tsung 采用了巧妙的 proxy 方式来“录制”测试脚本。具体来说,就是建立一个本机的 http proxy 默认使用 8090 端口,在配好 firefox 使用 localhost 8090 作为代理之后(推荐 foxyproxy 插件),所有“流经”这个 proxy 的 http 动作都会被记录下来,测试时可以“回放”这些步骤来产生请求。

tsung rocorder
tsung stop_recorder

“录制”完了,会得到一个 ~/.tsung/tsung_recorderXXXXXXXXXX.xml 文件,这就是测试时回回放的脚本。

将这个脚本加到 tsung.xml 之中

gedit ~/.tsung/tsung.xml

就像这样

<!DOCTYPEtsungSYSTEM"/usr/share/tsung/tsung-1.0.dtd" [
 <!
ENTITYmysession1SYSTEM"/home/yourname/.tsung/tsung_recorderXXXXXXXXXX.xml">
]>
...
<sessions>
 
&mysession1;
</sessions>

对配置稍作调整

<monitoring>
    
<monitorhost="localhost"type="erlang"></monitor>
 
</monitoring>
 
<!-- 需要配置到 localhost 无须密码的 ssh 登录(ssh via rsa_key),开启了这个配置可以,获得目标机器的 cpu 和 ram 消耗情况 -->
 
<load>
  
<arrivalphasephase="1"duration="1"unit="minute">
    
<usersinterarrival="2"unit="second"></users>
  
</arrivalphase>
 
</load>
 
<!-- 第1阶段1分钟(你可以自己多搞几个阶段),其中每2秒新建一个用户,每个用户都会完整执行 session 的测试脚本,最高并发约为 30 个,个人认为这个“逐渐加压”的方法比 ab xxxx 的“突然加压”要慢一些,但更科学一点 -->

运行

准备好了,加压运行。

tsung start

运行完,在 ~/.tsung/log 目录会生成一个以时间命名的目录,进入这个目录

cd ~/.tsung/log/xxxxx
/usr/lib/tsung/bin/tsung_stats.pl (有时可能是 /usr/local/lib/tsung/bin/tsung_stats.pl)

生成 html 的压力测试报告

firefox report.html
除了 http 以外 tsung 还可以压很多东西,比如:jabber, postgreSQL 还可以写插件来给任何你想要测试的东西加压.

posted @ 2008-12-01 10:43 Fingki.li 阅读(1960) | 评论 (2)编辑 收藏

仅列出标题
共8页: 上一页 1 2 3 4 5 6 7 8 下一页