The NoteBook of EricKong

  BlogJava :: 首页 :: 联系 :: 聚合  :: 管理
  611 Posts :: 1 Stories :: 190 Comments :: 0 Trackbacks

#

Materials from industry :
How to fix memory leaks in java : http://olex.openlogic.com/wazi/2009/how-to-fix-memory-leaks-in-java/
GC Tuning : http://www.oracle.com/technetwork/java/gc-tuning-5-138395.html
GC and Memory Leak Tips : http://chaoticjava.com/posts/gc-tips-and-memory-leaks/
Tools
IBM Support Assistant : http://www-01.ibm.com/software/support/isa/download.html
Memory Analyzer : http://www.ibm.com/developerworks/java/jdk/tools/memoryanalyzer/
Garbage Collection and Memory Visualizer : http://www.ibm.com/developerworks/java/jdk/tools/gcmv/
Eclipse Tools:
Memory Analyzer (MAT) :  http://www.eclipse.org/mat/
Guideline: http://wiki.eclipse.org/MemoryAnalyzer#Getting_a_Heap_Dump
Testing and Performance Tools Platform (TPTP): http://www.eclipse.org/tptp/
Guideline: http://www.eclipse.org/tptp/platform/documents/tutorials/jvmti/Java_Application_Profiling_using_TPTP-r4-3.html
Java Tools:
HPROF: http://java.sun.com/developer/technicalArticles/Programming/HPROF.html
posted @ 2013-09-20 15:56 Eric_jiang 阅读(593) | 评论 (1)编辑 收藏

其基本逻辑为先取得配置的IP列表,然后通过request.getRemoteAddr()取得客户端的IP地址,做鉴权和校验,逻辑没问题,那么肯定是request.getRemoteAddr()出了问题,google下,发现有人遇到类似的问题。
最终定位为request.getRemoteAddr()这种方法在大部分情况下都是有效的。但是在通过了Apache,Squid等反向代理软件就不能获取到客户端的真实IP地址了。
如果使用了反向代理软件,将http://192.168.1.110:2046/ 的URL反向代理为http://www.xxx.com/ 的URL时,用request.getRemoteAddr()方法获取的IP地址是:127.0.0.1 或 192.168.1.110,而并不是客户端的真实IP。
经过代理以后,由于在客户端和服务之间增加了中间层,因此服务器无法直接拿到客户端的IP,服务器端应用也无法直接通过转发请求的地址返回给客户端。但是在转发请求的HTTP头信息中,增加了X-FORWARDED-FOR信息用以跟踪原有的客户端IP地址和原来客户端请求的服务器地址。
原来如此,我们的项目中正好是有前置apache,将一些请求转发给后端的weblogic,看来就是这样导致的咯。
给出一份还算靠谱的代码,如下:
Java代码
public String getIpAddr(HttpServletRequest request) {
        String ip 
= request.getHeader("x-forwarded-for");
        
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            ip 
= request.getHeader("Proxy-Client-IP");
        }
        
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            ip 
= request.getHeader("WL-Proxy-Client-IP");
        }
        
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            ip 
= request.getRemoteAddr();
        }
        
return ip;
    }
如果有人遇到类似问题,请多加留意,呵呵。
PS:可是,如果通过了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串ip值,究竟哪个才是真正的用户端的真实IP呢?
答案是取X-Forwarded-For中第一个非unknown的有效IP字符串。如:X-Forwarded-For:192.168.1.110, 192.168.1.120, 192.168.1.130, 192.168.1.100,用户真实IP为: 192.168.1.110
posted @ 2013-09-11 18:21 Eric_jiang 阅读(342) | 评论 (0)编辑 收藏

     摘要: Selenium是一个很好用的Web界面测试框架。但它的功能也有不足之处,比如: 在Selenium IDE中不支持程序控制语句。下面介绍如何在Selenium IDE中添加程序控制功能。1)下载Selenium插件 (sideflow.js): 如果不想下载,直接把下面的代码保存到本机也可。?var gotoLabels= {};var whileLabels = {};&n...  阅读全文
posted @ 2013-09-06 16:54 Eric_jiang 阅读(497) | 评论 (0)编辑 收藏

     摘要: 1、把.cer的SSL证书转换为.pem文件,执行命令:openssl x509 -in aps_development.cer -inform der -out PushChatCert.pem 在桌面上会生成一个PushChatCert.pem文件 2、把私钥Push.p12文件转化为.pem文件:openssl pkcs12 -nocerts -out PushChatK...  阅读全文
