Tuesday, December 28, 2010

Inside P2's profile (2) - the fragment matches all osgi bundles

Recently our installer met a strange bug, it didn't uninstall all legacy bundles after updating to new version. Finally I found it's due to a magic fragment is missing in the profile due to some causes.

    <unit id='tooling.osgi.bundle.default' version='1.0.0' singleton='false'>
      <hostRequirements size='1'>
        <required namespace='org.eclipse.equinox.p2.eclipse.type' name='bundle' range='0.0.0' multiple='true' greedy='false'/>
      </hostRequirements>
      <properties size='1'>
        <property name='org.eclipse.equinox.p2.type.fragment' value='true'/>
      </properties>
      <provides size='2'>
        <provided namespace='org.eclipse.equinox.p2.iu' name='tooling.osgi.bundle.default' version='1.0.0'/>
        <provided namespace='org.eclipse.equinox.p2.flavor' name='tooling' version='1.0.0'/>
      </provides>
      <requires size='1'>
        <required namespace='org.eclipse.equinox.p2.eclipse.type' name='bundle' range='0.0.0' multiple='true' greedy='false'/>
      </requires>
      <touchpoint id='null' version='0.0.0'/>
      <touchpointData size='1'>
        <instructions size='4'>
          <instruction key='install'>
            installBundle(bundle:${artifact})
          </instruction>
          <instruction key='uninstall'>
            uninstallBundle(bundle:${artifact})
          </instruction>
          <instruction key='unconfigure'>

          </instruction>
          <instruction key='configure'>
            setStartLevel(startLevel:4);
          </instruction>
        </instructions>
      </touchpointData>
    </unit>

It has 'hostRequirements' element that represents it's a fragment IU and match all the eclipse's plug-ins in that profile. And this fragment defines the touch point actions for its hosts that will do installBundle action during 'install' phrase and uninstallBundle action during 'uninstall' phrase. It's a very good way to remove the duplicate touch point definitions for all eclipse's plug-ins in the profile.

BTW, p2's engine also doesn't attach this fragment to the eclipse's plug-in IU if the top level IU doesn't have the STRICT rule. I'm not sure the root cause of designing for it, but it's the fact.

Inside P2's profile (1) - inclusion rules

You would see some interesting properties at the bottom of eclipse's profile.

For example,
<iuProperties id='org.eclipse.sdk.ide' version='3.6.1.M20100909-0800'>
      <properties size='2'>
        <property name='org.eclipse.equinox.p2.internal.inclusion.rules' value='STRICT'/>
      </properties>
</iuProperties>

It attaches a property named 'org.eclipse.equinox.p2.internal.inclusion.rules' with value 'STRICT' on the IU 'org.eclipse.sdk.ide' with version 3.6.1.M20100909-0800.
 
It's a very important property for the p2 engine. It means the IU 'org.eclipse.sdk.ide' has been explicitly installed into the profile, so it's not allowed be implicitly updated or removed.

For example,
We have top feature IU 'org.eclipse.sdk.ide' that represents the Eclipse SDK,   'org.eclipse.pde.feature' that represents the Plug-in Development Tool and 'org.eclipse.jdt.feature' that represents the Java Development Tool. And both JDT and PDT are part of Eclipse SDK, so 'org.eclipse.pde.feature' and 'org.eclipse.jdt.feature' are required by 'org.eclipse.sdk.ide'.

If the profile only has the STRICT rule for 'org.eclipse.sdk.ide', 'org.eclipse.jdt.feature' and 'org.eclipse.pdt.feature' will implicitly be updated to 3.6.2 when updating 'org.eclipse.sdk.ide' from 3.6.1 to 3.6.2.

However the profile has below STRICT rule for PDT feature,


<iuProperties id='org.eclipse.pdt.feature' version='3.6.1.M20100909-0800'>
      <properties size='2'>
        <property name='org.eclipse.equinox.p2.internal.inclusion.rules' value='STRICT'/>
      </properties>
</iuProperties>


The p2 engine will report errors due to 'org.eclipse.pdt.feature' has STRICT rule for updating. Hence third-party must explicitly update both 'org.eclipse.sdk.ide' and 'org.eclipse.pdt.feature' from 3.6.1 to 3.6.2.

Thursday, December 23, 2010

stack overflow protector

