2013年7月23日星期二

Pythoner

Préfèrez :

la beauté à la laideur,
l’explicite à l’implicite,
le simple au complexe
et le complexe au compliqué,
le déroulé à l’imbriqué,
l’aéré au compact.
Prends en compte la lisibilité.
Les cas particuliers ne le sont jamais assez pour violer les règles.
Mais, à la pureté, privilégie l’aspect pratique.
Ne passe pas les erreurs sous silence,
... ou bâillonne-les explicitement.
Face à l’ambiguïté, à deviner ne te laisse pas aller.
Sache qu’il ne devrait avoir qu’une et une seule façon de procéder,
même si, de prime abord, elle n’est pas évidente, à moins d’être Néerlandais.
Mieux vaut maintenant que jamais.
Cependant jamais est souvent mieux qu’immédiatement.
Si l’implémentation s’explique difficilement, c’est une mauvaise idée.
Si l’implémentation s’explique aisément, c’est peut-être une bonne idée.
Les espaces de nommage ! Sacrée bonne idée ! Faisons plus de trucs comme ça.

2013年7月18日星期四

Eclipse RCP Technologies and other Technologies related to Eclipse RCP based projects

Eclipse RCP (Rich Client Platform) is a powerful free open-source platform for developing general purpose applications.

Eclipse RCP was chosen because of several goals:
It is based on OSGi principles. This means that we have a good flexibility between different modules. Eclipse RCP projects are based on plug-ins that provide possibility to easily include or exclude any modules. Or for example make two kinds of application –Trial version that contains only the Core functionality and Real version with the full functionality. Eclipse RCP supports a good Updating mechanism of existing projects with new versions.

Eclipse RCP platform already contains many solutions for implementing different tasks in GUI, Text handling etc.

There are many free open-sources Eclipse RCP based projects and plug-ins for many specific technologies and tasks that can be used instead of bootstrapping


Directly in our projects we use the following technologies:
SWT/JFace – for building GUI.
Resources plugin – provides access to file system.
Eclipse Workbench – to have a good organization of different GUI elements.
Eclipse Debug – organization of launching of different kind of scripts.

But also in our projects many specific technologies based on Eclipse were used such as:
uDIG SDK – Eclipse RCP based project for visualization and working with Geo Information Systems (maps, layers etc.). Particularly it was used to show specific user-defined information on maps.
EMF (Eclipse Modeling Framework) – Eclipse RCP module for Modeling. It was used as alternative for structural information storing (e.g. Map contents).
Neoclipse – Eclipse RCP based project for visualization content of Graph Database Neo4j.
RDT (Ruby Development Tool) – Ruby IDE based on Eclipse RCP.
GEF – framework to create different user-specific editors.
AWT-SWT Bridge – was used to create a powerful alternative of Excel – Splash.

Also in Eclipse RCP based projects many specific technologies that are not related to Eclipse RCP were used:
Neo4j Database - is a graph database. It is an embedded, disk-based, fully transactional Java persistence engine that stores data structured in graphs rather than in tables.
jRuby – Java based interpreter of Ruby language. Ruby was used as a scripting language for Splash (analog of Excel) and console. Directly jRuby was used to have access to Java classes.
jTestR – Junit based testing framework for Ruby.
Maven and Tycho maven plugin – automatic building of Eclipse RCP based applications.

2013年7月17日星期三

Hash tree (tiger tree)在大量文件实时同步中的应用

大型集群系统常需要进行多个服务器的大量文件的内容同步。
传统的文件同步方案有rsync(单向) 和 unison(双向)等,它们需要扫描所有文件后进行比对,差量传输。文件扫描计算摘要是非常耗时的,我用rsync同步maven中央仓库的内容,每次同步都要花至少几十分钟的时间计算本地的文件摘要后,才会开始从远程取新的内容。
在受控的服务器(有权限管理)的环境中,可以通过Hash Tree,就是tiger tree来实现变化文件的同步。 Sun的ZFS,Amazon的Dynamo中都有用到这种结构。
简言之,Hash Tree是将所有数据的摘要信息存储成树状结构,每个节点的Hash是其所有子节点的Hash的Hash,叶子节点的Hash是其内容的Hash。这样一旦某个节点发生变化,其Hash的变化会迅速传播到根节点。需要同步的系统只需要不断查询根节点的hash,一旦有变化,顺着树状结构就能够在logN级别的时间找到发生变化的内容,马上同步。
Linux下可利用2.6内核的新特性inotify来自动感知某个目录内文件发生变化的信息,当应用程序感知到变化时,更新Hash tree的所有父节点。Windows下可使用文件系统的hook来感知文件的变化。
在需要同步时,若发现根目录的Hash值有变化,顺着目录结构往下找即可有变化的文件,再做同步。

Speed up your eclipse as a super fast IDE