posted @ 2013-09-06 12:43 Eric_jiang 阅读(545) | 评论 (0)编辑 收藏

Create a Physical File with or without a key field 
创建一个物理文件(有或者没有Key字段)

The AS/400 database, DB2/400 is part of the AS/400 operating system. It is a relational database and has features similar to other databases you may have used such as Microsoft Access, Oracle or Dbase. The standard method of creating files is to define the specifications of the file using DDS. Of course DDS is used for other things on the AS/400 like defining display files and print files. 
AS/400数据库,DB2/400是AS/400操作系统的一部分,它是一个关系性数据库.和其他的数据库相比,例如Microsoft Access, Oracle or Dbase有着相似的特性.用DSS文件编写说明语句是创建数据库文件的标准方法.当然,也可以使用DSS在AS400做其他东西,例如创建显示文件或者打印文件

To create a physical database file, enter your source statements in a DDS source file member. For example, name the member "CUS" for customer file. Make sure the member type is "PF". This tells the compiler that this is for a physical file. Notice that the first record has an "R" in position 17. This means that this line is specifying the record name, in this case "CUREC". The "TEXT" is optional but helps to document the file. 
创建一个物理文件数据库,你需要在DSS文件中输入你的数据描述代码.例如,以一个Customer文件为例,命名为CUS的Member,要确保这个member的类型是"PF",这是为了告诉编译器,这是一个物理文件.注意到在第一行中,位置17的地方有个"R"的标记,这一行指明了记录的名字,这里记录名字就是CUREC.而Text不是一定要,但是也对文档化比较有用.

After the line naming the record, each line describes a field. The field name is followed by the field length and its data type.
这一行命名了记录之后,下面的每一行描述了一个字段,字段名称后面是字段的长度和数据类型

The three most used data types are "A" for alpha or character, "S" for numeric and "P" for packed decimal. For numeric fields, you must also specify the number of decimal positions. So here, the company number field is a three digit number with no decimal places. The customer number and zip code are also numeric fields with no decimal places. The credit limit is a numeric, packed decimal field with 9 digits, of which two are after the decimal point. The rest of the fields are character fields. 
最常用的数据类型是下面的三种, "A"代表字符,"S"代表数值, "P"代表packed decimal,对于数值字段,你必须指明小数点的位置,这里,公司号码字段就是一个3个数字的号码,没有小数点,客户号码和邮政编码同样是数字,也是没有小数,而信用额度是一个数值,它一个有9个数字,其中两位数值位于小数点后面,其他的都是字符的定义

Once you have entered the DDS source code, you must compile it. You do this by keying option 14 next to your member name on the PDM screen. If you pay attention you will see that the AS/400 is actually executing the CRTPF (Create Physical File) command. It knows to use this command because the member type of the source code is "PF". 
一旦你输入完DDS代码,你必须编译它,在PDM界面中,在你要编译Member名字的后面输入14.假如你细心一点,你会发现AS400实际执行了CRTPF (Create Physical File)命令,这是因为这个Member的类型是"PF"

You now have a database physical file, see Figure 1. This file has built into it the fields and their attributes. Let's modify this file definition to add key fields. If a physical file has key fields, programs can randomly access the records or read them sequentially in the order of the key fields.
现在你已经有了数据库物理文件,如图1,这个文件包含了字段和他们的属性,现在我们就为文件增加key字段,假如这个物理文件包含了key字段,那么程序就可以通过Key随即的访问或者顺许的访问记录

You can see in Figure 2 that it is simple to add key fields. 
看图2,建立key字段是非常简单的

The "UNIQUE" record at the beginning of the source is used if you want the AS/400 to insist on having no records with duplicate keys. This is optional. At the end of the source code, there are two lines with "K" in position 17. These lines define the key fields. So, this file will build a key using the company number and then the customer number. Further, it will not allow a duplicate company number / customer number record to be written. 
开头的那个"UNIQUE"表明了你要AS400不能含有重复key的Record,这是可选的. 代码的末尾最后两行,在位置17的有两个"K",这两个"K"就是定义key字段了,那么,这个文件就会用公司号码和客户号码来建立key,进一步来说,文件不允许含有公司号码和客户号码都相同的recored.