Latest gcc compiler enables the stack overflow protector that is since GLIBC 2.4. So the library or executable is compiled by latest gcc could be loaded or executed in RHEL4 or Solaris 9 that only have GLIBC 2.3. Hence using option '-fno-stack-protector' to compile the library or executable to make sure it could be executed in older linux release.

g++ -fno-stack-protector -o test.o test

Tuesday, September 21, 2010

the loop name for 'for' clause in java

Recently I just know such a useful syntax usage of java.

aLoopName: for (;;) {
 
// ...
 
while (someCondition)
 
// ...
   
if (otherCondition)
     
continue aLoopName;

Sunday, September 19, 2010

rename command

It's a powerful command to rename files in a batch.

Usage:

rename 's/(\d+)$/$1\.txt/' * rename add '.txt' extension name for all files that ends with number.

Monday, September 13, 2010

applying proxy for the softwares without proxy support in linux

If you have http proxy, set it to system environment,
export http_proxy=http://127.0.0.1:8000

Then start the application in that same terminal.

If the proxy is socks proxy, use 'tsocks' to wrap the application in terminal.

Monday, August 30, 2010

Food and Drinking

Honestly speaking, you have eaten the best delicious food if you're living in China. Though we have more and more concerns on the safety of food, we have to recognize that Chinese food is more delicious than others.

The cuisine is simple in Austria. People always use pork, beef, flour, tomato, potato and few green vegetables. So they surprised Chinese cost several hours to make the food.
Gulasch, it's good tasted after eating pizza several times
pasta


About the drinking, most of them directly drink the water from water pipe. And some of them like the special water that mixes water with gas. The coffee and beer are the favorite of local citizens. You can find more than one hundred beer brand in the city, and some of them have been found for centuries. Indeed they're good tasted.
special water
Die Weissf
Wieninger, it comes from Vienna
Stiegl, local famous brand

Friday, August 27, 2010

Working Workspace

Joel posted a blog related to how to hire the great programmers. One of his key points is building comfortable workspaces.

I believe every programmer loves the workspace like Google and Fog Creek. The workspace of Google has been very famous due to its French chef, gymnasium and big sofas. Why is Fog Creek? It's the company created by Joel, he also practiced his theory on his company. Ruan YiFeng posted a blog for it. I bet you would envy the guys working in that office.

How about the workspace of the office in Salzburg? Let me show some pictures.



Space

programmers have two monitors

Reading
non-technique magazines
technique books


Drinking
coffee machine


Kitchen
freezer for fast food


Entertainment
table football game

Transportation

Salzburg is a small city and is on the banks of the Salzach River. It's easy to go through the city by bus in 30 minutes.
Salzach River
outline view

Riding the bicycle is a very good way to enjoy the beautiful sight of the city. You could see many kids with parents riding bicycle in the sunny weekend.
The train station and a major bus transient station are the same one that is called as 'main station' by local residents. it's not far from the office of company, about 20 minutes by foot.

The ticket system of bus is more complicated than Beijing's. People can buy the ticket for single, 24 hours, 48 hours, a week and even a year. The children can get discount. There's no ticket seller in the bus. Usually nobody checks whether you have valid ticket. Pressing the button to open the door when getting on/off the bus.

The public transportation is designed well. There are different tickets for different people. For example, tourists would prefer to buy 24 hours ticket or 48 hours tickets. 24 hours ticket means the passengers can take any bus in the 24 hours after it's used first time. So it's very convenient for tourists. 24 hours ticket is 4.2€ for adults, 2.1€ for children.  The price of train tickets is same. The faster train "ICE" have higher price. The regular train is much cheaper. And the ticket allows a family not exceed 5 persons to go back and forth another city in a day. It's very cheap for a family to enjoy weekend in another city or town by train. I think it's a good approach to use public transportation more to reduce environment pollution.
round-trip ticket


Taking the train is more convenient than China. There is no security checking, no long distance between gate and platform and even no staffs in the platform. Meanwhile there is no any limitation to travel among the European countries. I went to Munich of Germany by train, I felt it's even more convenient than taking subway in Beijing. Both the train and bus have a lot of humanization design for disability people and people with their bicycles or pets.

Friday, August 20, 2010

Working style

There are 20+ staffs in Salzburg office. Most of them are developers, one is administrator of office.
Generally the staffs in Salzburg work more flexible than the staffs working in Beijing.
Some of them live in German. Even though it's not so far as Salzburg, they also need come to Salzburg by train. So sometimes they work at home, use internet and phone as communication tool.
And they have different responsibilities for products. For example, Helmut works on installer, Matthias and Michael are responsibility for QFT testing, Martin N. is focus on license API developing. So everybody has himself schedule, he can decide when he come to office and when leave office based on his working schedule. Nobody cares when you come/leave office or how long you work every day. I believe all of them do well on their jobs.
Furthermore you can work with your dogs together if nobody takes care of them at home.
Max's dogs
Most of foreign like coffee, so there is a kitchen with seats in the office. Some of them like to drink a cup of coffee or tea as a break, and it's a good chance to talk with others. It's a relaxing time for changing your mind out of work. Besides drinking some things, there is a room for playing table football game. It's a small amount of exercise, it's good for body.

Another thing makes me very impressive is that the team is very stable than any company I know in China. Most of them work in company more than 10 years. So I think I know that's why they know more than us. Everyone could be expert after doing the same thing more than 10 years. They love the work of coding, and they would like to do coding until retiring. That's why I can see some of them are more than 40, even 50 years old.

Tuesday, August 10, 2010

day 1


度过长途飞行的旅程不是一件容易的事。要在狭小的空间里待上近10个小时,好在是两人出行,半睡半聊的打发过了时间。
到达维也纳之后,出了登机通道看到的居然是一个酒吧类的餐馆。感觉很稀奇,也很有味道。
周围当然少不了免税店和商铺,但远没有首都机场那样的规模。总体感觉就像国内大型超市购物出口一样,而且人也不多。

另外赞一下维也纳机场的Wifi,简单配置就K了,哪像国内的,又要移动号码,还要短信获取,搞半天也没弄定。
转机之前还有段时间,就在机场里到处逛了逛。顺便在一个吧解决了晚餐,同时也尝了杯当地啤酒。

去萨尔茨堡的飞机还是带螺旋桨的,头次坐这样的老式飞机。

Monday, May 17, 2010

Discovering the p2 API

Check out this SlideShare Presentation:

P2 replication tool lives on Eclipse Marketplace

Days ago I updated my p2 replication tool. It's easier to install it in your Eclipse.
A new component named 'Eclipse marketplace' is added into Eclipse SDK since Helios, which is an application store for Eclipse. People could be easy to install third party plug-ins into their Eclipse.

You can launch marketplace via 'Help' - 'Eclipse Marketplace...', then search key word 'p2' or 'replication' to find the tool. Finally click next to install it.

It's a very graceful workflow to install some add-ons like firefox.

And then p2 replication tool could help you replicate your environment. This tool supports install components from another existing Eclipse instance to save the time cost on downloading them from Internet now! Enjoy it.

Thursday, March 11, 2010

useful network utility tools

1. tcpdump
tcpdump -n port 80 -i eth0|lo
monitor all package transferred on 80 port on the network interface eth0/lo
2. netstat
netstat -anp|grep java
trace all network traffic on the process named java
netstat -anp|grep 128.224.159.xxx
trace all network traffic on the host whose ip address is 128.224.159.xxx
3. nslookup
nslookup 206.191.52.46
look up the domain name whose ip address is 206.191.52.46

Wednesday, February 24, 2010

[tip]Find -exec tip

Using -exec command like below, need add escape character for semicolon that separated two commands in shell

find directory/ -type d -exec chmod a+x {} \;

Feb 24, 2010 - update:
find . -maxdepth 4 -type d  -name 'g-vxworks' 2>/dev/null -print

Friday, February 5, 2010

special characters in p2 touchpoint instruction

I suffered p2 installation failed on the configure parse. Becase I try to add vm arguments for my application.
For example, I added '-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8272' in the product configuration.
P2 will fail when parsing the argument, because it contains ':' and ',' that should be escaped.
It works again after replacing it to '-agentlib${#58}jdwp=transport=dt_socket${#44}server=y${#44}suspend=n${#44}address=8272'.
The more detail note could be found in p2 touchpoint wiki.
And I also opened bug to request improving it.

Friday, January 29, 2010

mount windows share folder

mount -t cifs -o username=xxx,password=xxx,workgroup=xx,iocharset=utf8 //share.domain/folder /localfolder

Wednesday, January 27, 2010

Monday, January 11, 2010

How to get the name of running test case in JUnit4

public class NameRuleTest {
   
@Rule public TestName name = new TestName();

       
@Test public void testA() {
                assertEquals
("testA", name.getMethodName());
       
}

       
@Test public void testB() {
                assertEquals
("testB", name.getMethodName());
       
}
}