Follow these steps to speed up your eclipse as a super fast IDE , it works for 32 & 64 bit version eclipse/jdk on my windows 7 x64.
1.Disable antivirus software, or add your jdk & eclipse & workspace & other related folder to white list in your antivirus software.
2.Disable unecessary validations and startup action in eclipse reference.
For validations: on eclipse menu Windows -> Preferences -> Validation, click “Disable All”, and then select the validator which you need. I selected “Classpath Dependency Validator” only.
For startup action: on eclipse menu Windows -> Preferences, type “startup”, select “Startup and Shutdown”, untick the options you don’t need. (Thanks for David’s suggest,  I’ve added the above 2 detail steps for readers)
3.Modify eclipse.ini to set the Xmn(new generation size), Xms and Xmx, enable parallel GC
-vm
C:/jdk1.6.0_25/bin
-startup
plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
–launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.100.v20110502
-product
org.eclipse.epp.package.jee.product
–launcher.defaultAction
openFile
–launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
–launcher.XXMaxPermSize
256m
–launcher.defaultAction
openFile
-vmargs
-server
-Dosgi.requiredJavaVersion=1.5
-Xmn128m
-Xms1024m
-Xmx1024m
-Xss2m
-XX:PermSize=128m
-XX:MaxPermSize=128m
-XX:+UseParallelGC
4.Create a ram disk(virtual disk) on memory, and put your jdk on the ram disk.
You can use imdisk to create ram disk. Firstly download it from: http://www.ltr-data.se/opencode.html/#ImDisk,  and install it.
Then set the ImDisk driver to auto-load at Command Prompt with administrative privileges (for example right-click, start as Administrator), type:
sc config imdisk start= auto
net start imdisk
create a 200m ram disk as driver n by:
imdisk -a -t vm -s 300m -m n:
then you should format the ram disk manually.
later ,if you would like to remove the ram disk, just run the command:
imdisk -D -m n:
5.Make sure you are using sun jdk, not open jdk/gcj nor other jdk on linux.
If you are not satified with the after the above steps, install jrockit instead of sun jdk, and change some of the vm options by jrocket specification,
jrockit is faster than sun jdk.
Some note:
On my laptop(Aspire 4745G 4G mem ), windows 7 x64, by default, it takes more than 30 seconds to start eclipse.  After the vm options tuned,  takes only 15 seconds.
And after jdk moved to ram disk, it takes 10 seconds to startup.

How to improve eclipse performance for starting

Increase the following Java virtual memory (-vmargs) settings:
Xms Initial size (bytes) of the memory allocation pool. This value must be a multiple of 1024, greater than 1 MB. Append the letter k or K to indicate kilobytes, or m or M to indicate megabytes. 
Xmx Maximum size (bytes) of the memory allocation pool. This value must a multiple of 1024, greater than 2 MB. Append the letter k or K to indicate kilobytes, or m or M to indicate megabytes.
XX:MaxPermSize Maximum size of Permanent Generation
XX:PermSize Initial size of Permanent Generation
Follow these steps to increase the Java virtual memory settings.

Ensure that Eclipse is not running on your computer.
Locate and open the eclipse.ini file, as applicable, on your computer. The .ini file is located within your Eclipse installation directory.
Change or add the following Java -vmargs settings in the eclipse.ini file:
Xms256m
Xmx512m
XX:MaxPermSize=256m
XX:PermSize=64m
Save the file and restart Eclipse, as applicable.

For more information:
  • http://wiki.eclipse.org/Eclipse.ini
  • http://wiki.eclipse.org/FAQ_How_do_I_increase_the_heap_size_available_to_Eclipse
  • http://wiki.eclipse.org/FAQ_How_do_I_increase_the_permgen_size_available_to_Eclipse
  • http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html

2013年7月16日星期二

Hibernate 3.5.0-Final release Features

hello, everbody,
Here is the list of the major accomplishments embodied in 3.5.0-Final
  • JSR 317 (JPA2) support.
  • Integration of hibernate-annotations, hibernate-entitymanager and hibernate-envers into the core project.  See http://in.relation.to/14172.lace for details
  • Added Infinispan as a standard second-level cache. See http://infinispan.blogspot.com/2009/10/infinispan-based-hibernate-cache.html for details
  • Improvements to the new second-level caching SPI introduced in 3.3 based on feedback from implementers including Ehcache, Inifinispan and JBoss Cache.
  • Far better read only / immutable support. See the new chapter added to the core reference manual dedicated to the subject.
  • Support for JDBC 4 such that Hibernate can be used in JDK 1.6 JVMs and make use of JDBC4-compliant drivers.'
  • Support for column-level read/write fragments (HBM only for now)
  • Initial support for fetch profiles
Check out the release page for the full list of changes (just in 3.5.0-Final, aka not cumulative).

you can see http://relation.to/15040.lace for details.

ericssonxiao