The records are written to the file in arrival sequence. If you read the data by specifying keyed access, the records will read as though they have been sorted by company number and customer number. Also, your programs can randomly retrieve records. For example, a "CHAIN" instruction in RPG can now randomly read the record for a specific company number / customer number. 
Record是按顺序写入文件的,而假如你读取数据的时候指明key,读取的数据是已经按照公司号码和客户号码排好顺序,同时,你也可以随即读取Record,例如,RPG的"CHAIN"说明符就可以用公司号码和客户号码随即读取文件

Figure 1 - DDS for Physical File Without Key 
     A          R CUREC                    TEXT('CUSTOMER FILE')   
     A            CUCO           3S 0      TEXT('COMPANY #')       
     A            CUSTS          1A        TEXT('STATUS CODE')     
     A            CUNUM          5S 0      TEXT('CUSTOMER #')      
     A            CUNAME        30A        TEXT('CUSTOMER NAME')   
     A            CUADR         30A        TEXT('CUSTOMER ADDRESS') 
     A            CUCITY        18A        TEXT('CUSTOMER CITY')   
     A            CUSTAT         2A        TEXT('CUSTOMER STATE')  
     A            CUZIP          9S 0      TEXT('CUSTOMER ZIP')        
     A            CUCRLM         9P 2      TEXT('CUST CREDIT LIMIT')         
                      
Figure 2 - DDS for Physical File With Key Fields
     A                                     UNIQUE                  
     A          R CUREC                    TEXT('CUSTOMER FILE')   
     A            CUCO           3S 0      TEXT('COMPANY #')       
     A            CUSTS          1A        TEXT('STATUS CODE')     
     A            CUNUM          5S 0      TEXT('CUSTOMER #')      
     A            CUNAME        30A        TEXT('CUSTOMER NAME')   
     A            CUADR         30A        TEXT('CUSTOMER ADDRESS') 
     A            CUCITY        18A        TEXT('CUSTOMER CITY')   
     A            CUSTAT         2A        TEXT('CUSTOMER STATE')  
     A            CUZIP          9S 0      TEXT('CUSTOMER ZIP')    
     A            CUCRLM         9P 2      TEXT('CUST CREDIT LIMIT')              
      *                                                             
     A          K CUCO                                              
     A          K CUNUM 
posted @ 2013-09-04 16:59 Eric_jiang 阅读(449) | 评论 (0)编辑 收藏

Nouns of either gender
阳性或者阴性皆可的名词

 
A few nouns can be either masculine or feminine. Relatively common among these are:
diabetes (also diabete) ‘diabetes’, suéter ‘sweater’ (more often encountered as masculine) and hélice ‘propeller’ (which is more commonly feminine, though can be masculine when
referring to the propeller of a ship or boat).
 
有一些名词,它们是阳性或者阴性皆可的,其中比较常见的是diabetes (also diabete) ‘diabetes’ 糖尿病, suéter ‘sweater’ 羊毛衫(通常都是阳性的)和 hélice ‘propeller’ 螺旋桨,推进器(通常都是阴性的,但是它也可以是阳性的,当涉及的是轮船或者是小艇。
posted @ 2013-09-03 16:47 Eric_jiang 阅读(274) | 评论 (2)编辑 收藏

The gender of a hyphenated compound noun is usually determined by the gender of the first noun in the compound, e.g. posto-chave ‘key post’, which is masculine like posto,and meia-noite, which is feminine like noite. Compounds that begin with a verb stem are masculine, e.g. guarda-chuva ‘umbrella’, para-brisa ‘windscreen’.
 
复合名词的性一般取决于第一个名词的性,例如,posto-chave ‘key post’,关键岗位,它们都是阳性的,正如posto邮递,和meia-noite午夜,而noite是阴性的,那些由动词开头的复合名词是阳性的,例如,guarda-chuva ‘umbrella‘伞,para-brisa ‘windscreen’.挡风玻璃
 
However, compounds referring to people can be masculine or feminine, depending on the sex of the person referred to, regardless of the original gender of the component noun, e.g.sem-teto ‘homeless person’, cabeça-dura ‘pigheaded person’, porta-voz ‘spokesperson’,relações-públicas ‘PR manager’.
 
但是,那些涉及到人复合名词,即可以是阳性的也可以是女性的,这决定于所提及的人的性别,
不管这个复合名词原本的性,例如,sem-teto ‘homeless person’无家可归的人, cabeça-dura ‘pigheaded person’固执的人, porta-voz ‘spokesperson’代言人,relações-públicas ‘PR manager’公共关系经理
posted @ 2013-09-03 16:29 Eric_jiang 阅读(235) | 评论 (0)编辑 收藏

Words that are masculine by implication
隐含为阳性的名词

 
The following nouns are masculine by implication, i.e. there is an unexpressed noun
(shown below in parentheses) which determines their gender:
下面这些名词隐含地为阳性的,
 
(i) months of the year (mês): abril próximo ‘next April’; 月份,下一个四月
(ii) rivers, seas, mountains (rio, mar/oceano, monte): o Amazonas ‘the Amazon’, o Pacífico ‘the Pacific’;河流,海洋,山,阿马逊河,太平洋

(iii) cardinal points (ponto cardeal): ao norte ‘to the north’; 基本方位,在北方
(iv) cars, planes, ships (carro, avião, navio): um Fiat ‘a Fiat’, o Titanic ‘the Titanic’;车,飞机,轮船,一台菲亚特,泰坦尼克号
(v) bars, restaurants, hotels (bar, restaurante, hotel): o Hilton ‘the Hilton’;吧,饭馆,酒店,希尔顿酒店
(vi) newspapers (jornal): o New York Times ‘the New York Times’;报纸杂志,纽约时代杂志
(vii) sports teams (time): o Corinthians ‘Corinthians’;运动,业余运动员
(viii) letters of the alphabet: dois fs ‘two fs’.字母表的字符,两个fs
 
Words that are feminine by implication
下面这些名词隐含地为阴性的,
 
(i) cities (cidade): toda Paris ‘all of Paris’, except when the city name contains the masculine definite article, e.g. o Rio de Janeiro (masc.); 城市,巴黎,除了那些城市名词包含了阳性的冠词,例如,里约热内卢
(ii) streets (rua): na esquina da Visconde ‘on the corner of Visconde’;街道,
(iii) TV networks (rede): na CNN ‘on CNN’;电视网络,例如CNN
(iv) companies, shops, airlines (empresa, loja, companhia): a Microsoft ‘Microsoft’. 公司,商店,航班,微软
 
posted @ 2013-09-03 15:49 Eric_jiang 阅读(258) | 评论 (0)编辑 收藏

Nouns that are masculine or feminine depending on meaning,

根据意思决定阳性或者是阴性的名词

 
Some words can be masculine or feminine depending on the meaning. Here are some common examples:
 
某些名词的阳性或者是阴性,取决于这个词的在情景中的意思,下面是一些常用的例子
                   作为阳性名词                                        作为阴性名词
As masculine noun                                                 As feminine noun
Capital     capital (= money) 资金                            capital (= city) 城市
Cara         guy          家伙                                       face 名字
grama     gram (= measure) 尺寸                            grass 玻璃
guia         guide (= man or book) 男人或者书            guide (= woman); form, slip   失误,口误;   事故
moral   morale morality; 道德观                             moral (of a story) 寓意,教训
rádio       radio;       无线电                                    radium radio station. 无线电电台
posted @ 2013-09-03 15:20 Eric_jiang 阅读(292) | 评论 (0)编辑 收藏

The following nouns are grammatically masculine only, but can refer to females as well
as males: cônjuge ‘spouse’, indivíduo ‘individual’, ser ‘being’.The following nouns are grammatically feminine only, but can refer to males as well as females: criança ‘child’, pessoa ‘person’, testemunha ‘witness’, vítima ‘victim’.
 
下面这些名词,在语法上只能用于男性,但是也可以用于女性。cônjuge ‘spouse’,配偶, indivíduo ‘individual’个人, ser ‘being’是.下面这些名词在语法上只能用于女性,但是也可以用于男性。criança ‘child’ 孩子, pessoa ‘person’ 人, testemunha ‘witness’ 目击证人, vítima ‘victim’受害者.
posted @ 2013-09-03 14:55 Eric_jiang 阅读(205) | 评论 (0)编辑 收藏

仅列出标题
共57页: First 上一页 16 17 18 19 20 21 22 23 24 下一页 Last