├── .classpath
├── .gitignore
├── .project
├── README.md
├── bin
├── rest-testscript-0.1.jar
├── run.bat
└── run.sh
├── build.xml
├── conf
└── log4j.properties
├── doc
└── img
│ └── example-rest.jpg
├── lib
├── commons-beanutils-1.8.0.jar
├── commons-codec-1.3.jar
├── commons-collections-3.2.jar
├── commons-httpclient-3.1.jar
├── commons-io-1.4.jar
├── commons-lang-2.5.jar
├── commons-logging-1.1.1.jar
├── commons-pool-1.5.4.jar
├── ezmorph-1.0.6.jar
├── fastjson-1.1.15.jar
├── httpclient-4.0.1.jar
├── json-lib-2.3-jdk15.jar
├── log4j-1.2.15.jar
├── slf4j-api-1.6.1.jar
└── slf4j-log4j12-1.6.1.jar
├── script
├── Readme.txt
├── es
│ ├── add
│ │ └── import-0.txt
│ ├── query
│ │ └── bitquery-0.txt
│ ├── randkwd.txt
│ ├── randkwd2.txt
│ ├── schema
│ │ ├── add.txt
│ │ └── mapping.txt
│ └── test.properties
├── es_mem
│ ├── add
│ │ └── import-0.txt
│ ├── query
│ │ └── bitquery-0.txt
│ ├── randkwd.txt
│ ├── randkwd2.txt
│ ├── schema
│ │ ├── add.txt
│ │ └── mapping.txt
│ └── test.properties
├── hash
│ ├── clean
│ │ └── delete.txt
│ ├── edit
│ │ ├── attr
│ │ │ └── attr_ca.txt
│ │ ├── bit-1.txt
│ │ ├── bit-2.txt
│ │ ├── delbyid
│ │ │ └── delete.txt
│ │ └── delbyquery
│ │ │ └── delete.txt
│ ├── import
│ │ ├── dir1
│ │ │ └── import-0.txt
│ │ ├── import-0.txt
│ │ ├── import-1.txt
│ │ ├── import-2.txt
│ │ ├── import-3.txt
│ │ ├── import-4.txt
│ │ ├── import-5.txt
│ │ └── import-6.txt
│ ├── performance
│ │ ├── import
│ │ │ └── import-0.txt
│ │ └── query
│ │ │ ├── bitquery-0.txt
│ │ │ └── bitquery-00.txt
│ ├── query
│ │ ├── attr
│ │ │ └── attrquery.txt
│ │ ├── bitquery-00.txt
│ │ ├── bitquery-1.txt
│ │ ├── bitquery-2.txt
│ │ └── qt
│ │ │ ├── bitquery-0.txt
│ │ │ └── qt.txt
│ ├── randkwd.txt
│ ├── randkwd2.txt
│ ├── schema
│ │ └── schema-1.txt
│ └── test.properties
├── jetty
│ ├── jsp
│ │ └── index.txt
│ ├── servlet
│ │ └── test.txt
│ └── test.properties
└── netty
│ ├── get
│ └── demo.txt
│ └── test.properties
└── src
└── org
└── langke
├── testscript
├── Test.java
├── WebBench.java
├── cmd
│ ├── Cmd.java
│ ├── CmdFactory.java
│ ├── Concurrent.java
│ ├── ForEach.java
│ └── Sleep.java
├── common
│ ├── FileUtil.java
│ ├── HttpClientUtil.java
│ ├── HttpSupporter.java
│ ├── Response.java
│ ├── Strings.java
│ └── TestConfig.java
└── tag
│ ├── Querywd.java
│ ├── RandInt.java
│ ├── SeqInt.java
│ ├── Tag.java
│ └── TagFactory.java
└── util
└── logging
├── ESLogger.java
├── ESLoggerFactory.java
├── Loggers.java
├── jdk
├── JdkESLogger.java
└── JdkESLoggerFactory.java
├── log4j
├── ConsoleAppender.java
├── JLinePatternLayout.java
├── Log4jESLogger.java
├── Log4jESLoggerFactory.java
└── LogConfigurator.java
├── slf4j
├── Slf4jESLogger.java
└── Slf4jESLoggerFactory.java
└── support
├── AbstractESLogger.java
├── LoggerMessageFormat.java
└── PrintLogger.java
/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /logs
2 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | rest-testscript
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jdt.core.javanature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | rest-testscript
2 | ===============
3 |
4 | base rest testscript 这是一个基于java http connection 、httpclient写的测试框架,可用于并发测试、性能测试,测试驱动开发等场景 可以支持自增、随机、循环、并发等标签
5 |
6 | 运行用例:
7 |
8 | linux:
9 | cd /data/search/rest-testscript/bin
10 | sh run.sh hash query
11 | sh run.sh -c100 -t60 url
12 | win:
13 | cd D:\workspaces\rest-testscript\bin
14 | run.bat hash query
15 |
16 |
17 | ###快捷并发测试
18 | 类似webbench方式进行压力测试
19 | sh run.sh -c10000 -t60 http://localhost:9900/demo/test?a=b
20 |
21 |
22 | ###编写测试用例
23 |
24 | cd rest-testscript/bin
25 | mkdir -p ../script/jetty/jsp
26 | vi ../script/jetty/test.properties
27 | #
28 | BASE_URL=http\://localhost
29 | PORT=9009
30 | INDEX_NAME=
31 | #Tag
32 | RANDINT=
33 | SEQINT=
34 | QUERYWD=
35 | QUERYWD.PATH=
36 | #Command
37 | SLEEP=
38 | FOREACH=
39 | CONCURRENT=
40 |
41 | vi ../script/jetty/jsp/index.txt
42 | ${BASE_URL}:${PORT}/index.jsp
43 |
44 | GET
45 |
46 |
47 |
48 | ${CONCURRENT.300_100}
49 |
50 |
51 | 执行结果
52 |
53 |
54 | 读取运行测试用例脚本 Usage: org.langke.testscript.Test
55 | project测试脚本项目目录名称,
56 | operate测试步骤目录名称,可以是all表示递归执行该目录下所有脚本
57 | scriptSubDir 子目录名 执行步骤目录下子目录脚本
58 | 只执行.txt格式脚本,每个步骤目录下可以有子目录,程序会递归执行
59 |
60 | 标签配置在每个脚本项目根目录下test.properties文件里,在运行时:
61 | 简单标签会把脚本里标签替换成properties文件里key对应的值
62 | COST_TIME=costTime 用于并发时取服务端返回执行时间的JSON串
63 |
64 | 生成器标签:
65 | SEQINT,自增整数 Usage:${SEQINT.0} 0表初始值
66 | RANDINT,随机整数 Usage:${RANDINT.0_1000} 0_1000表随机值范围
67 | QUERYWD,随机关键词 Usage:${QUERYWD.RAND} 也可指定随机关键词文件${QUERYWD.randkwd2.txt}或者properties文件配合QUERYWD.PATH=randkwd.txt配置关键词文件,如果没有则生成英文数字混合随机字符串
68 | RANDINT,QUERYWD有设置随机种子数,也就是每次运行的随机顺序的值会相同
69 |
70 | 指令标签,(配置在测试脚本第五段,如果没有第四段需要留出空行):
71 | SLEEP,等待指令,Usage:${SLEEP.10} 10表等10秒,可以是浮点数 ,可用于schema创建时等待shard分配等等
72 | FOREACH,循环指令,Usage:${FOREACH.10} 10表循环10次
73 | CONCURRENT,并发指令Usage:${CONCURRENT.100_200} 100表并发数,200表任务执行个数, 并发结果汇报ResponseCode,ResponseMessage
74 |
75 | 测试脚本格式:
76 | 第一段URL,第二段METHOD,第三段请求BODY,第四段预计结果;第五段指令${FOREACH} ${SLEEP}
77 | 以空行区分每个段落,注意脚本格式:为空的段落需要留出空白段
78 |
79 |
--------------------------------------------------------------------------------
/bin/rest-testscript-0.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/langke93/rest-testscript/ed4393696a7c870e08e55ebfd6335fc2ad2c148f/bin/rest-testscript-0.1.jar
--------------------------------------------------------------------------------
/bin/run.bat:
--------------------------------------------------------------------------------
1 | @setlocal enabledelayedexpansion
2 | @set classpath=.
3 | @for %%c in (..\lib\*.jar) do @set classpath=!classpath!;%%c
4 | @for %%c in (..\bin\*.jar) do @set classpath=!classpath!;%%c
5 |
6 | java -DSEARCH.home=../ -cp "%classpath%" org.langke.testscript.Test %*
7 |
--------------------------------------------------------------------------------
/bin/run.sh:
--------------------------------------------------------------------------------
1 | classpath=.
2 | for i in `ls ../lib/*.jar`;
3 | do classpath=$classpath:$i;
4 | done
5 | for i in `ls ../bin/*.jar`;
6 | do classpath=$classpath:$i;
7 | done
8 | LOG=-DLOG=$1
9 | ARG1=$1
10 | echo $LOG, ARG1=$ARG1
11 | #echo $classpath
12 | java -DSEARCH.home=../ $LOG -cp "${classpath}" org.langke.testscript.Test $ARG1 $2 $3
--------------------------------------------------------------------------------
/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/conf/log4j.properties:
--------------------------------------------------------------------------------
1 |
2 |
3 | ############################################################
4 | # Define some default values that can be overridden by system properties
5 | search.root.logger=INFO,console
6 | search.log.dir=../logs
7 | search.log.file=${LOG}_search.log
8 |
9 |
10 | # Define the root logger to the system property "search.root.logger".
11 | log4j.rootLogger=${search.root.logger},DRFA
12 |
13 | # Logging Threshold
14 | log4j.threshhold=ALL
15 |
16 | #
17 | # Daily Rolling File Appender
18 | #
19 | log4j.appender.DRFA=org.apache.log4j.DailyRollingFileAppender
20 | log4j.appender.DRFA.File=${search.log.dir}/${search.log.file}
21 |
22 | # Rollver at midnight
23 | log4j.appender.DRFA.DatePattern=.yyyy-MM-dd
24 |
25 | # 30-day backup
26 | #log4j.appender.DRFA.MaxBackupIndex=30
27 | log4j.appender.DRFA.layout=org.apache.log4j.PatternLayout
28 |
29 | # Pattern format: Date LogLevel LoggerName LogMessage
30 | log4j.appender.DRFA.layout.ConversionPattern=%d{ISO8601} %p %c: %m%n
31 |
32 | # Debugging Pattern format
33 | #log4j.appender.DRFA.layout.ConversionPattern=%d{ISO8601} %-5p %c{2} (%F:%M(%L)) - %m%n
34 |
35 |
36 | #
37 | # console
38 | # Add "console" to rootlogger above if you want to use this
39 | #
40 | log4j.appender.console=org.apache.log4j.ConsoleAppender
41 | log4j.appender.console.target=System.err
42 | log4j.appender.console.layout=org.apache.log4j.PatternLayout
43 | log4j.appender.console.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %p %c{2}: %m%n
44 |
45 | # Custom Logging levels
46 |
47 | log4j.logger.org.apache.zookeeper=INFO
48 | #log4j.logger.org.apache.hadoop.fs.FSNamesystem=DEBUG
49 | log4j.logger.org.apache.hadoop.search=DEBUG
50 | #log4j.logger.org.apache.hadoop.dfs=DEBUG
51 |
--------------------------------------------------------------------------------
/doc/img/example-rest.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/langke93/rest-testscript/ed4393696a7c870e08e55ebfd6335fc2ad2c148f/doc/img/example-rest.jpg
--------------------------------------------------------------------------------
/lib/commons-beanutils-1.8.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/langke93/rest-testscript/ed4393696a7c870e08e55ebfd6335fc2ad2c148f/lib/commons-beanutils-1.8.0.jar
--------------------------------------------------------------------------------
/lib/commons-codec-1.3.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/langke93/rest-testscript/ed4393696a7c870e08e55ebfd6335fc2ad2c148f/lib/commons-codec-1.3.jar
--------------------------------------------------------------------------------
/lib/commons-collections-3.2.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/langke93/rest-testscript/ed4393696a7c870e08e55ebfd6335fc2ad2c148f/lib/commons-collections-3.2.jar
--------------------------------------------------------------------------------
/lib/commons-httpclient-3.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/langke93/rest-testscript/ed4393696a7c870e08e55ebfd6335fc2ad2c148f/lib/commons-httpclient-3.1.jar
--------------------------------------------------------------------------------
/lib/commons-io-1.4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/langke93/rest-testscript/ed4393696a7c870e08e55ebfd6335fc2ad2c148f/lib/commons-io-1.4.jar
--------------------------------------------------------------------------------
/lib/commons-lang-2.5.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/langke93/rest-testscript/ed4393696a7c870e08e55ebfd6335fc2ad2c148f/lib/commons-lang-2.5.jar
--------------------------------------------------------------------------------
/lib/commons-logging-1.1.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/langke93/rest-testscript/ed4393696a7c870e08e55ebfd6335fc2ad2c148f/lib/commons-logging-1.1.1.jar
--------------------------------------------------------------------------------
/lib/commons-pool-1.5.4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/langke93/rest-testscript/ed4393696a7c870e08e55ebfd6335fc2ad2c148f/lib/commons-pool-1.5.4.jar
--------------------------------------------------------------------------------
/lib/ezmorph-1.0.6.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/langke93/rest-testscript/ed4393696a7c870e08e55ebfd6335fc2ad2c148f/lib/ezmorph-1.0.6.jar
--------------------------------------------------------------------------------
/lib/fastjson-1.1.15.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/langke93/rest-testscript/ed4393696a7c870e08e55ebfd6335fc2ad2c148f/lib/fastjson-1.1.15.jar
--------------------------------------------------------------------------------
/lib/httpclient-4.0.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/langke93/rest-testscript/ed4393696a7c870e08e55ebfd6335fc2ad2c148f/lib/httpclient-4.0.1.jar
--------------------------------------------------------------------------------
/lib/json-lib-2.3-jdk15.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/langke93/rest-testscript/ed4393696a7c870e08e55ebfd6335fc2ad2c148f/lib/json-lib-2.3-jdk15.jar
--------------------------------------------------------------------------------
/lib/log4j-1.2.15.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/langke93/rest-testscript/ed4393696a7c870e08e55ebfd6335fc2ad2c148f/lib/log4j-1.2.15.jar
--------------------------------------------------------------------------------
/lib/slf4j-api-1.6.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/langke93/rest-testscript/ed4393696a7c870e08e55ebfd6335fc2ad2c148f/lib/slf4j-api-1.6.1.jar
--------------------------------------------------------------------------------
/lib/slf4j-log4j12-1.6.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/langke93/rest-testscript/ed4393696a7c870e08e55ebfd6335fc2ad2c148f/lib/slf4j-log4j12-1.6.1.jar
--------------------------------------------------------------------------------
/script/Readme.txt:
--------------------------------------------------------------------------------
1 | 运行用例:
2 | linux:
3 | cd /data/search/rest-testscript/bin
4 | sh run.sh hash query
5 | sh run.sh -c100 -t60 url
6 | win:
7 | cd D:\workspaces\rest-testscript\bin
8 | run.bat hash query
9 |
10 | 读取运行测试用例脚本 Usage: org.langke.testscript.Test
11 | -c 并发数
12 | -t 执行时间
13 | url GET访问地址
14 | project测试脚本项目目录名称,
15 | operate测试步骤目录名称,可以是all表示递归执行该目录下所有脚本
16 | scriptSubDir 子目录名 执行步骤目录下子目录脚本
17 | 只执行.txt格式脚本,每个步骤目录下可以有子目录,程序会递归执行
18 | 标签配置在每个脚本项目根目录下test.properties文件里,在运行时:
19 | 简单标签会把脚本里标签替换成properties文件里key对应的值
20 | COST_TIME=costTime 用于并发时取服务端返回执行时间的JSON串
21 | 生成器标签:
22 | SEQINT,自增整数 Usage:${SEQINT.0} 0表初始值
23 | RANDINT,随机整数 Usage:${RANDINT.0_1000} 0_1000表随机值范围
24 | QUERYWD,随机关键词 Usage:${QUERYWD.RAND} 也可指定随机关键词文件${QUERYWD.randkwd2.txt}或者properties文件配合QUERYWD.PATH=randkwd.txt配置关键词文件,如果没有则生成英文数字混合随机字符串
25 | RANDINT,QUERYWD有设置随机种子数,也就是每次运行的随机顺序的值会相同
26 | 指令标签,(配置在测试脚本第五段,如果没有第四段需要留出空行):
27 | SLEEP,等待指令,Usage:${SLEEP.10} 10表等10秒,可以是浮点数 ,可用于schema创建时等待shard分配等等
28 | FOREACH,循环指令,Usage:${FOREACH.10} 10表循环10次
29 | CONCURRENT,并发指令Usage:${CONCURRENT.100_200} 100表并发数,200表任务执行个数, 并发结果汇报ResponseCode,ResponseMessage
30 | 测试脚本格式:
31 | 第一段URL,第二段METHOD,第三段请求BODY,第四段预计结果;第五段指令${FOREACH} ${SLEEP}
32 | 以空行区分每个段落,注意脚本格式:为空的段落需要留出空白段
--------------------------------------------------------------------------------
/script/es/add/import-0.txt:
--------------------------------------------------------------------------------
1 | ${BASE_URL}:${PORT}/${INDEX_NAME}/_default_/${SEQINT.0}
2 |
3 | POST
4 |
5 | {
6 | "id" : "${SEQINT.0}",
7 | "ttint" : "10",
8 | "ttlong" : "10002",
9 | "ttfloat" : "64.111",
10 | "ttdouble" : "9000.6666",
11 | "ttdatetime" : "2000-02-02T02:03:03",
12 | "tttext0" : "functional${SEQINT.0}",
13 | "tttext1" : "测试文本${SEQINT.0}",
14 | "tttext2" : "D&G杜嘉班纳 皮带1",
15 | "tttext3" : "D&G/杜嘉班纳",
16 | "tttext4" : "有三笔美国对台军售项目遭美国国务院",
17 | "tttext5" : "Q&A",
18 | "tttext6" : "测试中国,P&G",
19 | "tttext7" : "${QUERYWD.randkwd2.txt}",
20 | "dx_1" : "环球网30日消息",
21 | "dx_2" : "美国国防部今天宣布",
22 | "txt_1" : "出售给台湾、,已经发包给波音公司(Boeing)",
23 | "txt_2" : "预计2011年6月可以完成.",
24 | "index_no" : "index not_analyzed storetrue",
25 | "store_no" : "termVector with_positions_offsets index not_analyzed"
26 | }
27 |
28 |
29 | ${CONCURRENT.100_100000}
30 | #${FOREACH.1000}
31 |
--------------------------------------------------------------------------------
/script/es/query/bitquery-0.txt:
--------------------------------------------------------------------------------
1 | ${BASE_URL}:${PORT}/${INDEX_NAME}/_default_/_search?q=tttext0:functional${SEQINT.0}
2 |
3 | GET
4 |
5 |
6 |
7 |
8 | ${CONCURRENT.300_1000}
9 | #${SLEEP.60}
10 |
--------------------------------------------------------------------------------
/script/es/randkwd.txt:
--------------------------------------------------------------------------------
1 | 脚本
2 | 测试
3 | 随机
4 | 字符串
--------------------------------------------------------------------------------
/script/es/randkwd2.txt:
--------------------------------------------------------------------------------
1 | 自定义路径
2 | 脚本
3 | 测试
4 | 随机
5 | 字符串
--------------------------------------------------------------------------------
/script/es/schema/add.txt:
--------------------------------------------------------------------------------
1 | ${BASE_URL}:${PORT}/${INDEX_NAME}
2 |
3 | PUT
4 |
5 | {
6 | settings: {
7 | "index.number_of_replicas": 1,
8 | "index.number_of_shards": 5,
9 | "index.store.type": "mmapfs"
10 | }
11 | }
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/script/es/schema/mapping.txt:
--------------------------------------------------------------------------------
1 | ${BASE_URL}:${PORT}/${INDEX_NAME}/_default_/_mapping
2 |
3 | PUT
4 |
5 | {
6 | "_default_":{
7 | "_source": {
8 | "compress": true
9 | },
10 | "properties": {
11 | "id": {
12 | "index" : "not_analyzed",
13 | "type": "long"
14 | },
15 | "ttint": {
16 | "index" : "not_analyzed",
17 | "type": "integer"
18 | },
19 | "ttlong": {
20 | "index" : "not_analyzed",
21 | "type": "long"
22 | },
23 | "ttfloat": {
24 | "index" : "not_analyzed",
25 | "type": "float"
26 | },
27 | "ttdouble": {
28 | "index" : "not_analyzed",
29 | "type": "double"
30 | },
31 | "ttdouble": {
32 | "index" : "not_analyzed",
33 | "type": "double"
34 | },
35 | "ttdatetime": {
36 | "type": "date"
37 | },
38 | "tttext0": {
39 | "type": "string"
40 | },
41 | "tttext1": {
42 | "index" : "not_analyzed",
43 | "type": "string"
44 | },
45 | "tttext2": {
46 | "type": "string"
47 | },
48 | "tttext3": {
49 | "type": "string"
50 | },
51 | "tttext4": {
52 | "type": "string"
53 | },
54 | "tttext5": {
55 | "type": "string"
56 | },
57 | "tttext6": {
58 | "type": "string"
59 | },
60 | "tttext7": {
61 | "type": "string"
62 | },
63 | "dx_1": {
64 | "type": "string",
65 | "index":"no"
66 | },
67 | "dx_2": {
68 | "type": "string",
69 | "index":"no"
70 | },
71 | "txt_1": {
72 | "type": "string",
73 | "index":"no"
74 | },
75 | "txt_2": {
76 | "type": "string",
77 | "index":"no"
78 | },
79 | "index_no": {
80 | "type": "string",
81 | "index":"no"
82 | },
83 | "store_no": {
84 | "type": "string",
85 | "store":"no"
86 | },
87 | "null_value": {
88 | "type": "boolean",
89 | "null_value":true
90 | }
91 | }
92 | }
93 | }
94 |
95 |
96 |
--------------------------------------------------------------------------------
/script/es/test.properties:
--------------------------------------------------------------------------------
1 | #
2 | BASE_URL=http\://dfs1
3 | PORT=9200
4 | INDEX_NAME=test
5 | COST_TIME=took
6 | #Tag
7 | RANDINT=
8 | SEQINT=
9 | QUERYWD=
10 | QUERYWD.PATH=randkwd.txt
11 | #Command
12 | SLEEP=
13 | FOREACH=
14 | CONCURRENT=
15 |
--------------------------------------------------------------------------------
/script/es_mem/add/import-0.txt:
--------------------------------------------------------------------------------
1 | ${BASE_URL}:${PORT}/${INDEX_NAME}/_default_/${SEQINT.0}
2 |
3 | POST
4 |
5 | {
6 | "id" : "${SEQINT.0}",
7 | "ttint" : "10",
8 | "ttlong" : "10002",
9 | "ttfloat" : "64.111",
10 | "ttdouble" : "9000.6666",
11 | "ttdatetime" : "2000-02-02T02:03:03",
12 | "tttext0" : "functional${SEQINT.0}",
13 | "tttext1" : "测试文本${SEQINT.0}",
14 | "tttext2" : "D&G杜嘉班纳 皮带1",
15 | "tttext3" : "D&G/杜嘉班纳",
16 | "tttext4" : "有三笔美国对台军售项目遭美国国务院",
17 | "tttext5" : "Q&A",
18 | "tttext6" : "测试中国,P&G",
19 | "tttext7" : "${QUERYWD.randkwd2.txt}",
20 | "dx_1" : "环球网30日消息",
21 | "dx_2" : "美国国防部今天宣布",
22 | "txt_1" : "出售给台湾、,已经发包给波音公司(Boeing)",
23 | "txt_2" : "预计2011年6月可以完成.",
24 | "index_no" : "index not_analyzed storetrue",
25 | "store_no" : "termVector with_positions_offsets index not_analyzed"
26 | }
27 |
28 |
29 | ${CONCURRENT.100_100000}
30 | #${FOREACH.1000}
31 |
--------------------------------------------------------------------------------
/script/es_mem/query/bitquery-0.txt:
--------------------------------------------------------------------------------
1 | ${BASE_URL}:${PORT}/${INDEX_NAME}/_default_/_search?q=tttext0:functional${SEQINT.0}
2 |
3 | GET
4 |
5 |
6 |
7 |
8 | ${CONCURRENT.300_1000}
9 | #${SLEEP.60}
10 |
--------------------------------------------------------------------------------
/script/es_mem/randkwd.txt:
--------------------------------------------------------------------------------
1 | 脚本
2 | 测试
3 | 随机
4 | 字符串
--------------------------------------------------------------------------------
/script/es_mem/randkwd2.txt:
--------------------------------------------------------------------------------
1 | 自定义路径
2 | 脚本
3 | 测试
4 | 随机
5 | 字符串
--------------------------------------------------------------------------------
/script/es_mem/schema/add.txt:
--------------------------------------------------------------------------------
1 | ${BASE_URL}:${PORT}/${INDEX_NAME}
2 |
3 | PUT
4 |
5 | {
6 | settings: {
7 | "index.number_of_replicas": 1,
8 | "index.number_of_shards": 5,
9 | "index.store.type": "memory"
10 | }
11 | }
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/script/es_mem/schema/mapping.txt:
--------------------------------------------------------------------------------
1 | ${BASE_URL}:${PORT}/${INDEX_NAME}/_default_/_mapping
2 |
3 | PUT
4 |
5 | {
6 | "_default_":{
7 | "_source": {
8 | "compress": true
9 | },
10 | "properties": {
11 | "id": {
12 | "index" : "not_analyzed",
13 | "type": "long"
14 | },
15 | "ttint": {
16 | "index" : "not_analyzed",
17 | "type": "integer"
18 | },
19 | "ttlong": {
20 | "index" : "not_analyzed",
21 | "type": "long"
22 | },
23 | "ttfloat": {
24 | "index" : "not_analyzed",
25 | "type": "float"
26 | },
27 | "ttdouble": {
28 | "index" : "not_analyzed",
29 | "type": "double"
30 | },
31 | "ttdouble": {
32 | "index" : "not_analyzed",
33 | "type": "double"
34 | },
35 | "ttdatetime": {
36 | "type": "date"
37 | },
38 | "tttext0": {
39 | "type": "string"
40 | },
41 | "tttext1": {
42 | "index" : "not_analyzed",
43 | "type": "string"
44 | },
45 | "tttext2": {
46 | "type": "string"
47 | },
48 | "tttext3": {
49 | "type": "string"
50 | },
51 | "tttext4": {
52 | "type": "string"
53 | },
54 | "tttext5": {
55 | "type": "string"
56 | },
57 | "tttext6": {
58 | "type": "string"
59 | },
60 | "tttext7": {
61 | "type": "string"
62 | },
63 | "dx_1": {
64 | "type": "string",
65 | "index":"no"
66 | },
67 | "dx_2": {
68 | "type": "string",
69 | "index":"no"
70 | },
71 | "txt_1": {
72 | "type": "string",
73 | "index":"no"
74 | },
75 | "txt_2": {
76 | "type": "string",
77 | "index":"no"
78 | },
79 | "index_no": {
80 | "type": "string",
81 | "index":"no"
82 | },
83 | "store_no": {
84 | "type": "string",
85 | "store":"no"
86 | },
87 | "null_value": {
88 | "type": "boolean",
89 | "null_value":true
90 | }
91 | }
92 | }
93 | }
94 |
95 |
96 |
--------------------------------------------------------------------------------
/script/es_mem/test.properties:
--------------------------------------------------------------------------------
1 | #
2 | BASE_URL=http\://dfs2
3 | PORT=9200
4 | INDEX_NAME=test_mem
5 | COST_TIME=took
6 | #Tag
7 | RANDINT=
8 | SEQINT=
9 | QUERYWD=
10 | QUERYWD.PATH=randkwd.txt
11 | #Command
12 | SLEEP=
13 | FOREACH=
14 | CONCURRENT=
15 |
--------------------------------------------------------------------------------
/script/hash/clean/delete.txt:
--------------------------------------------------------------------------------
1 | ${BASE_URL}:${PORT}/${INDEX_NAME}/_query?q=*
2 |
3 | DELETE
4 |
5 |
--------------------------------------------------------------------------------
/script/hash/edit/attr/attr_ca.txt:
--------------------------------------------------------------------------------
1 | ${BASE_URL}:${PORT}/${INDEX_NAME}/test1/${SEQINT.1}/_ca
2 |
3 | PUT
4 |
5 | {"ttattrint":2}
6 |
7 | {"ok":true,"affectedCount":1,"qTime":0}
8 |
9 | ${CONCURRENT.2_15000}
--------------------------------------------------------------------------------
/script/hash/edit/bit-1.txt:
--------------------------------------------------------------------------------
1 | ${BASE_URL}:${PORT}/${INDEX_NAME}/c/bit1/_bit?op=and
2 |
3 | PUT
4 |
5 | {"ttattrint":0}
6 |
7 | {"ok":true,"affectedCount":1,"qTime":0}
8 |
9 |
--------------------------------------------------------------------------------
/script/hash/edit/bit-2.txt:
--------------------------------------------------------------------------------
1 | ${BASE_URL}:${PORT}/${INDEX_NAME}/c/bit2/_bit?op=and
2 |
3 | PUT
4 |
5 | {"ttattrint":1}
6 |
7 | {"ok":true,"affectedCount":1,"qTime":0}
8 |
9 |
10 |
--------------------------------------------------------------------------------
/script/hash/edit/delbyid/delete.txt:
--------------------------------------------------------------------------------
1 | ${BASE_URL}:${PORT}/${INDEX_NAME}/test1/${RANDINT.1_30000}
2 |
3 | DELETE
4 |
5 |
6 |
7 | ${CONCURRENT.6_50000}
--------------------------------------------------------------------------------
/script/hash/edit/delbyquery/delete.txt:
--------------------------------------------------------------------------------
1 | ${BASE_URL}:${PORT}/${INDEX_NAME}/_query?q=ttint0:${RANDINT.1_30000}
2 |
3 | DELETE
4 |
5 |
6 |
7 | ${CONCURRENT.6_50000}
--------------------------------------------------------------------------------
/script/hash/import/dir1/import-0.txt:
--------------------------------------------------------------------------------
1 | ${BASE_URL}:${PORT}/${INDEX_NAME}/test1/${SEQINT.11123726}
2 |
3 | POST
4 |
5 | {
6 | "ttbyte0" : "50",
7 | "ttbyte1" : "60",
8 | "ttbyte2" : "70",
9 | "ttshort0" : "80",
10 | "ttshort1" : "90",
11 | "ttshort2" : "100",
12 | "ttint0" : "${SEQINT.11123726}",
13 | "ttint1" : "10",
14 | "ttint2" : "10",
15 | "ttint3" : "10",
16 | "ttlong0" : "10002",
17 | "ttlong1" : "20002",
18 | "ttlong2" : "30002",
19 | "ttlong3" : "30002",
20 | "ttfloat0" : "64.111",
21 | "ttfloat1" : "5.222",
22 | "ttfloat2" : "6.333",
23 | "ttfloat3" : "6.333",
24 | "ttdouble0" : "6700000.4444",
25 | "ttdouble1" : "8000.5555",
26 | "ttdouble2" : "9000.6666",
27 | "ttdouble3" : "9000.6666",
28 | "ttdatetime0" : "2000-02-02 02:03:03",
29 | "ttdatetime1" : "2010/05/02 00-00-00",
30 | "ttdatetime2" : "2020-05-03 00:00:00",
31 | "ttdatetime3" : "2030-05-04 00:00:00",
32 | "ttdatetime4" : "2030-05-05 00:00:00",
33 | "ttstore" : "55woyo",
34 | "tttag0" : "产品 woyo",
35 | "tttag1" : "测试 tagging 55555",
36 | "tttext0" : "functional${SEQINT.11123726}",
37 | "tttext1" : "测试文本${SEQINT.11123726}",
38 | "tttext2" : "D&G杜嘉班纳 皮带1",
39 | "tttext3" : "D&G/杜嘉班纳",
40 | "tttext4" : "有三笔美国对台军售项目遭美国国务院",
41 | "tttext5" : "Q&A",
42 | "tttext6" : "测试中国,P&G",
43 | "tttext7" : "${QUERYWD.randkwd2.txt}",
44 | "dx_1" : "环球网30日消息",
45 | "dx_2" : "美国国防部今天宣布",
46 | "txt_1" : "出售给台湾、,已经发包给波音公司(Boeing)",
47 | "txt_2" : "预计2011年6月可以完成.",
48 | "tdz_1" : "index not_analyzed storetrue",
49 | "tdz_2" : "termVector with_positions_offsets index not_analyzed",
50 | "ttattrint" : "1",
51 | "ttattrdate" : "2012-01-02 01:02:03"
52 | }
53 |
54 |
55 | #${CONCURRENT.1_1000000}
56 | #${FOREACH.1000}
57 |
--------------------------------------------------------------------------------
/script/hash/import/import-0.txt:
--------------------------------------------------------------------------------
1 | ${BASE_URL}:${PORT}/${INDEX_NAME}/test1/25
2 |
3 | POST
4 |
5 | {
6 | "ttbyte0" : "50",
7 | "ttbyte1" : "60",
8 | "ttbyte2" : "70",
9 | "ttshort0" : "80",
10 | "ttshort1" : "90",
11 | "ttshort2" : "100",
12 | "ttint0" : "115",
13 | "ttint1" : "10",
14 | "ttint2" : "10",
15 | "ttint3" : "10",
16 | "ttlong0" : "10002",
17 | "ttlong1" : "20002",
18 | "ttlong2" : "30002",
19 | "ttlong3" : "30002",
20 | "ttfloat0" : "64.111",
21 | "ttfloat1" : "5.222",
22 | "ttfloat2" : "6.333",
23 | "ttfloat3" : "6.333",
24 | "ttdouble0" : "6700000.4444",
25 | "ttdouble1" : "8000.5555",
26 | "ttdouble2" : "9000.6666",
27 | "ttdouble3" : "9000.6666",
28 | "ttdatetime0" : "2000-02-02 02:03:03",
29 | "ttdatetime1" : "2010/05/02 00-00-00",
30 | "ttdatetime2" : "2020-05-03 00:00:00",
31 | "ttdatetime3" : "2030-05-04 00:00:00",
32 | "ttdatetime4" : "2030-05-05 00:00:00",
33 | "ttstore" : "55woyo",
34 | "tttag0" : "产品 woyo",
35 | "tttag1" : "测试 tagging 55555",
36 | "tttext0" : "woyo.com的产品人员56789 测试数据4 soapUI is a tool for functional,testing, mainly of Web Services like SOAP based Web Services and REST Web Services, but also HTTP",
37 | "tttext1" : "测试数据4 soapUI is a tool for functional,testing, mainly of Web Services like SOAP based Web Services and REST Web Services, but also HTTP based services and JMS Services as well as databases. soapUI is an Open Source tool with a commercial companion, soapUI Pro, with extra functionality for companies with mission critical Web Services. soapUI is being produced by the community as well as the Open Source company eviware.soapUI",
38 | "tttext2" : "而针对早前美国《国防新闻》周刊报道称,有三笔美国对台军售项目遭美国国务院\“挡驾\”,而未通知美国国会。台湾军方上个月底也曾表示,目前并未接获有关暂缓军售的讯息,对美国的各项军购案,也依正常程序进行",
39 | "tttext3" : "D&G杜嘉班纳 皮带1",
40 | "tttext4" : "有三笔美国对台军售项目遭美国国务院",
41 | "tttext5" : "测试男,test",
42 | "tttext6" : "测试中国,test",
43 | "tttext7" : "测试汉族,test",
44 | "dx_1" : "测试数据5 环球网30日消息,美国国防部今天宣布,出售给台湾、总价4384万6554美元的32具鱼叉导弹弹体,已经发包给波音公司(Boeing),预计2011年6月可以完成.",
45 | "dx_2" : "测试数据5 soapUI has been downloaded more than one and a half million times and is seen as the de facto standard for Web Service,testing. For you as a user, this means there is a lot of knowledge about the tool out there. We'd like to encourage you to read the blogs on the net for more info about using soapUI in real life. There also is a Community Forum on the eviware website. We appreciate every download and work really hard to create a super product for you. If you have any ideas or thought, please let us know!soapUI",
46 | "txt_1" : "环球网30日消息,美国国防部今天宣布,出售给台湾、总价4384万6554美元的32具鱼叉导弹弹体,已经发包给波音公司(Boeing),预计2011年6月可以完成.",
47 | "txt_2" : "而针对早前美国《国防新闻》周刊报道称,有三笔美国对台军售项目遭美国国务院\“挡驾\”,而未通知美国国会。台湾军方上个月底也曾表示,目前并未接获有关暂缓军售的讯息,对美国的各项军购案,也依正常程序进行",
48 | "tdz_1" : "index not_analyzed storetrue termVector with_positions_offsets",
49 | "tdz_2" : "index not_analyzed storetrue termVector with_positions_offsets index not_analyzed storetrue termVector with_positions_offsets",
50 | "ttattrint" : "61234",
51 | "ttattrdate" : "2012-01-02 01:02:03"
52 | }
53 |
--------------------------------------------------------------------------------
/script/hash/import/import-3.txt:
--------------------------------------------------------------------------------
1 | ${BASE_URL}:${PORT}/${INDEX_NAME}/c/_ma
2 |
3 | POST
4 |
5 | {
6 | "docs" :
7 | [
8 | {
9 | "_id" : "25",
10 | "ttbyte0" : "50",
11 | "ttbyte1" : "60",
12 | "ttbyte2" : "70",
13 | "ttshort0" : "80",
14 | "ttshort1" : "90",
15 | "ttshort2" : "100",
16 | "ttint0" : "115",
17 | "ttint1" : "10",
18 | "ttint2" : "10",
19 | "ttint3" : "10",
20 | "ttlong0" : "10002",
21 | "ttlong1" : "20002",
22 | "ttlong2" : "30002",
23 | "ttlong3" : "30002",
24 | "ttfloat0" : "64.111",
25 | "ttfloat1" : "5.222",
26 | "ttfloat2" : "6.333",
27 | "ttfloat3" : "6.333",
28 | "ttdouble0" : "6700000.4444",
29 | "ttdouble1" : "8000.5555",
30 | "ttdouble2" : "9000.6666",
31 | "ttdouble3" : "9000.6666",
32 | "ttdatetime0" : "2000-02-02 02:03:03",
33 | "ttdatetime1" : "2010/05/02 00-00-00",
34 | "ttdatetime2" : "2020-05-03 00:00:00",
35 | "ttdatetime3" : "2030-05-04 00:00:00",
36 | "ttdatetime4" : "2030-05-05 00:00:00",
37 | "ttstore" : "55woyo",
38 | "tttag0" : "产品 woyo",
39 | "tttag1" : "测试 tagging 55555",
40 | "tttext0" : "woyo.com的产品人员56789 测试数据4 soapUI is a tool for functional,testing, mainly of Web Services like SOAP based Web Services and REST Web Services, but also HTTP",
41 | "tttext1" : "测试数据4 soapUI is a tool for functional,testing, mainly of Web Services like SOAP based Web Services and REST Web Services, but also HTTP based services and JMS Services as well as databases. soapUI is an Open Source tool with a commercial companion, soapUI Pro, with extra functionality for companies with mission critical Web Services. soapUI is being produced by the community as well as the Open Source company eviware.soapUI",
42 | "tttext2" : "而针对早前美国《国防新闻》周刊报道称,有三笔美国对台军售项目遭美国国务院\“挡驾\”,而未通知美国国会。台湾军方上个月底也曾表示,目前并未接获有关暂缓军售的讯息,对美国的各项军购案,也依正常程序进行",
43 | "tttext3" : "测试产品部 aaaaaa",
44 | "tttext4" : "有三笔美国对台军售项目遭美国国务院",
45 | "tttext5" : "测试男,test",
46 | "tttext6" : "测试中国,test",
47 | "tttext7" : "测试汉族,test",
48 | "dx_1" : "测试数据5 环球网30日消息,美国国防部今天宣布,出售给台湾、总价4384万6554美元的32具鱼叉导弹弹体,已经发包给波音公司(Boeing),预计2011年6月可以完成.",
49 | "dx_2" : "测试数据5 soapUI has been downloaded more than one and a half million times and is seen as the de facto standard for Web Service,testing. For you as a user, this means there is a lot of knowledge about the tool out there. We'd like to encourage you to read the blogs on the net for more info about using soapUI in real life. There also is a Community Forum on the eviware website. We appreciate every download and work really hard to create a super product for you. If you have any ideas or thought, please let us know!soapUI",
50 | "txt_1" : "环球网30日消息,美国国防部今天宣布,出售给台湾、总价4384万6554美元的32具鱼叉导弹弹体,已经发包给波音公司(Boeing),预计2011年6月可以完成.",
51 | "txt_2" : "而针对早前美国《国防新闻》周刊报道称,有三笔美国对台军售项目遭美国国务院\“挡驾\”,而未通知美国国会。台湾军方上个月底也曾表示,目前并未接获有关暂缓军售的讯息,对美国的各项军购案,也依正常程序进行",
52 | "tdz_1" : "index not_analyzed storetrue termVector with_positions_offsets",
53 | "tdz_2" : "index not_analyzed storetrue termVector with_positions_offsets index not_analyzed storetrue termVector with_positions_offsets",
54 | "ttattrint" : "61234",
55 | "ttattrdate" : "2012-01-02 01:02:03"
56 | },
57 | {
58 | "_id":"bit1",
59 | "ttattrint":10
60 | },
61 | {
62 | "_id":"bit2",
63 | "ttattrint":10
64 | },
65 | {
66 | "_id":"bit3",
67 | "ttattrint":10
68 | },
69 | {
70 | "_id":"bit4",
71 | "ttattrint":10
72 | },
73 | {
74 | "_id":"bit5",
75 | "ttattrint":10
76 | },
77 | {
78 | "_id":"bit6",
79 | "ttattrint":10
80 | },
81 | {
82 | "_id":"bit7",
83 | "ttattrint":10
84 | },
85 | {
86 | "_id":"bit8",
87 | "ttattrint":10
88 | },
89 | {
90 | "_id":"bit9",
91 | "ttattrint":10
92 | },
93 | {
94 | "_id":"bit10",
95 | "ttattrint":10
96 | }
97 | ]
98 | }
99 |
--------------------------------------------------------------------------------
/script/hash/import/import-4.txt:
--------------------------------------------------------------------------------
1 | ${BASE_URL}:${PORT}/${INDEX_NAME}/d/_ma
2 |
3 | POST
4 |
5 | {
6 | "docs" :
7 | [
8 | {
9 | "_id":"bit11",
10 | "ttattrint":10
11 | },
12 | {
13 | "_id":"bit${QUERYWD.randkwd2.txt}",
14 | "ttattrint":10
15 | },
16 | {
17 | "_id":"bit${QUERYWD.RAND}",
18 | "ttattrint":10
19 | },
20 | {
21 | "_id":"bit${QUERYWD.RAND}",
22 | "ttattrint":10
23 | },
24 | {
25 | "_id":"bit15",
26 | "ttattrint":10
27 | },
28 | {
29 | "_id":"bit16",
30 | "ttattrint":10
31 | },
32 | {
33 | "_id":"bit17",
34 | "ttattrint":10
35 | },
36 | {
37 | "_id":"bit18",
38 | "ttattrint":10
39 | },
40 | {
41 | "_id":"bit19",
42 | "ttattrint":10
43 | },
44 | {
45 | "_id":"bit20",
46 | "ttattrint":10
47 | }
48 | ]
49 | }
50 |
51 |
52 | ${FOREACH.1}
--------------------------------------------------------------------------------
/script/hash/import/import-5.txt:
--------------------------------------------------------------------------------
1 | ${BASE_URL}:${PORT}/${INDEX_NAME}/e/_ma
2 |
3 | POST
4 |
5 | {
6 | "docs" :
7 | [
8 | {
9 | "_id":"bit21",
10 | "ttattrint":10
11 | },
12 | {
13 | "_id":"bit22",
14 | "ttattrint":10
15 | },
16 | {
17 | "_id":"bit23",
18 | "ttattrint":10
19 | },
20 | {
21 | "_id":"bit24",
22 | "ttattrint":10
23 | },
24 | {
25 | "_id":"bit25",
26 | "ttattrint":10
27 | },
28 | {
29 | "_id":"bit26",
30 | "ttattrint":10
31 | },
32 | {
33 | "_id":"bit27",
34 | "ttattrint":10
35 | },
36 | {
37 | "_id":"bit28",
38 | "ttattrint":10
39 | },
40 | {
41 | "_id":"bit29",
42 | "ttattrint":10
43 | },
44 | {
45 | "_id":"bit30",
46 | "ttattrint":10
47 | },
48 | {
49 | "_id":"bit31",
50 | "ttattrint":10
51 | },
52 | {
53 | "_id":"bit32",
54 | "ttattrint":10
55 | },
56 | {
57 | "_id":"bit33",
58 | "ttattrint":10
59 | },
60 | {
61 | "_id":"bit34",
62 | "ttattrint":10
63 | },
64 | {
65 | "_id":"bit35",
66 | "ttattrint":10
67 | }
68 | ]
69 | }
70 |
--------------------------------------------------------------------------------
/script/hash/import/import-6.txt:
--------------------------------------------------------------------------------
1 | ${BASE_URL}:${PORT}/${INDEX_NAME}/f/_ma
2 |
3 | POST
4 |
5 | {
6 | "docs" :
7 | [
8 | {
9 | "_id":"bit36",
10 | "ttattrint":10
11 | },
12 | {
13 | "_id":"bit37",
14 | "ttattrint":10
15 | },
16 | {
17 | "_id":"bit38",
18 | "ttattrint":10
19 | },
20 | {
21 | "_id":"bit39",
22 | "ttattrint":10
23 | },
24 | {
25 | "_id":"bit40",
26 | "ttattrint":10
27 | },
28 | {
29 | "_id":"bit41",
30 | "ttattrint":10
31 | },
32 | {
33 | "_id":"bit42",
34 | "ttattrint":10
35 | },
36 | {
37 | "_id":"bit43",
38 | "ttattrint":10
39 | },
40 | {
41 | "_id":"bit44",
42 | "ttattrint":10
43 | },
44 | {
45 | "_id":"bit45",
46 | "ttattrint":10
47 | },
48 | {
49 | "_id":"bit46",
50 | "ttattrint":10
51 | },
52 | {
53 | "_id":"bit47",
54 | "ttattrint":10
55 | },
56 | {
57 | "_id":"bit48",
58 | "ttattrint":10
59 | }
60 | ]
61 | }
62 |
--------------------------------------------------------------------------------
/script/hash/performance/import/import-0.txt:
--------------------------------------------------------------------------------
1 | ${BASE_URL}:${PORT}/${INDEX_NAME}/test1/${SEQINT.1}
2 |
3 | POST
4 |
5 | {
6 | "ttbyte0" : "50",
7 | "ttbyte1" : "60",
8 | "ttbyte2" : "70",
9 | "ttshort0" : "80",
10 | "ttshort1" : "90",
11 | "ttshort2" : "100",
12 | "ttint0" : "${SEQINT.1}",
13 | "ttint1" : "10",
14 | "ttint2" : "10",
15 | "ttint3" : "10",
16 | "ttlong0" : "10002",
17 | "ttlong1" : "20002",
18 | "ttlong2" : "30002",
19 | "ttlong3" : "30002",
20 | "ttfloat0" : "64.111",
21 | "ttfloat1" : "5.222",
22 | "ttfloat2" : "6.333",
23 | "ttfloat3" : "6.333",
24 | "ttdouble0" : "6700000.4444",
25 | "ttdouble1" : "8000.5555",
26 | "ttdouble2" : "9000.6666",
27 | "ttdouble3" : "9000.6666",
28 | "ttdatetime0" : "2000-02-02 02:03:03",
29 | "ttdatetime1" : "2010/05/02 00-00-00",
30 | "ttdatetime2" : "2020-05-03 00:00:00",
31 | "ttdatetime3" : "2030-05-04 00:00:00",
32 | "ttdatetime4" : "2030-05-05 00:00:00",
33 | "ttstore" : "55woyo",
34 | "tttag0" : "产品 woyo",
35 | "tttag1" : "测试 tagging 55555",
36 | "tttext0" : "woyo.com的产品人员56789 测试数据4 soapUI is a tool for functional,testing, mainly of Web Services like SOAP based Web Services and REST Web Services, but also HTTP",
37 | "tttext1" : "测试数据4 soapUI is a tool for functional,testing, mainly of Web Services like SOAP based Web Services and REST Web Services, but also HTTP based services and JMS Services as well as databases. soapUI is an Open Source tool with a commercial companion, soapUI Pro, with extra functionality for companies with mission critical Web Services. soapUI is being produced by the community as well as the Open Source company eviware.soapUI",
38 | "tttext2" : "而针对早前美国《国防新闻》周刊报道称,有三笔美国对台军售项目遭美国国务院\“挡驾\”,而未通知美国国会。台湾军方上个月底也曾表示,目前并未接获有关暂缓军售的讯息,对美国的各项军购案,也依正常程序进行",
39 | "tttext3" : "测试产品部 aaaaaa",
40 | "tttext4" : "有三笔美国对台军售项目遭美国国务院",
41 | "tttext5" : "测试男,test",
42 | "tttext6" : "测试中国,test",
43 | "tttext7" : "${QUERYWD.randkwd2.txt}",
44 | "dx_1" : "测试数据5 环球网30日消息,美国国防部今天宣布,出售给台湾、总价4384万6554美元的32具鱼叉导弹弹体,已经发包给波音公司(Boeing),预计2011年6月可以完成.",
45 | "dx_2" : "测试数据5 soapUI has been downloaded more than one and a half million times and is seen as the de facto standard for Web Service,testing. For you as a user, this means there is a lot of knowledge about the tool out there. We'd like to encourage you to read the blogs on the net for more info about using soapUI in real life. There also is a Community Forum on the eviware website. We appreciate every download and work really hard to create a super product for you. If you have any ideas or thought, please let us know!soapUI",
46 | "txt_1" : "环球网30日消息,美国国防部今天宣布,出售给台湾、总价4384万6554美元的32具鱼叉导弹弹体,已经发包给波音公司(Boeing),预计2011年6月可以完成.",
47 | "txt_2" : "而针对早前美国《国防新闻》周刊报道称,有三笔美国对台军售项目遭美国国务院\“挡驾\”,而未通知美国国会。台湾军方上个月底也曾表示,目前并未接获有关暂缓军售的讯息,对美国的各项军购案,也依正常程序进行",
48 | "tdz_1" : "index not_analyzed storetrue termVector with_positions_offsets",
49 | "tdz_2" : "index not_analyzed storetrue termVector with_positions_offsets index not_analyzed storetrue termVector with_positions_offsets",
50 | "ttattrint" : "61234",
51 | "ttattrdate" : "2012-01-02 01:02:03"
52 | }
53 |
54 |
55 | ${CONCURRENT.400_5000}
56 | #${FOREACH.1000}
57 |
--------------------------------------------------------------------------------
/script/hash/performance/query/bitquery-0.txt:
--------------------------------------------------------------------------------
1 | ${BASE_URL}:${PORT}/${INDEX_NAME}//_search?q=_all:自定义路径
2 |
3 | GET
4 |
5 |
6 | {"qTime":"16ms","hits":{"total":9,"hits":[
7 | {"_id":"2","_type":"a","_source":{"ttbyte0":"10","ttbyte2":"30","ttshort0":"40","ttshort2":"100","ttint0":"2","ttint2":"130","ttint3":"10","ttlong0":"100000","ttlong2":"300000","ttlong3":"300000","ttfloat0":"4000.111","ttfloat2":"6000.333","ttfloat3":"6000.333","ttdouble0":"700000.4444","ttdouble2":"900000.6666","ttdouble3":"90.6666","ttdatetime0":"2000-02-01 01:02:03","ttdatetime1":"2010/02/02 00-00-00","ttdatetime3":"2030-03-03 00:00:00","ttdatetime4":"2030-03-03 00:00:00","ttstore":"22woyo","tttag0":"2我友 woyo 开发","tttag1":"测试","tttext0":"woyo的开发人员23456,test","tttext1":"sdfsdf,woyo,test,3","tttext4":"波音公司(Boeing),预计2011年6月可以完成.","tttext5":"波音公司(boeing),预计2011年6月可以完成.","tttext6":"测试 中国,test","tttext7":"测试 汉族,test","dx_1":"测试数据2 soapUI is a tool for functional,testing, mainly of Web Services like SOAP based Web Services and REST Web Services, but also HTTP based services and JMS Services as well as databases. soapUI is an Open Source tool with a commercial companion, soapUI Pro, with extra functionality for companies with mission critical Web Services. soapUI is being produced by the community as well as the Open Source company eviware.soapUI","dx_2":"测试数据2 soapUI has been downloaded more than one and a half million times and is seen as the de facto standard for Web Service,testing. For you as a user, this means there is a lot of knowledge about the tool out there. We'd like to encourage you to read the blogs on the net for more info about using soapUI in real life. There also is a Community Forum on the eviware website. We appreciate every download and work really hard to create a super product for you. If you have any ideas or thought, please let us know!soapUI","tdz_1":"index not_analyzed storetrue termVector with_positions_offsets","tdz_2":"index not_analyzed storetrue termVector with_positions_offsets index not_analyzed storetrue termVector with_positions_offsets","_type":"a","_id":"2#a","ttattrdate":"2012-01-01 01:02:03","ttattrint":"3"}},
8 | {"_id":"6","_type":"a","_source":{"ttbyte0":"6","ttbyte2":"30","ttshort0":"40","ttshort2":"100","ttint0":"6","ttint2":"130","ttint3":"130","ttlong0":"600000","ttlong2":"600002","ttlong3":"600003","ttfloat0":"4000.111","ttfloat2":"6000.333","ttfloat3":"6000.333","ttdouble0":"700000.4444","ttdouble2":"900000.6666","ttdouble3":"900000.6666","ttdatetime0":"2000-02-02 02:03:04","ttdatetime1":"2010/02/02 00-00-00","ttdatetime3":"2030-03-03 00:00:00","ttdatetime4":"2030-03-03 00:00:00","ttstore":"11 woyo","tttag0":"1我友 woyo 前台","tttag1":"11111","tttext0":"woyo.com的前台人员12345 测试,⊙﹏⊙b汗","tttext1":"测试 www.woyo.com ,test,3.","tttext4":"测试张一 1111111111111111111111111111111111111111111测试2222222222222222222222222222","tttext5":"测试女,test","tttext6":"测试中国,test","tttext7":"测试汉族,test","dx_1":"测试数据1 soapUI is a tool for functional,testing, mainly of Web Services like SOAP based Web Services and REST Web Services, but also HTTP based services and JMS Services as well as databases. soapUI is an Open Source tool with a commercial companion, soapUI Pro, with extra functionality for companies with mission critical Web Services. soapUI is being produced by the community as well as the Open Source company eviware.soapUI","dx_2":"测试数据1 soapUI has been downloaded more than one and a half million times and is seen as the de facto standard for Web Service,testing. For you as a user, this means there is a lot of knowledge about the tool out there. We'd like to encourage you to read the blogs on the net for more info about using soapUI in real life. There also is a Community Forum on the eviware website. We appreciate every download and work really hard to create a super product for you. If you have any ideas or thought, please let us know!soapUI","tdz_1":"index not_analyzed storetrue策测试termVector with_positions_off测试sets","tdz_2":"index not_analyzed storetrue termVector with_positions_offsets index not_analyzed storetrue termVector with_positions_offsets","_type":"a","_id":"6#a","ttattrdate":"2012-01-01 02:02:03","ttattrint":"12345"}},
9 | {"_id":"7","_type":"a","_source":{"ttbyte0":"7","ttbyte2":"30","ttshort0":"40","ttshort2":"100","ttint0":"7","ttint2":"130","ttint3":"130","ttlong0":"600000","ttlong2":"200002","ttlong3":"300003","ttfloat0":"4000.111","ttfloat2":"6000.333","ttfloat3":"6000.333","ttdouble0":"700000.4444","ttdouble2":"900000.6666","ttdouble3":"900000.6666","ttdatetime0":"2004-01-01 01:02:03","ttdatetime1":"2010/02/02 00-00-00","ttdatetime3":"2030-03-03 00:00:00","ttdatetime4":"2030-03-03 00:00:00","ttstore":"22woyo","tttag0":"2我友 woyo 开发","tttag1":"测试","tttext0":"woyo.com的开发人员23456,test","tttext1":"www.woyo.com 测试","tttext4":"测试 陈二,test","tttext5":"测试 男,test","tttext6":"测试 中国,test","tttext7":"测试 汉族,test","dx_1":"测试数据2 soapUI is a tool for functional,testing, mainly of Web Services like SOAP based Web Services and REST Web Services, but also HTTP based services and JMS Services as well as databases. soapUI is an Open Source tool with a commercial companion, soapUI Pro, with extra functionality for companies with mission critical Web Services. soapUI is being produced by the community as well as the Open Source company eviware.soapUI","dx_2":"测试数据2 soapUI has been downloaded more than one and a half million times and is seen as the de facto standard for Web Service,testing. For you as a user, this means there is a lot of knowledge about the tool out there. We'd like to encourage you to read the blogs on the net for more info about using soapUI in real life. There also is a Community Forum on the eviware website. We appreciate every download and work really hard to create a super product for you. If you have any ideas or thought, please let us know!soapUI","tdz_1":"index not_analyzed storetrue termVector with_positions_offsets","tdz_2":"index not_analyzed storetrue termVector with_positions_offsets index not_analyzed storetrue termVector with_positions_offsets","_type":"a","_id":"7#a","ttattrdate":"2012-01-01 01:03:03","ttattrint":"12345"}},
10 | {"_id":"11","_type":"a","_source":{"ttbyte0":"10","ttbyte2":"30","ttshort0":"40","ttshort2":"100","ttint0":"110","ttint2":"130","ttint3":"10","ttlong0":"100000","ttlong2":"300000","ttlong3":"300000","ttfloat0":"2.111","ttfloat2":"6000.333","ttfloat3":"6000.333","ttdouble0":"200000.4444","ttdouble2":"900000.6666","ttdouble3":"9.6666","ttdatetime0":"2010-01-01 00:00:00","ttdatetime1":"2010/02/02 00-00-00","ttdatetime3":"2030-03-03 00:00:00","ttdatetime4":"2030-03-03 00:00:00","ttstore":"11 woyo","tttag0":"1我友 woyo 前台","tttag1":"11111","tttext0":"woyo.com的前台人员12345 测试","tttext1":"测试 www.woyo.com ,test,ceshi,3","tttext4":"测试张一 1111111111111111111111111111111111111111111测试2222222222222222222222222222","tttext5":"测试女,test","tttext6":"测试中国,test","tttext7":"测试汉族,test","dx_1":"测试数据1 soapUI is a tool for functional,testing, mainly of Web Services like SOAP based Web Services and REST Web Services, but also HTTP based services and JMS Services as well as databases. soapUI is an Open Source tool with a commercial companion, soapUI Pro, with extra functionality for companies with mission critical Web Services. soapUI is being produced by the community as well as the Open Source company eviware.soapUI","dx_2":"特大泥石流灾害,总理温家宝视察","tdz_1":"index not_analyzed storetrue策测试termVector with_positions_off测试sets","tdz_2":"index not_analyzed storetrue termVector with_positions_offsets index not_analyzed storetrue termVector with_positions_offsets","_type":"a","_id":"11#a","ttattrdate":"2013-01-01 01:02:03","ttattrint":"12345"}},
11 | {"_id":"12","_type":"a","_source":{"ttbyte0":"10","ttbyte2":"30","ttshort0":"40","ttshort2":"100","ttint0":"110","ttint2":"130","ttint3":"10","ttlong0":"100000","ttlong2":"300000","ttlong3":"300000","ttfloat0":"2.111","ttfloat2":"6000.333","ttfloat3":"6000.333","ttdouble0":"200000.4444","ttdouble2":"900000.6666","ttdouble3":"90.6666","ttdatetime0":"2000-02-01 01:02:03","ttdatetime1":"2010/02/02 00-00-00","ttdatetime3":"2030-03-03 00:00:00","ttdatetime4":"2030-03-03 00:00:00","ttstore":"22woyo","tttag0":"2我友 woyo 开发","tttag1":"测试","tttext0":"woyo.com的开发人员23456,test","tttext1":"记忆里面唯一一次到南站还是大四找工作那会儿跑上海面试完之后要回杭州,的士司机硬给拉过去的。当时那地方比破得连正门都找不到,一度以为的哥把我给忽悠了。后来听说又建成世界之最了,从浙江过来的火车都改到那里停靠,但那时已经自己开着凯越溜达了,愣是没机会一睹其风采。","tttext4":"测试 陈二,test","tttext5":"测试 男,test","tttext6":"测试 中国,test","tttext7":"测试 汉族,test","dx_1":"测试数据2 soapUI is a tool for functional,testing, mainly of Web Services like SOAP based Web Services and REST Web Services, but also HTTP based services and JMS Services as well as databases. soapUI is an Open Source tool with a commercial companion, soapUI Pro, with extra functionality for companies with mission critical Web Services. soapUI is being produced by the community as well as the Open Source company eviware.soapUI","dx_2":"测试数据2 soapUI has been downloaded more than one and a half million times and is seen as the de facto standard for Web Service,testing. For you as a user, this means there is a lot of knowledge about the tool out there. We'd like to encourage you to read the blogs on the net for more info about using soapUI in real life. There also is a Community Forum on the eviware website. We appreciate every download and work really hard to create a super product for you. If you have any ideas or thought, please let us know!soapUI","tdz_1":"index not_analyzed storetrue termVector with_positions_offsets","tdz_2":"index not_analyzed storetrue termVector with_positions_offsets index not_analyzed storetrue termVector with_positions_offsets","_type":"a","_id":"12#a","ttattrdate":"2012-01-01 01:02:03","ttattrint":"212345"}},
12 | {"_id":"16","_type":"b","_source":{"ttbyte0":"10","ttbyte2":"30","ttshort0":"40","ttshort2":"100","ttint0":"110","ttint2":"130","ttint3":"10","ttlong0":"100000","ttlong2":"300000","ttlong3":"300000","ttfloat0":"34.111","ttfloat2":"6000.333","ttfloat3":"6000.333","ttdouble0":"3700000.4444","ttdouble2":"900000.6666","ttdouble3":"9.6666","ttdatetime0":"2000-01-01 01:02:03","ttdatetime1":"2010/02/02 00-00-00","ttdatetime3":"2030-03-03 00:00:00","ttdatetime4":"2030-03-03 00:00:00","ttstore":"11 woyo","tttag0":"1我友 woyo 前台","tttag1":"11111","tttext0":"woyo.com的前台人员12345 测试","tttext1":"测试 www.woyo.com ,test","tttext4":"测试张一 1111111111111111111111111111111111111111111测试2222222222222222222222222222","tttext5":"测试女,test","tttext6":"测试中国,test","tttext7":"测试汉族,test","dx_1":"测试数据1 soapUI is a tool for functional,testing, mainly of Web Services like SOAP based Web Services and REST Web Services, but also HTTP based services and JMS Services as well as databases. soapUI is an Open Source tool with a commercial companion, soapUI Pro, with extra functionality for companies with mission critical Web Services. soapUI is being produced by the community as well as the Open Source company eviware.soapUI","dx_2":"测试数据1 soapUI has been downloaded more than one and a half million times and is seen as the de facto standard for Web Service,testing. For you as a user, this means there is a lot of knowledge about the tool out there. We'd like to encourage you to read the blogs on the net for more info about using soapUI in real life. There also is a Community Forum on the eviware website. We appreciate every download and work really hard to create a super product for you. If you have any ideas or thought, please let us know!soapUI","tdz_1":"index not_analyzed storetrue策测试termVector with_positions_off测试sets","tdz_2":"index not_analyzed storetrue termVector with_positions_offsets index not_analyzed storetrue termVector with_positions_offsets","_type":"b","_id":"16#b","ttattrdate":"2013-01-01 01:02:03","ttattrint":"412345"}},
13 | {"_id":"17","_type":"b","_source":{"ttbyte0":"10","ttbyte2":"30","ttshort0":"40","ttshort2":"100","ttint0":"110","ttint2":"130","ttint3":"10","ttlong0":"100000","ttlong2":"300000","ttlong3":"300000","ttfloat0":"44.111","ttfloat2":"6000.333","ttfloat3":"6000.333","ttdouble0":"4700000.4444","ttdouble2":"900000.6666","ttdouble3":"90.6666","ttdatetime0":"2000-02-01 01:02:03","ttdatetime1":"2010/02/02 00-00-00","ttdatetime3":"2030-03-03 00:00:00","ttdatetime4":"2030-03-03 00:00:00","ttstore":"22woyo","tttag0":"2我友 woyo 开发","tttag1":"测试","tttext0":"woyo.com的开发人员23456,test","tttext1":"www.woyo.com 测试","tttext4":"测试 陈二,test","tttext5":"测试 男,test","tttext6":"测试 中国,test","tttext7":"测试 汉族,test","dx_1":"测试数据2 soapUI is a tool for functional,testing, mainly of Web Services like SOAP based Web Services and REST Web Services, but also HTTP based services and JMS Services as well as databases. soapUI is an Open Source tool with a commercial companion, soapUI Pro, with extra functionality for companies with mission critical Web Services. soapUI is being produced by the community as well as the Open Source company eviware.soapUI","dx_2":"测试数据2 soapUI has been downloaded more than one and a half million times and is seen as the de facto standard for Web Service,testing. For you as a user, this means there is a lot of knowledge about the tool out there. We'd like to encourage you to read the blogs on the net for more info about using soapUI in real life. There also is a Community Forum on the eviware website. We appreciate every download and work really hard to create a super product for you. If you have any ideas or thought, please let us know!soapUI","tdz_1":"index not_analyzed storetrue termVector with_positions_offsets","tdz_2":"index not_analyzed storetrue termVector with_positions_offsets index not_analyzed storetrue termVector with_positions_offsets","_type":"b","_id":"17#b","ttattrdate":"2012-01-01 01:02:03","ttattrint":"412345"}},
14 | {"_id":"21","_type":"b","_source":{"ttbyte0":"10","ttbyte2":"30","ttshort0":"40","ttshort2":"100","ttint0":"110","ttint2":"130","ttint3":"10","ttlong0":"100000","ttlong2":"300000","ttlong3":"300000","ttfloat0":"54.111","ttfloat2":"6000.333","ttfloat3":"6000.333","ttdouble0":"6700000.4444","ttdouble2":"900000.6666","ttdouble3":"9.6666","ttdatetime0":"2000-01-01 01:02:03","ttdatetime1":"2010/02/02 00-00-00","ttdatetime3":"2030-03-03 00:00:00","ttdatetime4":"2030-03-03 00:00:00","ttstore":"11 woyo","tttag0":"1我友 woyo 前台","tttag1":"11111","tttext0":"woyo.com的前台人员12345 测试","tttext1":"测试 www.woyo.com ,test","tttext4":"测试张一 1111111111111111111111111111111111111111111测试2222222222222222222222222222","tttext5":"测试女,test","tttext6":"测试中国,test","tttext7":"测试汉族,test","dx_1":"测试数据1 soapUI is a tool for functional,testing, mainly of Web Services like SOAP based Web Services and REST Web Services, but also HTTP based services and JMS Services as well as databases. soapUI is an Open Source tool with a commercial companion, soapUI Pro, with extra functionality for companies with mission critical Web Services. soapUI is being produced by the community as well as the Open Source company eviware.soapUI","dx_2":"测试数据1 soapUI has been downloaded more than one and a half million times and is seen as the de facto standard for Web Service,testing. For you as a user, this means there is a lot of knowledge about the tool out there. We'd like to encourage you to read the blogs on the net for more info about using soapUI in real life. There also is a Community Forum on the eviware website. We appreciate every download and work really hard to create a super product for you. If you have any ideas or thought, please let us know!soapUI","tdz_1":"index not_analyzed storetrue策测试termVector with_positions_off测试sets","tdz_2":"index not_analyzed storetrue termVector with_positions_offsets index not_analyzed storetrue termVector with_positions_offsets","_type":"b","_id":"21#b","ttattrdate":"2013-01-01 01:02:03","ttattrint":"612345"}},
15 | {"_id":"22","_type":"b","_source":{"ttbyte0":"10","ttbyte2":"30","ttshort0":"40","ttshort2":"100","ttint0":"110","ttint2":"130","ttint3":"10","ttlong0":"100000","ttlong2":"300000","ttlong3":"300000","ttfloat0":"64.111","ttfloat2":"6000.333","ttfloat3":"6000.333","ttdouble0":"6700000.4444","ttdouble2":"900000.6666","ttdouble3":"90.6666","ttdatetime0":"2000-02-01 01:02:03","ttdatetime1":"2010/02/02 00-00-00","ttdatetime3":"2030-03-03 00:00:00","ttdatetime4":"2030-03-03 00:00:00","ttstore":"22woyo","tttag0":"2我友 woyo 开发","tttag1":"测试","tttext0":"woyo.com的开发人员23456,test","tttext1":"www.woyo.com 测试","tttext4":"测试 陈二,test","tttext5":"测试 男,test","tttext6":"测试 中国,test","tttext7":"测试 汉族,test","dx_1":"测试数据2 soapUI is a tool for functional,testing, mainly of Web Services like SOAP based Web Services and REST Web Services, but also HTTP based services and JMS Services as well as databases. soapUI is an Open Source tool with a commercial companion, soapUI Pro, with extra functionality for companies with mission critical Web Services. soapUI is being produced by the community as well as the Open Source company eviware.soapUI","dx_2":"测试数据2 soapUI has been downloaded more than one and a half million times and is seen as the de facto standard for Web Service,testing. For you as a user, this means there is a lot of knowledge about the tool out there. We'd like to encourage you to read the blogs on the net for more info about using soapUI in real life. There also is a Community Forum on the eviware website. We appreciate every download and work really hard to create a super product for you. If you have any ideas or thought, please let us know!soapUI","tdz_1":"index not_analyzed storetrue termVector with_positions_offsets","tdz_2":"index not_analyzed storetrue termVector with_positions_offsets index not_analyzed storetrue termVector with_positions_offsets","_type":"b","_id":"22#b","ttattrdate":"2012-01-01 01:02:03","ttattrint":"612345"}}]}}
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/script/hash/performance/query/bitquery-00.txt:
--------------------------------------------------------------------------------
1 | ${BASE_URL}:${PORT}/${INDEX_NAME}/_search
2 |
3 | POST
4 |
5 | {
6 | "query":{
7 | "bitfilter":
8 | {
9 | "ttattrint" :1,
10 | "operator":"AND"
11 | }
12 | }
13 | }
14 |
15 | {"qTime":"16ms","hits":{"total":9,"hits":[
16 | {"_id":"2","_type":"a","_source":{"ttbyte0":"10","ttbyte2":"30","ttshort0":"40","ttshort2":"100","ttint0":"2","ttint2":"130","ttint3":"10","ttlong0":"100000","ttlong2":"300000","ttlong3":"300000","ttfloat0":"4000.111","ttfloat2":"6000.333","ttfloat3":"6000.333","ttdouble0":"700000.4444","ttdouble2":"900000.6666","ttdouble3":"90.6666","ttdatetime0":"2000-02-01 01:02:03","ttdatetime1":"2010/02/02 00-00-00","ttdatetime3":"2030-03-03 00:00:00","ttdatetime4":"2030-03-03 00:00:00","ttstore":"22woyo","tttag0":"2我友 woyo 开发","tttag1":"测试","tttext0":"woyo的开发人员23456,test","tttext1":"sdfsdf,woyo,test,3","tttext4":"波音公司(Boeing),预计2011年6月可以完成.","tttext5":"波音公司(boeing),预计2011年6月可以完成.","tttext6":"测试 中国,test","tttext7":"测试 汉族,test","dx_1":"测试数据2 soapUI is a tool for functional,testing, mainly of Web Services like SOAP based Web Services and REST Web Services, but also HTTP based services and JMS Services as well as databases. soapUI is an Open Source tool with a commercial companion, soapUI Pro, with extra functionality for companies with mission critical Web Services. soapUI is being produced by the community as well as the Open Source company eviware.soapUI","dx_2":"测试数据2 soapUI has been downloaded more than one and a half million times and is seen as the de facto standard for Web Service,testing. For you as a user, this means there is a lot of knowledge about the tool out there. We'd like to encourage you to read the blogs on the net for more info about using soapUI in real life. There also is a Community Forum on the eviware website. We appreciate every download and work really hard to create a super product for you. If you have any ideas or thought, please let us know!soapUI","tdz_1":"index not_analyzed storetrue termVector with_positions_offsets","tdz_2":"index not_analyzed storetrue termVector with_positions_offsets index not_analyzed storetrue termVector with_positions_offsets","_type":"a","_id":"2#a","ttattrdate":"2012-01-01 01:02:03","ttattrint":"3"}},
17 | {"_id":"6","_type":"a","_source":{"ttbyte0":"6","ttbyte2":"30","ttshort0":"40","ttshort2":"100","ttint0":"6","ttint2":"130","ttint3":"130","ttlong0":"600000","ttlong2":"600002","ttlong3":"600003","ttfloat0":"4000.111","ttfloat2":"6000.333","ttfloat3":"6000.333","ttdouble0":"700000.4444","ttdouble2":"900000.6666","ttdouble3":"900000.6666","ttdatetime0":"2000-02-02 02:03:04","ttdatetime1":"2010/02/02 00-00-00","ttdatetime3":"2030-03-03 00:00:00","ttdatetime4":"2030-03-03 00:00:00","ttstore":"11 woyo","tttag0":"1我友 woyo 前台","tttag1":"11111","tttext0":"woyo.com的前台人员12345 测试,⊙﹏⊙b汗","tttext1":"测试 www.woyo.com ,test,3.","tttext4":"测试张一 1111111111111111111111111111111111111111111测试2222222222222222222222222222","tttext5":"测试女,test","tttext6":"测试中国,test","tttext7":"测试汉族,test","dx_1":"测试数据1 soapUI is a tool for functional,testing, mainly of Web Services like SOAP based Web Services and REST Web Services, but also HTTP based services and JMS Services as well as databases. soapUI is an Open Source tool with a commercial companion, soapUI Pro, with extra functionality for companies with mission critical Web Services. soapUI is being produced by the community as well as the Open Source company eviware.soapUI","dx_2":"测试数据1 soapUI has been downloaded more than one and a half million times and is seen as the de facto standard for Web Service,testing. For you as a user, this means there is a lot of knowledge about the tool out there. We'd like to encourage you to read the blogs on the net for more info about using soapUI in real life. There also is a Community Forum on the eviware website. We appreciate every download and work really hard to create a super product for you. If you have any ideas or thought, please let us know!soapUI","tdz_1":"index not_analyzed storetrue策测试termVector with_positions_off测试sets","tdz_2":"index not_analyzed storetrue termVector with_positions_offsets index not_analyzed storetrue termVector with_positions_offsets","_type":"a","_id":"6#a","ttattrdate":"2012-01-01 02:02:03","ttattrint":"12345"}},
18 | {"_id":"7","_type":"a","_source":{"ttbyte0":"7","ttbyte2":"30","ttshort0":"40","ttshort2":"100","ttint0":"7","ttint2":"130","ttint3":"130","ttlong0":"600000","ttlong2":"200002","ttlong3":"300003","ttfloat0":"4000.111","ttfloat2":"6000.333","ttfloat3":"6000.333","ttdouble0":"700000.4444","ttdouble2":"900000.6666","ttdouble3":"900000.6666","ttdatetime0":"2004-01-01 01:02:03","ttdatetime1":"2010/02/02 00-00-00","ttdatetime3":"2030-03-03 00:00:00","ttdatetime4":"2030-03-03 00:00:00","ttstore":"22woyo","tttag0":"2我友 woyo 开发","tttag1":"测试","tttext0":"woyo.com的开发人员23456,test","tttext1":"www.woyo.com 测试","tttext4":"测试 陈二,test","tttext5":"测试 男,test","tttext6":"测试 中国,test","tttext7":"测试 汉族,test","dx_1":"测试数据2 soapUI is a tool for functional,testing, mainly of Web Services like SOAP based Web Services and REST Web Services, but also HTTP based services and JMS Services as well as databases. soapUI is an Open Source tool with a commercial companion, soapUI Pro, with extra functionality for companies with mission critical Web Services. soapUI is being produced by the community as well as the Open Source company eviware.soapUI","dx_2":"测试数据2 soapUI has been downloaded more than one and a half million times and is seen as the de facto standard for Web Service,testing. For you as a user, this means there is a lot of knowledge about the tool out there. We'd like to encourage you to read the blogs on the net for more info about using soapUI in real life. There also is a Community Forum on the eviware website. We appreciate every download and work really hard to create a super product for you. If you have any ideas or thought, please let us know!soapUI","tdz_1":"index not_analyzed storetrue termVector with_positions_offsets","tdz_2":"index not_analyzed storetrue termVector with_positions_offsets index not_analyzed storetrue termVector with_positions_offsets","_type":"a","_id":"7#a","ttattrdate":"2012-01-01 01:03:03","ttattrint":"12345"}},
19 | {"_id":"11","_type":"a","_source":{"ttbyte0":"10","ttbyte2":"30","ttshort0":"40","ttshort2":"100","ttint0":"110","ttint2":"130","ttint3":"10","ttlong0":"100000","ttlong2":"300000","ttlong3":"300000","ttfloat0":"2.111","ttfloat2":"6000.333","ttfloat3":"6000.333","ttdouble0":"200000.4444","ttdouble2":"900000.6666","ttdouble3":"9.6666","ttdatetime0":"2010-01-01 00:00:00","ttdatetime1":"2010/02/02 00-00-00","ttdatetime3":"2030-03-03 00:00:00","ttdatetime4":"2030-03-03 00:00:00","ttstore":"11 woyo","tttag0":"1我友 woyo 前台","tttag1":"11111","tttext0":"woyo.com的前台人员12345 测试","tttext1":"测试 www.woyo.com ,test,ceshi,3","tttext4":"测试张一 1111111111111111111111111111111111111111111测试2222222222222222222222222222","tttext5":"测试女,test","tttext6":"测试中国,test","tttext7":"测试汉族,test","dx_1":"测试数据1 soapUI is a tool for functional,testing, mainly of Web Services like SOAP based Web Services and REST Web Services, but also HTTP based services and JMS Services as well as databases. soapUI is an Open Source tool with a commercial companion, soapUI Pro, with extra functionality for companies with mission critical Web Services. soapUI is being produced by the community as well as the Open Source company eviware.soapUI","dx_2":"特大泥石流灾害,总理温家宝视察","tdz_1":"index not_analyzed storetrue策测试termVector with_positions_off测试sets","tdz_2":"index not_analyzed storetrue termVector with_positions_offsets index not_analyzed storetrue termVector with_positions_offsets","_type":"a","_id":"11#a","ttattrdate":"2013-01-01 01:02:03","ttattrint":"12345"}},
20 | {"_id":"12","_type":"a","_source":{"ttbyte0":"10","ttbyte2":"30","ttshort0":"40","ttshort2":"100","ttint0":"110","ttint2":"130","ttint3":"10","ttlong0":"100000","ttlong2":"300000","ttlong3":"300000","ttfloat0":"2.111","ttfloat2":"6000.333","ttfloat3":"6000.333","ttdouble0":"200000.4444","ttdouble2":"900000.6666","ttdouble3":"90.6666","ttdatetime0":"2000-02-01 01:02:03","ttdatetime1":"2010/02/02 00-00-00","ttdatetime3":"2030-03-03 00:00:00","ttdatetime4":"2030-03-03 00:00:00","ttstore":"22woyo","tttag0":"2我友 woyo 开发","tttag1":"测试","tttext0":"woyo.com的开发人员23456,test","tttext1":"记忆里面唯一一次到南站还是大四找工作那会儿跑上海面试完之后要回杭州,的士司机硬给拉过去的。当时那地方比破得连正门都找不到,一度以为的哥把我给忽悠了。后来听说又建成世界之最了,从浙江过来的火车都改到那里停靠,但那时已经自己开着凯越溜达了,愣是没机会一睹其风采。","tttext4":"测试 陈二,test","tttext5":"测试 男,test","tttext6":"测试 中国,test","tttext7":"测试 汉族,test","dx_1":"测试数据2 soapUI is a tool for functional,testing, mainly of Web Services like SOAP based Web Services and REST Web Services, but also HTTP based services and JMS Services as well as databases. soapUI is an Open Source tool with a commercial companion, soapUI Pro, with extra functionality for companies with mission critical Web Services. soapUI is being produced by the community as well as the Open Source company eviware.soapUI","dx_2":"测试数据2 soapUI has been downloaded more than one and a half million times and is seen as the de facto standard for Web Service,testing. For you as a user, this means there is a lot of knowledge about the tool out there. We'd like to encourage you to read the blogs on the net for more info about using soapUI in real life. There also is a Community Forum on the eviware website. We appreciate every download and work really hard to create a super product for you. If you have any ideas or thought, please let us know!soapUI","tdz_1":"index not_analyzed storetrue termVector with_positions_offsets","tdz_2":"index not_analyzed storetrue termVector with_positions_offsets index not_analyzed storetrue termVector with_positions_offsets","_type":"a","_id":"12#a","ttattrdate":"2012-01-01 01:02:03","ttattrint":"212345"}},
21 | {"_id":"16","_type":"b","_source":{"ttbyte0":"10","ttbyte2":"30","ttshort0":"40","ttshort2":"100","ttint0":"110","ttint2":"130","ttint3":"10","ttlong0":"100000","ttlong2":"300000","ttlong3":"300000","ttfloat0":"34.111","ttfloat2":"6000.333","ttfloat3":"6000.333","ttdouble0":"3700000.4444","ttdouble2":"900000.6666","ttdouble3":"9.6666","ttdatetime0":"2000-01-01 01:02:03","ttdatetime1":"2010/02/02 00-00-00","ttdatetime3":"2030-03-03 00:00:00","ttdatetime4":"2030-03-03 00:00:00","ttstore":"11 woyo","tttag0":"1我友 woyo 前台","tttag1":"11111","tttext0":"woyo.com的前台人员12345 测试","tttext1":"测试 www.woyo.com ,test","tttext4":"测试张一 1111111111111111111111111111111111111111111测试2222222222222222222222222222","tttext5":"测试女,test","tttext6":"测试中国,test","tttext7":"测试汉族,test","dx_1":"测试数据1 soapUI is a tool for functional,testing, mainly of Web Services like SOAP based Web Services and REST Web Services, but also HTTP based services and JMS Services as well as databases. soapUI is an Open Source tool with a commercial companion, soapUI Pro, with extra functionality for companies with mission critical Web Services. soapUI is being produced by the community as well as the Open Source company eviware.soapUI","dx_2":"测试数据1 soapUI has been downloaded more than one and a half million times and is seen as the de facto standard for Web Service,testing. For you as a user, this means there is a lot of knowledge about the tool out there. We'd like to encourage you to read the blogs on the net for more info about using soapUI in real life. There also is a Community Forum on the eviware website. We appreciate every download and work really hard to create a super product for you. If you have any ideas or thought, please let us know!soapUI","tdz_1":"index not_analyzed storetrue策测试termVector with_positions_off测试sets","tdz_2":"index not_analyzed storetrue termVector with_positions_offsets index not_analyzed storetrue termVector with_positions_offsets","_type":"b","_id":"16#b","ttattrdate":"2013-01-01 01:02:03","ttattrint":"412345"}},
22 | {"_id":"17","_type":"b","_source":{"ttbyte0":"10","ttbyte2":"30","ttshort0":"40","ttshort2":"100","ttint0":"110","ttint2":"130","ttint3":"10","ttlong0":"100000","ttlong2":"300000","ttlong3":"300000","ttfloat0":"44.111","ttfloat2":"6000.333","ttfloat3":"6000.333","ttdouble0":"4700000.4444","ttdouble2":"900000.6666","ttdouble3":"90.6666","ttdatetime0":"2000-02-01 01:02:03","ttdatetime1":"2010/02/02 00-00-00","ttdatetime3":"2030-03-03 00:00:00","ttdatetime4":"2030-03-03 00:00:00","ttstore":"22woyo","tttag0":"2我友 woyo 开发","tttag1":"测试","tttext0":"woyo.com的开发人员23456,test","tttext1":"www.woyo.com 测试","tttext4":"测试 陈二,test","tttext5":"测试 男,test","tttext6":"测试 中国,test","tttext7":"测试 汉族,test","dx_1":"测试数据2 soapUI is a tool for functional,testing, mainly of Web Services like SOAP based Web Services and REST Web Services, but also HTTP based services and JMS Services as well as databases. soapUI is an Open Source tool with a commercial companion, soapUI Pro, with extra functionality for companies with mission critical Web Services. soapUI is being produced by the community as well as the Open Source company eviware.soapUI","dx_2":"测试数据2 soapUI has been downloaded more than one and a half million times and is seen as the de facto standard for Web Service,testing. For you as a user, this means there is a lot of knowledge about the tool out there. We'd like to encourage you to read the blogs on the net for more info about using soapUI in real life. There also is a Community Forum on the eviware website. We appreciate every download and work really hard to create a super product for you. If you have any ideas or thought, please let us know!soapUI","tdz_1":"index not_analyzed storetrue termVector with_positions_offsets","tdz_2":"index not_analyzed storetrue termVector with_positions_offsets index not_analyzed storetrue termVector with_positions_offsets","_type":"b","_id":"17#b","ttattrdate":"2012-01-01 01:02:03","ttattrint":"412345"}},
23 | {"_id":"21","_type":"b","_source":{"ttbyte0":"10","ttbyte2":"30","ttshort0":"40","ttshort2":"100","ttint0":"110","ttint2":"130","ttint3":"10","ttlong0":"100000","ttlong2":"300000","ttlong3":"300000","ttfloat0":"54.111","ttfloat2":"6000.333","ttfloat3":"6000.333","ttdouble0":"6700000.4444","ttdouble2":"900000.6666","ttdouble3":"9.6666","ttdatetime0":"2000-01-01 01:02:03","ttdatetime1":"2010/02/02 00-00-00","ttdatetime3":"2030-03-03 00:00:00","ttdatetime4":"2030-03-03 00:00:00","ttstore":"11 woyo","tttag0":"1我友 woyo 前台","tttag1":"11111","tttext0":"woyo.com的前台人员12345 测试","tttext1":"测试 www.woyo.com ,test","tttext4":"测试张一 1111111111111111111111111111111111111111111测试2222222222222222222222222222","tttext5":"测试女,test","tttext6":"测试中国,test","tttext7":"测试汉族,test","dx_1":"测试数据1 soapUI is a tool for functional,testing, mainly of Web Services like SOAP based Web Services and REST Web Services, but also HTTP based services and JMS Services as well as databases. soapUI is an Open Source tool with a commercial companion, soapUI Pro, with extra functionality for companies with mission critical Web Services. soapUI is being produced by the community as well as the Open Source company eviware.soapUI","dx_2":"测试数据1 soapUI has been downloaded more than one and a half million times and is seen as the de facto standard for Web Service,testing. For you as a user, this means there is a lot of knowledge about the tool out there. We'd like to encourage you to read the blogs on the net for more info about using soapUI in real life. There also is a Community Forum on the eviware website. We appreciate every download and work really hard to create a super product for you. If you have any ideas or thought, please let us know!soapUI","tdz_1":"index not_analyzed storetrue策测试termVector with_positions_off测试sets","tdz_2":"index not_analyzed storetrue termVector with_positions_offsets index not_analyzed storetrue termVector with_positions_offsets","_type":"b","_id":"21#b","ttattrdate":"2013-01-01 01:02:03","ttattrint":"612345"}},
24 | {"_id":"22","_type":"b","_source":{"ttbyte0":"10","ttbyte2":"30","ttshort0":"40","ttshort2":"100","ttint0":"110","ttint2":"130","ttint3":"10","ttlong0":"100000","ttlong2":"300000","ttlong3":"300000","ttfloat0":"64.111","ttfloat2":"6000.333","ttfloat3":"6000.333","ttdouble0":"6700000.4444","ttdouble2":"900000.6666","ttdouble3":"90.6666","ttdatetime0":"2000-02-01 01:02:03","ttdatetime1":"2010/02/02 00-00-00","ttdatetime3":"2030-03-03 00:00:00","ttdatetime4":"2030-03-03 00:00:00","ttstore":"22woyo","tttag0":"2我友 woyo 开发","tttag1":"测试","tttext0":"woyo.com的开发人员23456,test","tttext1":"www.woyo.com 测试","tttext4":"测试 陈二,test","tttext5":"测试 男,test","tttext6":"测试 中国,test","tttext7":"测试 汉族,test","dx_1":"测试数据2 soapUI is a tool for functional,testing, mainly of Web Services like SOAP based Web Services and REST Web Services, but also HTTP based services and JMS Services as well as databases. soapUI is an Open Source tool with a commercial companion, soapUI Pro, with extra functionality for companies with mission critical Web Services. soapUI is being produced by the community as well as the Open Source company eviware.soapUI","dx_2":"测试数据2 soapUI has been downloaded more than one and a half million times and is seen as the de facto standard for Web Service,testing. For you as a user, this means there is a lot of knowledge about the tool out there. We'd like to encourage you to read the blogs on the net for more info about using soapUI in real life. There also is a Community Forum on the eviware website. We appreciate every download and work really hard to create a super product for you. If you have any ideas or thought, please let us know!soapUI","tdz_1":"index not_analyzed storetrue termVector with_positions_offsets","tdz_2":"index not_analyzed storetrue termVector with_positions_offsets index not_analyzed storetrue termVector with_positions_offsets","_type":"b","_id":"22#b","ttattrdate":"2012-01-01 01:02:03","ttattrint":"612345"}}]}}
25 |
26 | ${CONCURRENT.200_1000}
--------------------------------------------------------------------------------
/script/hash/query/attr/attrquery.txt:
--------------------------------------------------------------------------------
1 | ${BASE_URL}:${PORT}/${INDEX_NAME}/test1/_search
2 |
3 | POST
4 |
5 | {
6 | "fields":["ttattrint","ttattrdate"],
7 | "query":{
8 | "term":
9 | {
10 | "ttint0" :"${SEQINT.1}",
11 | }
12 | }
13 | }
14 |
15 | {"qTime":"6ms","hits":{"total":1,"hits":[
16 | {"_id":"1","_type":"test1","_source":{"ttattrint":"61234","ttattrdate":"2012-01-02 01:02:03"}}]}}
17 |
18 | ${CONCURRENT.300_100}
19 |
--------------------------------------------------------------------------------
/script/hash/query/bitquery-00.txt:
--------------------------------------------------------------------------------
1 | ${BASE_URL}:${PORT}/${INDEX_NAME}/_search
2 |
3 | POST
4 |
5 | {
6 | "query":{
7 | "bitfilter":
8 | {
9 | "tttext0" :"functional${SEQINT.1}",
10 | "operator":"AND"
11 | }
12 | }
13 | }
14 |
15 | {"qTime":"16ms","hits":{"total":9,"hits":[
16 | {"_id":"2","_type":"a","_source":{"ttbyte0":"10","ttbyte2":"30","ttshort0":"40","ttshort2":"100","ttint0":"2","ttint2":"130","ttint3":"10","ttlong0":"100000","ttlong2":"300000","ttlong3":"300000","ttfloat0":"4000.111","ttfloat2":"6000.333","ttfloat3":"6000.333","ttdouble0":"700000.4444","ttdouble2":"900000.6666","ttdouble3":"90.6666","ttdatetime0":"2000-02-01 01:02:03","ttdatetime1":"2010/02/02 00-00-00","ttdatetime3":"2030-03-03 00:00:00","ttdatetime4":"2030-03-03 00:00:00","ttstore":"22woyo","tttag0":"2我友 woyo 开发","tttag1":"测试","tttext0":"woyo的开发人员23456,test","tttext1":"sdfsdf,woyo,test,3","tttext4":"波音公司(Boeing),预计2011年6月可以完成.","tttext5":"波音公司(boeing),预计2011年6月可以完成.","tttext6":"测试 中国,test","tttext7":"测试 汉族,test","dx_1":"测试数据2 soapUI is a tool for functional,testing, mainly of Web Services like SOAP based Web Services and REST Web Services, but also HTTP based services and JMS Services as well as databases. soapUI is an Open Source tool with a commercial companion, soapUI Pro, with extra functionality for companies with mission critical Web Services. soapUI is being produced by the community as well as the Open Source company eviware.soapUI","dx_2":"测试数据2 soapUI has been downloaded more than one and a half million times and is seen as the de facto standard for Web Service,testing. For you as a user, this means there is a lot of knowledge about the tool out there. We'd like to encourage you to read the blogs on the net for more info about using soapUI in real life. There also is a Community Forum on the eviware website. We appreciate every download and work really hard to create a super product for you. If you have any ideas or thought, please let us know!soapUI","tdz_1":"index not_analyzed storetrue termVector with_positions_offsets","tdz_2":"index not_analyzed storetrue termVector with_positions_offsets index not_analyzed storetrue termVector with_positions_offsets","_type":"a","_id":"2#a","ttattrdate":"2012-01-01 01:02:03","ttattrint":"3"}},
17 | {"_id":"6","_type":"a","_source":{"ttbyte0":"6","ttbyte2":"30","ttshort0":"40","ttshort2":"100","ttint0":"6","ttint2":"130","ttint3":"130","ttlong0":"600000","ttlong2":"600002","ttlong3":"600003","ttfloat0":"4000.111","ttfloat2":"6000.333","ttfloat3":"6000.333","ttdouble0":"700000.4444","ttdouble2":"900000.6666","ttdouble3":"900000.6666","ttdatetime0":"2000-02-02 02:03:04","ttdatetime1":"2010/02/02 00-00-00","ttdatetime3":"2030-03-03 00:00:00","ttdatetime4":"2030-03-03 00:00:00","ttstore":"11 woyo","tttag0":"1我友 woyo 前台","tttag1":"11111","tttext0":"woyo.com的前台人员12345 测试,⊙﹏⊙b汗","tttext1":"测试 www.woyo.com ,test,3.","tttext4":"测试张一 1111111111111111111111111111111111111111111测试2222222222222222222222222222","tttext5":"测试女,test","tttext6":"测试中国,test","tttext7":"测试汉族,test","dx_1":"测试数据1 soapUI is a tool for functional,testing, mainly of Web Services like SOAP based Web Services and REST Web Services, but also HTTP based services and JMS Services as well as databases. soapUI is an Open Source tool with a commercial companion, soapUI Pro, with extra functionality for companies with mission critical Web Services. soapUI is being produced by the community as well as the Open Source company eviware.soapUI","dx_2":"测试数据1 soapUI has been downloaded more than one and a half million times and is seen as the de facto standard for Web Service,testing. For you as a user, this means there is a lot of knowledge about the tool out there. We'd like to encourage you to read the blogs on the net for more info about using soapUI in real life. There also is a Community Forum on the eviware website. We appreciate every download and work really hard to create a super product for you. If you have any ideas or thought, please let us know!soapUI","tdz_1":"index not_analyzed storetrue策测试termVector with_positions_off测试sets","tdz_2":"index not_analyzed storetrue termVector with_positions_offsets index not_analyzed storetrue termVector with_positions_offsets","_type":"a","_id":"6#a","ttattrdate":"2012-01-01 02:02:03","ttattrint":"12345"}},
18 | {"_id":"7","_type":"a","_source":{"ttbyte0":"7","ttbyte2":"30","ttshort0":"40","ttshort2":"100","ttint0":"7","ttint2":"130","ttint3":"130","ttlong0":"600000","ttlong2":"200002","ttlong3":"300003","ttfloat0":"4000.111","ttfloat2":"6000.333","ttfloat3":"6000.333","ttdouble0":"700000.4444","ttdouble2":"900000.6666","ttdouble3":"900000.6666","ttdatetime0":"2004-01-01 01:02:03","ttdatetime1":"2010/02/02 00-00-00","ttdatetime3":"2030-03-03 00:00:00","ttdatetime4":"2030-03-03 00:00:00","ttstore":"22woyo","tttag0":"2我友 woyo 开发","tttag1":"测试","tttext0":"woyo.com的开发人员23456,test","tttext1":"www.woyo.com 测试","tttext4":"测试 陈二,test","tttext5":"测试 男,test","tttext6":"测试 中国,test","tttext7":"测试 汉族,test","dx_1":"测试数据2 soapUI is a tool for functional,testing, mainly of Web Services like SOAP based Web Services and REST Web Services, but also HTTP based services and JMS Services as well as databases. soapUI is an Open Source tool with a commercial companion, soapUI Pro, with extra functionality for companies with mission critical Web Services. soapUI is being produced by the community as well as the Open Source company eviware.soapUI","dx_2":"测试数据2 soapUI has been downloaded more than one and a half million times and is seen as the de facto standard for Web Service,testing. For you as a user, this means there is a lot of knowledge about the tool out there. We'd like to encourage you to read the blogs on the net for more info about using soapUI in real life. There also is a Community Forum on the eviware website. We appreciate every download and work really hard to create a super product for you. If you have any ideas or thought, please let us know!soapUI","tdz_1":"index not_analyzed storetrue termVector with_positions_offsets","tdz_2":"index not_analyzed storetrue termVector with_positions_offsets index not_analyzed storetrue termVector with_positions_offsets","_type":"a","_id":"7#a","ttattrdate":"2012-01-01 01:03:03","ttattrint":"12345"}},
19 | {"_id":"11","_type":"a","_source":{"ttbyte0":"10","ttbyte2":"30","ttshort0":"40","ttshort2":"100","ttint0":"110","ttint2":"130","ttint3":"10","ttlong0":"100000","ttlong2":"300000","ttlong3":"300000","ttfloat0":"2.111","ttfloat2":"6000.333","ttfloat3":"6000.333","ttdouble0":"200000.4444","ttdouble2":"900000.6666","ttdouble3":"9.6666","ttdatetime0":"2010-01-01 00:00:00","ttdatetime1":"2010/02/02 00-00-00","ttdatetime3":"2030-03-03 00:00:00","ttdatetime4":"2030-03-03 00:00:00","ttstore":"11 woyo","tttag0":"1我友 woyo 前台","tttag1":"11111","tttext0":"woyo.com的前台人员12345 测试","tttext1":"测试 www.woyo.com ,test,ceshi,3","tttext4":"测试张一 1111111111111111111111111111111111111111111测试2222222222222222222222222222","tttext5":"测试女,test","tttext6":"测试中国,test","tttext7":"测试汉族,test","dx_1":"测试数据1 soapUI is a tool for functional,testing, mainly of Web Services like SOAP based Web Services and REST Web Services, but also HTTP based services and JMS Services as well as databases. soapUI is an Open Source tool with a commercial companion, soapUI Pro, with extra functionality for companies with mission critical Web Services. soapUI is being produced by the community as well as the Open Source company eviware.soapUI","dx_2":"特大泥石流灾害,总理温家宝视察","tdz_1":"index not_analyzed storetrue策测试termVector with_positions_off测试sets","tdz_2":"index not_analyzed storetrue termVector with_positions_offsets index not_analyzed storetrue termVector with_positions_offsets","_type":"a","_id":"11#a","ttattrdate":"2013-01-01 01:02:03","ttattrint":"12345"}},
20 | {"_id":"12","_type":"a","_source":{"ttbyte0":"10","ttbyte2":"30","ttshort0":"40","ttshort2":"100","ttint0":"110","ttint2":"130","ttint3":"10","ttlong0":"100000","ttlong2":"300000","ttlong3":"300000","ttfloat0":"2.111","ttfloat2":"6000.333","ttfloat3":"6000.333","ttdouble0":"200000.4444","ttdouble2":"900000.6666","ttdouble3":"90.6666","ttdatetime0":"2000-02-01 01:02:03","ttdatetime1":"2010/02/02 00-00-00","ttdatetime3":"2030-03-03 00:00:00","ttdatetime4":"2030-03-03 00:00:00","ttstore":"22woyo","tttag0":"2我友 woyo 开发","tttag1":"测试","tttext0":"woyo.com的开发人员23456,test","tttext1":"记忆里面唯一一次到南站还是大四找工作那会儿跑上海面试完之后要回杭州,的士司机硬给拉过去的。当时那地方比破得连正门都找不到,一度以为的哥把我给忽悠了。后来听说又建成世界之最了,从浙江过来的火车都改到那里停靠,但那时已经自己开着凯越溜达了,愣是没机会一睹其风采。","tttext4":"测试 陈二,test","tttext5":"测试 男,test","tttext6":"测试 中国,test","tttext7":"测试 汉族,test","dx_1":"测试数据2 soapUI is a tool for functional,testing, mainly of Web Services like SOAP based Web Services and REST Web Services, but also HTTP based services and JMS Services as well as databases. soapUI is an Open Source tool with a commercial companion, soapUI Pro, with extra functionality for companies with mission critical Web Services. soapUI is being produced by the community as well as the Open Source company eviware.soapUI","dx_2":"测试数据2 soapUI has been downloaded more than one and a half million times and is seen as the de facto standard for Web Service,testing. For you as a user, this means there is a lot of knowledge about the tool out there. We'd like to encourage you to read the blogs on the net for more info about using soapUI in real life. There also is a Community Forum on the eviware website. We appreciate every download and work really hard to create a super product for you. If you have any ideas or thought, please let us know!soapUI","tdz_1":"index not_analyzed storetrue termVector with_positions_offsets","tdz_2":"index not_analyzed storetrue termVector with_positions_offsets index not_analyzed storetrue termVector with_positions_offsets","_type":"a","_id":"12#a","ttattrdate":"2012-01-01 01:02:03","ttattrint":"212345"}},
21 | {"_id":"16","_type":"b","_source":{"ttbyte0":"10","ttbyte2":"30","ttshort0":"40","ttshort2":"100","ttint0":"110","ttint2":"130","ttint3":"10","ttlong0":"100000","ttlong2":"300000","ttlong3":"300000","ttfloat0":"34.111","ttfloat2":"6000.333","ttfloat3":"6000.333","ttdouble0":"3700000.4444","ttdouble2":"900000.6666","ttdouble3":"9.6666","ttdatetime0":"2000-01-01 01:02:03","ttdatetime1":"2010/02/02 00-00-00","ttdatetime3":"2030-03-03 00:00:00","ttdatetime4":"2030-03-03 00:00:00","ttstore":"11 woyo","tttag0":"1我友 woyo 前台","tttag1":"11111","tttext0":"woyo.com的前台人员12345 测试","tttext1":"测试 www.woyo.com ,test","tttext4":"测试张一 1111111111111111111111111111111111111111111测试2222222222222222222222222222","tttext5":"测试女,test","tttext6":"测试中国,test","tttext7":"测试汉族,test","dx_1":"测试数据1 soapUI is a tool for functional,testing, mainly of Web Services like SOAP based Web Services and REST Web Services, but also HTTP based services and JMS Services as well as databases. soapUI is an Open Source tool with a commercial companion, soapUI Pro, with extra functionality for companies with mission critical Web Services. soapUI is being produced by the community as well as the Open Source company eviware.soapUI","dx_2":"测试数据1 soapUI has been downloaded more than one and a half million times and is seen as the de facto standard for Web Service,testing. For you as a user, this means there is a lot of knowledge about the tool out there. We'd like to encourage you to read the blogs on the net for more info about using soapUI in real life. There also is a Community Forum on the eviware website. We appreciate every download and work really hard to create a super product for you. If you have any ideas or thought, please let us know!soapUI","tdz_1":"index not_analyzed storetrue策测试termVector with_positions_off测试sets","tdz_2":"index not_analyzed storetrue termVector with_positions_offsets index not_analyzed storetrue termVector with_positions_offsets","_type":"b","_id":"16#b","ttattrdate":"2013-01-01 01:02:03","ttattrint":"412345"}},
22 | {"_id":"17","_type":"b","_source":{"ttbyte0":"10","ttbyte2":"30","ttshort0":"40","ttshort2":"100","ttint0":"110","ttint2":"130","ttint3":"10","ttlong0":"100000","ttlong2":"300000","ttlong3":"300000","ttfloat0":"44.111","ttfloat2":"6000.333","ttfloat3":"6000.333","ttdouble0":"4700000.4444","ttdouble2":"900000.6666","ttdouble3":"90.6666","ttdatetime0":"2000-02-01 01:02:03","ttdatetime1":"2010/02/02 00-00-00","ttdatetime3":"2030-03-03 00:00:00","ttdatetime4":"2030-03-03 00:00:00","ttstore":"22woyo","tttag0":"2我友 woyo 开发","tttag1":"测试","tttext0":"woyo.com的开发人员23456,test","tttext1":"www.woyo.com 测试","tttext4":"测试 陈二,test","tttext5":"测试 男,test","tttext6":"测试 中国,test","tttext7":"测试 汉族,test","dx_1":"测试数据2 soapUI is a tool for functional,testing, mainly of Web Services like SOAP based Web Services and REST Web Services, but also HTTP based services and JMS Services as well as databases. soapUI is an Open Source tool with a commercial companion, soapUI Pro, with extra functionality for companies with mission critical Web Services. soapUI is being produced by the community as well as the Open Source company eviware.soapUI","dx_2":"测试数据2 soapUI has been downloaded more than one and a half million times and is seen as the de facto standard for Web Service,testing. For you as a user, this means there is a lot of knowledge about the tool out there. We'd like to encourage you to read the blogs on the net for more info about using soapUI in real life. There also is a Community Forum on the eviware website. We appreciate every download and work really hard to create a super product for you. If you have any ideas or thought, please let us know!soapUI","tdz_1":"index not_analyzed storetrue termVector with_positions_offsets","tdz_2":"index not_analyzed storetrue termVector with_positions_offsets index not_analyzed storetrue termVector with_positions_offsets","_type":"b","_id":"17#b","ttattrdate":"2012-01-01 01:02:03","ttattrint":"412345"}},
23 | {"_id":"21","_type":"b","_source":{"ttbyte0":"10","ttbyte2":"30","ttshort0":"40","ttshort2":"100","ttint0":"110","ttint2":"130","ttint3":"10","ttlong0":"100000","ttlong2":"300000","ttlong3":"300000","ttfloat0":"54.111","ttfloat2":"6000.333","ttfloat3":"6000.333","ttdouble0":"6700000.4444","ttdouble2":"900000.6666","ttdouble3":"9.6666","ttdatetime0":"2000-01-01 01:02:03","ttdatetime1":"2010/02/02 00-00-00","ttdatetime3":"2030-03-03 00:00:00","ttdatetime4":"2030-03-03 00:00:00","ttstore":"11 woyo","tttag0":"1我友 woyo 前台","tttag1":"11111","tttext0":"woyo.com的前台人员12345 测试","tttext1":"测试 www.woyo.com ,test","tttext4":"测试张一 1111111111111111111111111111111111111111111测试2222222222222222222222222222","tttext5":"测试女,test","tttext6":"测试中国,test","tttext7":"测试汉族,test","dx_1":"测试数据1 soapUI is a tool for functional,testing, mainly of Web Services like SOAP based Web Services and REST Web Services, but also HTTP based services and JMS Services as well as databases. soapUI is an Open Source tool with a commercial companion, soapUI Pro, with extra functionality for companies with mission critical Web Services. soapUI is being produced by the community as well as the Open Source company eviware.soapUI","dx_2":"测试数据1 soapUI has been downloaded more than one and a half million times and is seen as the de facto standard for Web Service,testing. For you as a user, this means there is a lot of knowledge about the tool out there. We'd like to encourage you to read the blogs on the net for more info about using soapUI in real life. There also is a Community Forum on the eviware website. We appreciate every download and work really hard to create a super product for you. If you have any ideas or thought, please let us know!soapUI","tdz_1":"index not_analyzed storetrue策测试termVector with_positions_off测试sets","tdz_2":"index not_analyzed storetrue termVector with_positions_offsets index not_analyzed storetrue termVector with_positions_offsets","_type":"b","_id":"21#b","ttattrdate":"2013-01-01 01:02:03","ttattrint":"612345"}},
24 | {"_id":"22","_type":"b","_source":{"ttbyte0":"10","ttbyte2":"30","ttshort0":"40","ttshort2":"100","ttint0":"110","ttint2":"130","ttint3":"10","ttlong0":"100000","ttlong2":"300000","ttlong3":"300000","ttfloat0":"64.111","ttfloat2":"6000.333","ttfloat3":"6000.333","ttdouble0":"6700000.4444","ttdouble2":"900000.6666","ttdouble3":"90.6666","ttdatetime0":"2000-02-01 01:02:03","ttdatetime1":"2010/02/02 00-00-00","ttdatetime3":"2030-03-03 00:00:00","ttdatetime4":"2030-03-03 00:00:00","ttstore":"22woyo","tttag0":"2我友 woyo 开发","tttag1":"测试","tttext0":"woyo.com的开发人员23456,test","tttext1":"www.woyo.com 测试","tttext4":"测试 陈二,test","tttext5":"测试 男,test","tttext6":"测试 中国,test","tttext7":"测试 汉族,test","dx_1":"测试数据2 soapUI is a tool for functional,testing, mainly of Web Services like SOAP based Web Services and REST Web Services, but also HTTP based services and JMS Services as well as databases. soapUI is an Open Source tool with a commercial companion, soapUI Pro, with extra functionality for companies with mission critical Web Services. soapUI is being produced by the community as well as the Open Source company eviware.soapUI","dx_2":"测试数据2 soapUI has been downloaded more than one and a half million times and is seen as the de facto standard for Web Service,testing. For you as a user, this means there is a lot of knowledge about the tool out there. We'd like to encourage you to read the blogs on the net for more info about using soapUI in real life. There also is a Community Forum on the eviware website. We appreciate every download and work really hard to create a super product for you. If you have any ideas or thought, please let us know!soapUI","tdz_1":"index not_analyzed storetrue termVector with_positions_offsets","tdz_2":"index not_analyzed storetrue termVector with_positions_offsets index not_analyzed storetrue termVector with_positions_offsets","_type":"b","_id":"22#b","ttattrdate":"2012-01-01 01:02:03","ttattrint":"612345"}}]}}
25 |
26 | ${CONCURRENT.200_1000}
--------------------------------------------------------------------------------
/script/hash/query/qt/bitquery-0.txt:
--------------------------------------------------------------------------------
1 | ${BASE_URL}:${PORT}/${INDEX_NAME}//_search?q=tttext1:测试文本${SEQINT.5221395}
2 |
3 | GET
4 |
5 |
6 |
7 |
8 | ${CONCURRENT.400_100}
9 | #${SLEEP.60}
10 |
--------------------------------------------------------------------------------
/script/hash/query/qt/qt.txt:
--------------------------------------------------------------------------------
1 | http://10.29.80.100:9200/GoodsSellerT/_search?nsextend=40&o=%E6%B5%8B%E8%AF%95
2 |
3 | #POST
4 |
5 | #{"from":0,"size":40,"fields":["lSellerGoodsId","lSellerId","lGoodsId","strTitle","lBrandId","strBrandName","strBrandModel", "nPrice","strLogo1URL","nMinPrice","nMaxPrice","nSellCount","dtCreateTime","lCategoryId2","lShopId","strShopName","nRangeIndex","strActiveTag","strConsumeType"],"sort":[{"[_score *Math.atan(value(nWeight)+0.1)]":"desc"}],query:{"bool":{"must":[{"term":{ "strRangeTag":"2"}},{"query_string":{"query":"_all:测试 OR strTitle:测试"}}],}}, faceted:{ "mincount":1, "fields": {"lBrandId":{},"lCategoryId1":{} }},"group": {"fieldname": "lGoodsId"},"highlight": {"fields": {"strTitle": {"pre_tags": "","post_tags": "<\/font>"}}},}
6 |
7 |
--------------------------------------------------------------------------------
/script/hash/randkwd.txt:
--------------------------------------------------------------------------------
1 | 脚本
2 | 测试
3 | 随机
4 | 字符串
--------------------------------------------------------------------------------
/script/hash/randkwd2.txt:
--------------------------------------------------------------------------------
1 | 自定义路径
2 | 脚本
3 | 测试
4 | 随机
5 | 字符串
--------------------------------------------------------------------------------
/script/hash/schema/schema-1.txt:
--------------------------------------------------------------------------------
1 | ${BASE_URL}:${PORT}/${INDEX_NAME}/_schema
2 |
3 | POST
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | ${SLEEP.10}
62 |
--------------------------------------------------------------------------------
/script/hash/test.properties:
--------------------------------------------------------------------------------
1 | #
2 | BASE_URL=http\://hadoop2
3 | PORT=9200
4 | INDEX_NAME=hashShard4
5 | #Tag
6 | RANDINT=
7 | SEQINT=
8 | QUERYWD=
9 | QUERYWD.PATH=randkwd.txt
10 | #Command
11 | SLEEP=
12 | FOREACH=
13 | CONCURRENT=
--------------------------------------------------------------------------------
/script/jetty/jsp/index.txt:
--------------------------------------------------------------------------------
1 | ${BASE_URL}:${PORT}/index.jsp
2 |
3 | GET
4 |
5 |
6 |
7 | ${CONCURRENT.300_100}
--------------------------------------------------------------------------------
/script/jetty/servlet/test.txt:
--------------------------------------------------------------------------------
1 | ${BASE_URL}:${PORT}/servlet/test?task=${SEQINT.1}
2 |
3 | GET
4 |
5 |
6 |
7 | ${CONCURRENT.300_100}
--------------------------------------------------------------------------------
/script/jetty/test.properties:
--------------------------------------------------------------------------------
1 | #
2 | BASE_URL=http\://localhost
3 | PORT=9009
4 | INDEX_NAME=
5 | #Tag
6 | RANDINT=
7 | SEQINT=
8 | QUERYWD=
9 | QUERYWD.PATH=
10 | #Command
11 | SLEEP=
12 | FOREACH=
13 | CONCURRENT=
--------------------------------------------------------------------------------
/script/netty/get/demo.txt:
--------------------------------------------------------------------------------
1 | ${BASE_URL}:${PORT}/demo/test?task=${SEQINT.1}
2 |
3 | GET
4 |
5 |
6 |
7 | ${CONCURRENT.300_1000}
--------------------------------------------------------------------------------
/script/netty/test.properties:
--------------------------------------------------------------------------------
1 | #
2 | BASE_URL=http\://localhost
3 | PORT=9090
4 | INDEX_NAME=
5 | #Tag
6 | RANDINT=
7 | SEQINT=
8 | QUERYWD=
9 | QUERYWD.PATH=
10 | #Command
11 | SLEEP=
12 | FOREACH=
13 | CONCURRENT=
--------------------------------------------------------------------------------
/src/org/langke/testscript/WebBench.java:
--------------------------------------------------------------------------------
1 | package org.langke.testscript;
2 |
3 | import java.util.concurrent.ExecutorService;
4 | import java.util.concurrent.Executors;
5 | import java.util.concurrent.atomic.AtomicInteger;
6 |
7 | import net.sf.json.JSONObject;
8 |
9 | import org.langke.testscript.common.HttpClientUtil;
10 | import org.langke.testscript.common.Response;
11 | import org.langke.util.logging.ESLogger;
12 | import org.langke.util.logging.Loggers;
13 |
14 | /**
15 | * 指定时间并发测试
16 | * @author langke
17 | * @since JDK1.6
18 | * @version 1.0
19 | *
20 | */
21 | public class WebBench {
22 |
23 | private ESLogger log = Loggers.getLogger(WebBench.class);
24 | private String url;
25 | private String body;
26 | private String method;
27 | volatile String result;
28 | AtomicInteger send=new AtomicInteger();
29 | AtomicInteger receive=new AtomicInteger();
30 | AtomicInteger qps=new AtomicInteger();//每秒执行次数
31 | AtomicInteger maxQps=new AtomicInteger();
32 | AtomicInteger success = new AtomicInteger();
33 | AtomicInteger error=new AtomicInteger();
34 | AtomicInteger totalShowTime = new AtomicInteger();//显示查询时间
35 | AtomicInteger totalFactTime = new AtomicInteger();//实际查询时间
36 | AtomicInteger totalHits = new AtomicInteger();//结果记录数
37 | AtomicInteger affected = new AtomicInteger();//影响记录数
38 | volatile boolean stopThread = false;
39 | Integer total = 1;//并发数
40 | Long runTime;//需要执行时间
41 | Long startTime;//开始执行时间
42 | Long exec_time;
43 | Object lock = new Object();
44 |
45 | public void success(int showTime, int factTime, int hits,Response response) {
46 | synchronized(lock) {
47 | success.incrementAndGet();
48 | totalShowTime.addAndGet(showTime);
49 | totalFactTime.addAndGet(factTime);
50 | totalHits.addAndGet(hits);
51 | receive.incrementAndGet();
52 | qps.incrementAndGet();
53 | result = response.getResult();
54 | }
55 | }
56 | public synchronized void failed(Response response) {
57 | error.incrementAndGet();
58 | receive.incrementAndGet();
59 | result = response.getResult();
60 | if(error.get()<10 && response !=null){
61 | log.error("{}", JSONObject.fromObject(response));
62 | }
63 | }
64 |
65 | /**
66 | * 并发执行指定时长
67 | * @param url
68 | * @param concurrent 并发数
69 | * @param time 执行时间/秒
70 | * @return
71 | */
72 | public String runInTime(String url,Integer concurrent,Integer time){
73 | if(concurrent == null)
74 | concurrent = 1;
75 | if(time == null)
76 | time = 30;
77 | this.url = url;
78 | this.method = "GET";
79 | this.startTime = System.currentTimeMillis();
80 | this.exec_time = this.startTime;
81 | this.runTime = (long) (time * 1000);
82 | this.total = concurrent;
83 | ExecutorService es = Executors.newFixedThreadPool(concurrent);
84 | for(int i=0;i= runTime){
121 | break;
122 | }
123 | }
124 | }catch(Exception e){
125 | log.error("{}", e);
126 | log.error("code{} msg{} result{}", response.getCode(),response.getMsg(),response.getResult());
127 | failed(response);
128 | }
129 | }
130 | };
131 | }
132 |
133 | /**
134 | * 执行中间汇报
135 | */
136 | public void monitorReportThread(){
137 | new Thread("test_monitor"){
138 | public void run(){
139 | while(!stopThread){
140 | if(qps.get()>maxQps.get())
141 | maxQps.set(qps.get());
142 | synchronized(lock) {
143 | log.info("send:{} receive:{} error:{} hits/req:{} affected:{} showtime/req:{} facttime/req:{} qps:{} maxQps{}"
144 | ,send.get(),receive.get(),error.get(),getDiv(totalHits.get(),receive.get()), affected.get(),getDiv(totalShowTime.get(),qps.get()),getDiv(totalFactTime.get(),qps.get()),qps.get(),maxQps.get());
145 | totalShowTime.set(0);
146 | totalFactTime.set(0);
147 | totalHits.set(0);
148 | qps.set(0);
149 | }
150 | try{
151 | Thread.sleep(1000);
152 | }catch (InterruptedException e){
153 | Thread.currentThread().interrupt(); // re-assert interrupt
154 | }
155 | }
156 | }
157 | }.start();
158 | }
159 |
160 | public String getJsonString(String key,JSONObject json){
161 | String res = null;
162 | try{
163 | res = json.getString(key);
164 | }catch(Exception e){
165 | }
166 | return res;
167 | }
168 | public int getDiv(int a,int b ){
169 | if(b==0)
170 | return b;
171 | else
172 | return a/b;
173 | }
174 |
175 | public int getDiv(long a,int b ){
176 | if(b==0)
177 | return b;
178 | else
179 | return (int) (a/b);
180 | }
181 |
182 | /**
183 | * 等待任务完成,并汇总执行结果
184 | */
185 | public void waitTaskReport(){
186 | while(!stopThread){
187 | if(System.currentTimeMillis() - startTime >= runTime){//执行结果汇总
188 | exec_time = System.currentTimeMillis()-exec_time;
189 | log.info("Thread exit !concurrent num:{} exec_time:{} send:{} receive:{} error:{} exec_time:{} ms " +
190 | " hits/req:{} affected:{} showtime/req:{} facttime/req:{} average/s:{}" ,
191 | total,exec_time,send.get(),receive.get(),error.get(),exec_time,
192 | getDiv(totalHits.get(),receive.get()), affected.get(),
193 | getDiv(totalShowTime.get(),receive.get()),
194 | getDiv(totalFactTime.get(),receive.get()),
195 | getDiv(receive.get(),getDiv(exec_time,1000))
196 | );
197 | stopThread = true;
198 | }
199 | try {
200 | Thread.sleep(1);
201 | } catch (InterruptedException e) {
202 | log.error("{}", e);
203 | }
204 | }
205 | }
206 | }
207 |
--------------------------------------------------------------------------------
/src/org/langke/testscript/cmd/Cmd.java:
--------------------------------------------------------------------------------
1 | package org.langke.testscript.cmd;
2 |
3 | import org.langke.testscript.Test;
4 | import org.langke.testscript.common.HttpClientUtil;
5 | import org.langke.testscript.common.HttpSupporter;
6 | import org.langke.testscript.common.Response;
7 | import org.langke.testscript.common.TestConfig;
8 |
9 | /**
10 | * 指令抽象类
11 | * @author langke
12 | *
13 | */
14 | public abstract class Cmd {
15 | public abstract Object exec(String command,String key,String URL,String BODY,String METHOD,TestConfig projConfig);
16 |
17 | /**
18 | * 提交数据返回字符串结果
19 | * @param URL
20 | * @param BODY
21 | * @param METHOD
22 | * @param projConfig
23 | * @return String
24 | */
25 | public String postData(String URL,String BODY,String METHOD,TestConfig projConfig){
26 | String seg="|||SEG|||";
27 | String all=URL+seg+BODY;
28 | all=Test.replaceTag(projConfig, all);
29 |
30 | int index=all.indexOf(seg);
31 |
32 | URL = all.substring(0,index);
33 | BODY=all.substring(index+seg.length());
34 |
35 | String result = HttpSupporter.doRequest(URL, BODY,METHOD);
36 | return result;
37 | }
38 |
39 | /**
40 | * 提交数据返回Response对象
41 | * @param URL
42 | * @param BODY
43 | * @param METHOD
44 | * @param projConfig
45 | * @return Response
46 | */
47 | public Response postDataResp(String URL,String BODY,String METHOD,TestConfig projConfig){
48 | String seg="|||SEG|||";
49 | String all=URL+seg+BODY;
50 | all=Test.replaceTag(projConfig, all);
51 |
52 | int index=all.indexOf(seg);
53 |
54 | URL = all.substring(0,index);
55 | BODY=all.substring(index+seg.length());
56 | Response response = HttpClientUtil.getInstance().new Execute().exec(URL, BODY, METHOD);//new HttpSupporter().getRequestToResponse(URL, BODY,METHOD);
57 | return response;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/org/langke/testscript/cmd/CmdFactory.java:
--------------------------------------------------------------------------------
1 | package org.langke.testscript.cmd;
2 |
3 | import java.util.HashMap;
4 | import java.util.Map;
5 | /**
6 | * 指令定义
7 | * @author langke_li
8 | *
9 | */
10 | public class CmdFactory {
11 | private static Map cmdClasses = new HashMap();
12 | static {
13 | cmdClasses.put("SLEEP", new Sleep());
14 | cmdClasses.put("FOREACH", new ForEach());
15 | cmdClasses.put("CONCURRENT", new Concurrent());
16 | }
17 | public static Cmd getCmd(String tagName)throws InstantiationException,IllegalAccessException {
18 | return cmdClasses.get(tagName);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/org/langke/testscript/cmd/Concurrent.java:
--------------------------------------------------------------------------------
1 | package org.langke.testscript.cmd;
2 |
3 | import java.util.concurrent.ExecutorService;
4 | import java.util.concurrent.Executors;
5 | import java.util.concurrent.atomic.AtomicInteger;
6 |
7 | import org.langke.testscript.common.HttpSupporter;
8 | import org.langke.testscript.common.Response;
9 | import org.langke.testscript.common.TestConfig;
10 | import org.langke.util.logging.ESLogger;
11 | import org.langke.util.logging.Loggers;
12 |
13 | import net.sf.json.JSONObject;
14 |
15 | /**
16 | * 并发指令
17 | * @author langke
18 | * @since JDK1.6
19 | * @version 1.8
20 | *
21 | */
22 | public class Concurrent extends Cmd{
23 | private ESLogger log = Loggers.getLogger(Concurrent.class);
24 | private String url;
25 | private String body;
26 | private String method;
27 | private TestConfig projConfig;
28 | volatile String result;
29 | AtomicInteger send=new AtomicInteger();
30 | AtomicInteger receive=new AtomicInteger();
31 | AtomicInteger qps=new AtomicInteger();//每秒执行次数
32 | AtomicInteger maxQps=new AtomicInteger();
33 | AtomicInteger success = new AtomicInteger();
34 | AtomicInteger error=new AtomicInteger();
35 | AtomicInteger totalShowTime = new AtomicInteger();//显示查询时间
36 | AtomicInteger totalFactTime = new AtomicInteger();//实际查询时间
37 | AtomicInteger totalHits = new AtomicInteger();//结果记录数
38 | AtomicInteger affected = new AtomicInteger();//影响记录数
39 | volatile boolean stopThread = false;
40 | Integer total = 1;//并发数
41 | Integer taskNum = 1;//任务个数
42 | Long exec_time;
43 | Object lock = new Object();
44 |
45 | void setParm(String url,String body,String method,TestConfig projConfig){
46 | this.url = url;
47 | this.body = body;
48 | this.method = method;
49 | this.projConfig = projConfig;
50 | }
51 |
52 |
53 | public void success(int showTime, int factTime, int hits,Response response) {
54 | synchronized(lock) {
55 | success.incrementAndGet();
56 | totalShowTime.addAndGet(showTime);
57 | totalFactTime.addAndGet(factTime);
58 | totalHits.addAndGet(hits);
59 | receive.incrementAndGet();
60 | qps.incrementAndGet();
61 | result = response.getResult();
62 | }
63 | }
64 | public synchronized void failed(Response response) {
65 | error.incrementAndGet();
66 | receive.incrementAndGet();
67 | result = response.getResult();
68 | if(error.get()<10 && response !=null){
69 | log.error("{}", JSONObject.fromObject(response));
70 | }
71 | }
72 |
73 | @Override
74 | public Object exec(String command, String key, String URL, String BODY,
75 | String METHOD, final TestConfig projConfig) {
76 | String tag = "${"+key+".";
77 | String temp ;
78 | temp = command.substring(command.indexOf(tag)+tag.length());
79 | temp = temp.substring(0,temp.indexOf('}'));
80 | if(!temp.equals("")) {
81 | if(temp.indexOf('_')!=-1){//10_100 并发任务格式,前面并发数,后面任务执行次数
82 | total = Integer.valueOf(temp.substring(0, temp.indexOf("_")));
83 | taskNum = Integer.valueOf(temp.substring(temp.indexOf("_")+1));
84 | }else
85 | total = Integer.valueOf(temp);
86 | }
87 | setParm(URL, BODY, METHOD,projConfig);
88 | exec_time = System.currentTimeMillis();
89 | ExecutorService es = Executors.newFixedThreadPool(total);
90 | for(int i=0;imaxQps.get())
171 | maxQps.set(qps.get());
172 | synchronized(lock) {
173 | log.info("send:{} receive:{} error:{} hits/req:{} affected:{} showtime/req:{} facttime/req:{} qps:{} maxQps{}"
174 | ,send.get(),receive.get(),error.get(),getDiv(totalHits.get(),receive.get()), affected.get(),getDiv(totalShowTime.get(),qps.get()),getDiv(totalFactTime.get(),qps.get()),qps.get(),maxQps.get());
175 | totalShowTime.set(0);
176 | totalFactTime.set(0);
177 | totalHits.set(0);
178 | qps.set(0);
179 | }
180 | try{
181 | Thread.sleep(1000);
182 | }catch (InterruptedException e){
183 | Thread.currentThread().interrupt(); // re-assert interrupt
184 | }
185 | }
186 | }
187 | }.start();
188 | }
189 |
190 | public String getJsonString(String key,JSONObject json){
191 | String res = null;
192 | try{
193 | res = json.getString(key);
194 | }catch(Exception e){
195 | }
196 | return res;
197 | }
198 | public int getDiv(int a,int b ){
199 | if(b==0)
200 | return b;
201 | else
202 | return a/b;
203 | }
204 |
205 | public int getDiv(long a,int b ){
206 | if(b==0)
207 | return b;
208 | else
209 | return (int) (a/b);
210 | }
211 |
212 | /**
213 | * 等待任务完成,并汇总执行结果
214 | */
215 | public void waitTaskReport(){
216 | while(!stopThread){
217 | if(receive.get()==total*taskNum){//执行结果汇总
218 | exec_time = System.currentTimeMillis()-exec_time;
219 | log.info("Thread exit !concurrent num:{} taskNum:{} send:{} receive:{} error:{} exec_time:{} ms " +
220 | " hits/req:{} affected:{} showtime/req:{} facttime/req:{} average/s:{}" ,
221 | total,taskNum,send.get(),receive.get(),error.get(),exec_time,
222 | getDiv(totalHits.get(),receive.get()), affected.get(),
223 | getDiv(totalShowTime.get(),receive.get()),
224 | getDiv(totalFactTime.get(),receive.get()),
225 | getDiv(receive.get(),getDiv(exec_time,1000))
226 | );
227 | stopThread = true;
228 | }
229 | try {
230 | Thread.sleep(1);
231 | } catch (InterruptedException e) {
232 | log.error("{}", e);
233 | }
234 | }
235 | }
236 |
237 | public void concurrentTest(String URL){
238 | this.url = URL;
239 |
240 | for(int i=0;i= 0xF0 ) break;
100 | if ( 0x80 <= read && read <= 0xBF ) // 单独出现BF以下的,也算是GBK
101 | break;
102 | if ( 0xC0 <= read && read <= 0xDF ) {
103 | read = bis.read();
104 | if ( 0x80 <= read && read <= 0xBF ) // 双字节 (0xC0 - 0xDF) (0x80
105 | // - 0xBF),也可能在GB编码内
106 | continue;
107 | else break;
108 | }else if ( 0xE0 <= read && read <= 0xEF ) {// 也有可能出错,但是几率较小
109 | read = bis.read();
110 | if ( 0x80 <= read && read <= 0xBF ) {
111 | read = bis.read();
112 | if ( 0x80 <= read && read <= 0xBF ) {
113 | charset = "UTF-8";
114 | break;
115 | }
116 | else break;
117 | }
118 | else break;
119 | }
120 | }
121 | //System.out.println( loc + " " + Integer.toHexString( read ) );
122 | }
123 |
124 | bis.close();
125 | } catch ( Exception e ) {
126 | e.printStackTrace();
127 | }
128 |
129 | return charset;
130 | }
131 |
132 | public static void deleteFile(File oldPath) {
133 | if (oldPath.isDirectory()) {
134 | File[] files = oldPath.listFiles();
135 | for (File file : files) {
136 | deleteFile(file);
137 | }
138 | } else {
139 | oldPath.delete();
140 | }
141 | }
142 | /**
143 | * String转JDOM Element
144 | * @param xmlString
145 | * @return
146 | */
147 | /* public static Element getJdomElement(String xmlString){
148 | xmlString = xmlString.replaceAll("UTF-8", "gb2312");//UTF-8无法识别中文
149 | InputStream inputStream;
150 | SAXBuilder builder = new SAXBuilder();
151 | Document document;
152 | Element element = null;
153 | try {
154 | inputStream = new ByteArrayInputStream(xmlString.getBytes());
155 | document = builder.build(inputStream);
156 | element = document.getRootElement(); // 获得根节点
157 | } catch (Exception e) {
158 | e.printStackTrace();
159 | }
160 | return element;
161 | }*/
162 | }
163 |
--------------------------------------------------------------------------------
/src/org/langke/testscript/common/HttpClientUtil.java:
--------------------------------------------------------------------------------
1 | package org.langke.testscript.common;
2 |
3 | import java.net.URI;
4 | import java.net.URISyntaxException;
5 |
6 | import org.apache.commons.httpclient.HttpClient;
7 | import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
8 | import org.apache.commons.httpclient.methods.DeleteMethod;
9 | import org.apache.commons.httpclient.methods.GetMethod;
10 | import org.apache.commons.httpclient.methods.PostMethod;
11 | import org.apache.commons.httpclient.methods.PutMethod;
12 | import org.apache.commons.httpclient.methods.RequestEntity;
13 | import org.apache.commons.httpclient.methods.StringRequestEntity;
14 | import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
15 | import org.apache.commons.httpclient.params.HttpMethodParams;
16 | import org.langke.util.logging.ESLogger;
17 | import org.langke.util.logging.Loggers;
18 |
19 | /**
20 | * httpclient 公共方法
21 | * 提供get put post delete 几种方式调用
22 | * @author langke
23 | * @since httpclient4.0.1
24 | * @version 1.0
25 | */
26 | public class HttpClientUtil {
27 |
28 | private static ESLogger log = Loggers.getLogger(HttpClientUtil.class);
29 | private static HttpClient client = null;
30 | private static MultiThreadedHttpConnectionManager conn_manager = null;
31 | private static HttpConnectionManagerParams cmanager_params = null;
32 | private static final HttpClientUtil instance = new HttpClientUtil();
33 |
34 | private HttpClientUtil() {
35 | }
36 |
37 | public static HttpClientUtil getInstance(){
38 | return instance;
39 | }
40 |
41 | static{
42 | if(client==null) init();
43 | }
44 |
45 | private static void init(){
46 | if (conn_manager == null)
47 | conn_manager = new MultiThreadedHttpConnectionManager();
48 | if (cmanager_params == null)
49 | cmanager_params = new HttpConnectionManagerParams();
50 | // config the HTTP client visit performance.
51 | cmanager_params.setDefaultMaxConnectionsPerHost(10240);
52 | cmanager_params.setMaxTotalConnections(10240);
53 | cmanager_params.setParameter(HttpMethodParams.USE_EXPECT_CONTINUE, false);
54 | //cmanager_params.setConnectionTimeout(6000);
55 | //cmanager_params.setSoTimeout(6000);
56 | conn_manager.setParams(cmanager_params);
57 | if (client == null)
58 | client = new HttpClient(conn_manager);
59 | }
60 |
61 | /**
62 | * 内部类,封装http调用方式
63 | * HttpClientUtil.getInstance().new Execute().exec("url", null, "GET")
64 | * @author langke
65 | * @since httpclient4.0.1
66 | * @version 1.0
67 | */
68 | public class Execute {
69 | public Response exec(String url,String body,String method){
70 | if(method.equalsIgnoreCase("get")){
71 | return new Execute().get(url);
72 | }else if(method.equalsIgnoreCase("post")){
73 | return new Execute().post(url,body);
74 | }else if(method.equalsIgnoreCase("put")){
75 | return new Execute().put(url,body);
76 | }else if(method.equalsIgnoreCase("delete")){
77 | return new Execute().delete(url);
78 | }else{
79 | Response res = new Response();
80 | res.setCode(400);
81 | res.setMsg("not found method :"+method);
82 | return res;
83 | }
84 | }
85 |
86 | public Response get(String url){
87 | GetMethod method = null;
88 | Response res = new Response();
89 | try {
90 | if(url.indexOf("?")!=-1){
91 | try {
92 | url = new URI(url).toASCIIString();
93 | } catch (URISyntaxException e) {
94 | log.error("{}", e.toString());
95 | }
96 | }
97 | method = new GetMethod(url);
98 | method.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");
99 | int status = client.executeMethod(method);
100 | String resp = method.getResponseBodyAsString();
101 | res.result= resp;
102 | res.msg = method.getStatusText();
103 | res.header = method.getResponseHeader("Content-Type").getValue();
104 | res.code = status;
105 | } catch (Exception e) {
106 | res.setCode(500);
107 | res.setMsg(e.toString());
108 | log.error("{}", e.toString());
109 | } finally{
110 | if(method != null){
111 | method.releaseConnection();
112 | }
113 | }
114 | return res;
115 | }
116 |
117 | public Response post(String url, String requestBody){
118 | PostMethod method = null;
119 | Response res = new Response();
120 | try {
121 | method = new PostMethod(url);
122 | method.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");
123 | if(requestBody != null){
124 | RequestEntity reqEntity = new StringRequestEntity(requestBody, "application/json", "UTF-8");
125 | method.setRequestEntity(reqEntity);
126 | }
127 | int status = client.executeMethod(method);
128 | String resp = method.getResponseBodyAsString();
129 | res.result= resp;
130 | res.msg = method.getStatusText();
131 | res.header = method.getResponseHeader("Content-Type").getValue();
132 | res.code = status;
133 | return res;
134 | } catch (Exception e) {
135 | res.setCode(500);
136 | res.setMsg(e.toString());
137 | log.error("{}", e.toString());
138 | } finally{
139 | if(method != null){
140 | method.releaseConnection();
141 | }
142 | }
143 | return res;
144 | }
145 |
146 | public Response put(String url, String requestBody){
147 | PutMethod method = null;
148 | Response res = new Response();
149 | try {
150 | method = new PutMethod(url);
151 | method.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");
152 | if(requestBody != null){
153 | RequestEntity reqEntity = new StringRequestEntity(requestBody, "application/json", "UTF-8");
154 | method.setRequestEntity(reqEntity);
155 | }
156 | int status = client.executeMethod(method);
157 | String resp = method.getResponseBodyAsString();
158 | res.result= resp;
159 | res.msg = method.getStatusText();
160 | res.header = method.getResponseHeader("Content-Type").getValue();
161 | res.code = status;
162 | return res;
163 | } catch (Exception e) {
164 | res.setCode(500);
165 | res.setMsg(e.toString());
166 | log.error("{}", e.toString());
167 | } finally{
168 | if(method != null){
169 | method.releaseConnection();
170 | }
171 | }
172 | return res;
173 | }
174 |
175 |
176 | public Response delete(String url){
177 | DeleteMethod method = null;
178 | Response res = new Response();
179 | try {
180 | method = new DeleteMethod(url);
181 | method.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");
182 | int status = client.executeMethod(method);
183 | String resp = method.getResponseBodyAsString();
184 | res.result= resp;
185 | res.msg = method.getStatusText();
186 | res.header = method.getResponseHeader("Content-Type").getValue();
187 | res.code = status;
188 | return res;
189 | } catch (Exception e) {
190 | res.setCode(500);
191 | res.setMsg(e.toString());
192 | log.error("{}", e.toString());
193 | } finally{
194 | if(method != null){
195 | method.releaseConnection();
196 | }
197 | }
198 | return res;
199 | }
200 | /**
201 | * 失败后,重试3次
202 | * @param uri
203 | * @param json
204 | * @return
205 | */
206 | public Response tryExecute(String uri, String json){
207 | Response res = post(uri, json);
208 | if(res != null){
209 | return res;
210 | }
211 | int tryCount = 3;
212 | while(res == null && (tryCount--) > 0 ){
213 | res = post(uri, json);
214 | try {
215 | Thread.sleep(20);
216 | } catch (InterruptedException e) {
217 | log.error("{}", e.toString());
218 | }
219 | }
220 | return res;
221 | }
222 | }
223 |
224 | public static void main(String[] args) {
225 | Response resp = HttpClientUtil.getInstance().new Execute().exec("http://dfs1:9200/test_mem//_search?q=tttext0:functional1", null, "GET");
226 | System.out.println(resp.code+resp.msg+resp.result);
227 | }
228 |
229 | }
230 |
--------------------------------------------------------------------------------
/src/org/langke/testscript/common/HttpSupporter.java:
--------------------------------------------------------------------------------
1 | package org.langke.testscript.common;
2 |
3 | import java.io.ByteArrayOutputStream;
4 | import java.io.IOException;
5 | import java.io.InputStream;
6 | import java.io.UnsupportedEncodingException;
7 | import java.net.HttpURLConnection;
8 | import java.net.MalformedURLException;
9 | import java.net.URI;
10 | import java.net.URISyntaxException;
11 | import java.net.URL;
12 | import java.net.URLConnection;
13 |
14 | import javax.net.ssl.HostnameVerifier;
15 | import javax.net.ssl.HttpsURLConnection;
16 | import javax.net.ssl.SSLSession;
17 |
18 | import org.langke.util.logging.ESLogger;
19 | import org.langke.util.logging.Loggers;
20 |
21 | /**
22 | * URLConnection 调用http方法封装
23 | * @author langke
24 | * @since JDK1.6
25 | * @version 1.0
26 | */
27 | public class HttpSupporter {
28 | private static ESLogger log = Loggers.getLogger(HttpSupporter.class);
29 |
30 | public static String doRequest(String url,String body, String method) {
31 | String result = null;
32 | byte[] bodyByte ;
33 | try {
34 | if(body==null)
35 | bodyByte = null;
36 | else
37 | bodyByte = body.getBytes("UTF-8");
38 | result = doRequest( url,bodyByte , method) ;
39 | } catch (UnsupportedEncodingException e) {
40 | result = e.toString();
41 | log.error("{}", e);
42 | }
43 | return result;
44 | }
45 |
46 | public static String doRequest(String url, byte[] body, String method) {
47 | ByteArrayOutputStream content = new ByteArrayOutputStream();
48 | InputStream is = null;
49 | String result=null;
50 | URLConnection conn = null;
51 | HttpURLConnection httpconn = null;
52 | HttpsURLConnection httpsconn = null;
53 | try {
54 | if(body!=null && body.length==0) body = null;
55 | if(method.equals("GET") && url.indexOf("?")!=-1){
56 | //url = url.substring(0, url.indexOf('?')+1)+java.net.URLEncoder.encode(url.substring(url.indexOf('?')+1),"UTF-8");
57 | //url = url.replace("%3D", "=");
58 | try {
59 | url = new URI(url).toASCIIString();
60 | } catch (URISyntaxException e) {
61 | log.error("{}", e);
62 | }
63 | }
64 | conn = new URL(url).openConnection();
65 | if (conn instanceof HttpURLConnection) {
66 | httpconn = (HttpURLConnection) conn;
67 | httpconn.setRequestMethod(method);
68 | if (body != null){
69 | httpconn.setDoOutput(true);
70 | httpconn.getOutputStream().write(body);
71 | }else{
72 | httpconn.setDoOutput(false);
73 | }
74 | int code=httpconn.getResponseCode();
75 | if(code!=200){
76 | is=httpconn.getErrorStream();
77 | }else{
78 | is=httpconn.getInputStream();
79 | }
80 | } else if (conn instanceof HttpsURLConnection) {
81 | httpsconn = (HttpsURLConnection) conn;
82 | httpsconn.setHostnameVerifier(new HostnameVerifier() {
83 |
84 | @Override
85 | public boolean verify(String arg0, SSLSession arg1) {
86 | return true;
87 | }
88 | });
89 | httpsconn.setRequestMethod(method);
90 | if (body != null){
91 | httpsconn.setDoOutput(true);
92 | httpsconn.getOutputStream().write(body);
93 | }
94 | int code=httpsconn.getResponseCode();
95 | if(code!=200){
96 | is=httpsconn.getErrorStream();
97 | }else{
98 | is = httpsconn.getInputStream();
99 | }
100 | }
101 | byte[] buf = new byte[1024];
102 | int amount;
103 | if(is!=null){
104 | while ((amount = is.read(buf)) != -1) {
105 | content.write(buf, 0, amount);
106 | }
107 | }
108 | } catch (MalformedURLException e) {
109 | log.error("{}", e);
110 | } catch (IOException e) {
111 | log.error("{}", e);
112 | }
113 | try {
114 | result=new String(content.toByteArray(),"UTF-8");
115 | } catch (UnsupportedEncodingException e) {
116 | log.error("{}", e);
117 | }
118 | try{
119 | if(content != null) content.close(); content = null;
120 | if(is != null) is.close(); is = null;
121 | if(httpconn!= null) httpconn.disconnect();httpconn = null;
122 | if(httpsconn != null)httpsconn.disconnect();
123 | }catch(Exception e){
124 | log.error("{}", e);
125 | }
126 | return result;
127 | }
128 |
129 | public Response getRequestToResponse(String url, String body, String method) {
130 | byte[] bodyByte = null;
131 | try {
132 | if(body==null)
133 | bodyByte = null;
134 | else if(body.length()==0)
135 | body = null;
136 | else
137 | bodyByte = body.getBytes("UTF-8");
138 | if(method.equals("GET") && url.indexOf("?")!=-1){
139 | //url = url.substring(0, url.indexOf('?')+1)+java.net.URLEncoder.encode(url.substring(url.indexOf('?')+1),"UTF-8");
140 | //url = url.replace("%3D", "=");
141 | try {
142 | url = new URI(url).toASCIIString();
143 | } catch (URISyntaxException e) {
144 | log.error("{}", e);
145 | }
146 | }
147 | } catch (UnsupportedEncodingException e) {
148 | log.error("{}", e);
149 | }
150 | ByteArrayOutputStream content = new ByteArrayOutputStream();
151 | InputStream is = null;
152 | Response response= new Response();
153 | String result = null;
154 | URLConnection conn = null;
155 | HttpURLConnection httpconn = null;
156 | HttpsURLConnection httpsconn = null;
157 | try {
158 | conn = new URL(url).openConnection();
159 | if (conn instanceof HttpURLConnection) {
160 | httpconn = (HttpURLConnection) conn;
161 | httpconn.setRequestMethod(method);
162 | if (body != null){
163 | httpconn.setDoOutput(true);
164 | httpconn.getOutputStream().write(bodyByte);
165 | }else{
166 | httpconn.setDoOutput(false);
167 | }
168 | int code=httpconn.getResponseCode();
169 | if(code!=200){
170 | is=httpconn.getErrorStream();
171 | }else{
172 | is=httpconn.getInputStream();
173 | }
174 | } else if (conn instanceof HttpsURLConnection) {
175 | httpsconn = (HttpsURLConnection) conn;
176 | httpsconn.setHostnameVerifier(new HostnameVerifier() {
177 |
178 | @Override
179 | public boolean verify(String arg0, SSLSession arg1) {
180 | return true;
181 | }
182 | });
183 | httpsconn.setRequestMethod(method);
184 | if (body != null){
185 | httpsconn.setDoOutput(true);
186 | httpsconn.getOutputStream().write(bodyByte);
187 | }
188 | int code=httpsconn.getResponseCode();
189 | if(code!=200){
190 | is=httpsconn.getErrorStream();
191 | }else{
192 | is = httpsconn.getInputStream();
193 | }
194 | }
195 | byte[] buf = new byte[1024];
196 | int amount;
197 | if(is!=null){
198 | while ((amount = is.read(buf)) != -1) {
199 | content.write(buf, 0, amount);
200 | }
201 | result=new String(content.toByteArray(),"UTF-8");
202 | }
203 | response.setCode(httpconn.getResponseCode());
204 | response.setMsg(httpconn.getResponseMessage());
205 | response.setResult(result);
206 | } catch (MalformedURLException e) {
207 | log.error("{}", e);
208 | } catch (Exception e) {
209 | log.error("{}", e);
210 | } finally{
211 | try{
212 | if(content != null) content.close();
213 | if(is != null) is.close();
214 | if(httpconn!= null) httpconn.disconnect();
215 | if(httpsconn != null)httpsconn.disconnect();
216 | }catch(Exception e){
217 | log.error("{}", e);
218 | }
219 | }
220 | return response;
221 | }
222 | }
--------------------------------------------------------------------------------
/src/org/langke/testscript/common/Response.java:
--------------------------------------------------------------------------------
1 | package org.langke.testscript.common;
2 |
3 | /**
4 | * Http请求响应体
5 | * @author langke
6 | * @since JDK1.6
7 | * @version 1.0
8 | */
9 | public class Response {
10 | volatile int code;
11 | volatile String header;
12 | volatile String msg;
13 | volatile String result;
14 | public int getCode() {
15 | return code;
16 | }
17 | public void setCode(int i) {
18 | this.code = i;
19 | }
20 | public String getMsg() {
21 | return msg;
22 | }
23 | public void setMsg(String msg) {
24 | this.msg = msg;
25 | }
26 | public String getResult() {
27 | return result;
28 | }
29 | public void setResult(String result) {
30 | this.result = result;
31 | }
32 | public String getHeader() {
33 | return header;
34 | }
35 | public void setHeader(String header) {
36 | this.header = header;
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/src/org/langke/testscript/common/Strings.java:
--------------------------------------------------------------------------------
1 | package org.langke.testscript.common;
2 |
3 | import java.io.BufferedInputStream;
4 | import java.io.ByteArrayOutputStream;
5 | import java.io.File;
6 | import java.io.IOException;
7 | import java.io.PrintWriter;
8 | import java.util.List;
9 |
10 | /**
11 | * 字符串处理类
12 | * @author langke
13 | * @since JDK1.6
14 | * @version Strings1.0
15 | *
16 | */
17 | public class Strings {
18 |
19 | public static int[] toIntArray(String[] array){
20 | int[] arrayInt = new int[array.length];
21 | for(int i=0;i 1024) {
77 | sb.append(buffer, 0, bufferIndex);
78 | bufferIndex = 0;
79 | }
80 | b = c;
81 | c = chars[i];
82 | switch (c) {
83 | case '\\':
84 | case '"':
85 | buffer[bufferIndex++] = '\\';
86 | buffer[bufferIndex++] = c;
87 | break;
88 | case '/':
89 | if (b == '<') {
90 | buffer[bufferIndex++] = '\\';
91 | }
92 | buffer[bufferIndex++] = c;
93 | break;
94 | default:
95 | if (c < ' ') {
96 | switch (c) {
97 | case '\b':
98 | buffer[bufferIndex++] = '\\';
99 | buffer[bufferIndex++] = 'b';
100 | break;
101 | case '\t':
102 | buffer[bufferIndex++] = '\\';
103 | buffer[bufferIndex++] = 't';
104 | break;
105 | case '\n':
106 | buffer[bufferIndex++] = '\\';
107 | buffer[bufferIndex++] = 'n';
108 | break;
109 | case '\f':
110 | buffer[bufferIndex++] = '\\';
111 | buffer[bufferIndex++] = 'f';
112 | break;
113 | case '\r':
114 | buffer[bufferIndex++] = '\\';
115 | buffer[bufferIndex++] = 'r';
116 | break;
117 | default:
118 | t = "000" + Integer.toHexString(c);
119 | int tLength = t.length();
120 | buffer[bufferIndex++] = '\\';
121 | buffer[bufferIndex++] = 'u';
122 | buffer[bufferIndex++] = t.charAt(tLength - 4);
123 | buffer[bufferIndex++] = t.charAt(tLength - 3);
124 | buffer[bufferIndex++] = t.charAt(tLength - 2);
125 | buffer[bufferIndex++] = t.charAt(tLength - 1);
126 | }
127 | } else {
128 | buffer[bufferIndex++] = c;
129 | }
130 | }
131 | }
132 | sb.append(buffer, 0, bufferIndex);
133 | sb.append('"');
134 | return sb.toString();
135 | }
136 |
137 | public static StringBuilder quoteJson(StringBuilder sb, String s){
138 | return sb.append(quote(s));
139 | }
140 |
141 | public static final void trimEndComma(StringBuilder sb) {
142 | int l = sb.length();
143 | if (sb.charAt(l - 1) == ',') {
144 | sb.setLength(l - 1);
145 | }
146 | }
147 | public static final void trimEnd(StringBuilder sb) {
148 | int l = sb.length();
149 | sb.setLength(l - 1);
150 | }
151 |
152 | public static final void arrayToString(StringBuilder sb, String name, Object[] os) {
153 | sb.append(name).append(":");
154 | if (os == null) {
155 | sb.append(" null \n");
156 | return;
157 | }
158 | sb.append("[");
159 | for (int i=0;i')
200 | return ">";
201 | else if (i == '"')
202 | return """;
203 | else
204 | return "" + (char) i;
205 | }
206 |
207 | public final static void exec(String command, String dir, StringBuilder ret) {
208 | final String[] COMMAND_INTERPRETER = { "/bin/sh", "-c" };
209 | final long MAX_PROCESS_RUNNING_TIME = 30 * 1000; // 30 seconds
210 |
211 | String[] comm = new String[3];
212 | comm[0] = COMMAND_INTERPRETER[0];
213 | comm[1] = COMMAND_INTERPRETER[1];
214 | comm[2] = command;
215 | long start = System.currentTimeMillis();
216 | try {
217 | // Start process
218 | Process ls_proc = Runtime.getRuntime().exec(comm, null,
219 | new File(dir));
220 | // Get input and error streams
221 | BufferedInputStream ls_in = new BufferedInputStream(ls_proc
222 | .getInputStream());
223 | BufferedInputStream ls_err = new BufferedInputStream(ls_proc
224 | .getErrorStream());
225 | boolean end = false;
226 | while (!end) {
227 | int c = 0;
228 | while ((ls_err.available() > 0) && (++c <= 1000)) {
229 | ret.append(conv2Html(ls_err.read()));
230 | }
231 | c = 0;
232 | while ((ls_in.available() > 0) && (++c <= 1000)) {
233 | ret.append(conv2Html(ls_in.read()));
234 | }
235 | try {
236 | ls_proc.exitValue();
237 | // if the process has not finished, an exception is thrown
238 | // else
239 | while (ls_err.available() > 0)
240 | ret.append(conv2Html(ls_err.read()));
241 | while (ls_in.available() > 0)
242 | ret.append(conv2Html(ls_in.read()));
243 | end = true;
244 | } catch (IllegalThreadStateException ex) {
245 | // Process is running
246 | }
247 | // The process is not allowed to run longer than given time.
248 | if (System.currentTimeMillis() - start > MAX_PROCESS_RUNNING_TIME) {
249 | ls_proc.destroy();
250 | end = true;
251 | ret.append("!!!! Process has timed out, destroyed !!!!!");
252 | }
253 | try {
254 | Thread.sleep(50);
255 | } catch (InterruptedException ie) {
256 | }
257 | }
258 | } catch (IOException e) {
259 | ret.append("Error: " + e);
260 | }
261 |
262 | }
263 |
264 | public static String listToString(List> list){
265 | return list.toString().replace("[", "").replace("]", "").replace(" ","");
266 | }
267 | public static void main(String[] args) {
268 | String json = "{\"title\":\"hello,\"jim\",haha\"}";
269 | System.out.println(json);
270 | System.out.println(quote(json));
271 | }
272 |
273 | }
274 |
--------------------------------------------------------------------------------
/src/org/langke/testscript/common/TestConfig.java:
--------------------------------------------------------------------------------
1 | package org.langke.testscript.common;
2 | import java.io.File;
3 | import java.io.FileOutputStream;
4 | import java.io.IOException;
5 | import java.util.HashMap;
6 | import java.util.Map;
7 | import java.util.Properties;
8 |
9 | import org.slf4j.Logger;
10 | import org.slf4j.LoggerFactory;
11 |
12 | /**
13 | * 配置文件读取程序
14 | * 读取指定目录下配置文件,有守护线程每60秒检测如果文件被修改则重新加载配置
15 | * 如果有配置autoUpdate,勾子程序在进程结束时,判断如有修改过配置,则把配置全部刷到文件
16 | * @author langke
17 | * @since JDK1.6
18 | * @version 1.0
19 | *
20 | */
21 | public class TestConfig {
22 | public Properties properties = new Properties();
23 | private static Logger log = LoggerFactory.getLogger(TestConfig.class);
24 | private static Map configMap = new HashMap();
25 | private boolean modified = false;
26 | private final File cf;
27 | private long time;
28 |
29 | public static String getConfigDir() {
30 | String configDir = null;
31 | String userDir = System.getProperty("user.dir");
32 | if (System.getProperty("os.name").toLowerCase().contains("windows")) {
33 |
34 | configDir = userDir + "";
35 | } else {
36 |
37 | configDir = userDir + "";
38 | }
39 | return configDir;
40 | }
41 |
42 | public String getConfigPath() {
43 | return cf.getAbsolutePath();
44 | }
45 |
46 | private TestConfig(String confFilePath) {
47 | cf = new File(confFilePath);
48 | try {
49 | /*
50 | if (!cf.exists()) {
51 | cf.getParentFile().mkdirs();
52 | cf.createNewFile();
53 | }*/
54 | // 当进程关闭,如果properties有修改,则写入文件
55 | Runtime.getRuntime().addShutdownHook(new Thread("store-config") {
56 | public void run() {
57 | try {
58 | if (modified) {
59 | boolean autoUpdate = properties.containsKey("autoUpdate");
60 | if (autoUpdate) {
61 | FileOutputStream fos = new FileOutputStream(cf);
62 | properties.store(fos,
63 | "add an key to auto update config form default values");
64 | fos.close();
65 | }
66 | }
67 | } catch (Exception ex) {
68 | log.warn("store config", ex);
69 | }
70 | }
71 | });
72 | properties.load(new java.io.FileInputStream(cf));
73 | log.info("loading config from:" + cf.getAbsolutePath());
74 | time = cf.lastModified();
75 | // 检测配置文件是否被修改,自动reload
76 | Thread t = new Thread(new Runnable() {
77 | public void run() {
78 | try {
79 | Thread.sleep(60000);
80 | } catch (InterruptedException e) {
81 | }
82 | long newlmd = cf.lastModified();
83 | if (newlmd > time) {
84 | time = newlmd;
85 | log.info("Config file {} is modified,reloading ...",
86 | cf.getAbsolutePath());
87 | try {
88 | properties.load(new java.io.FileInputStream(cf));
89 | } catch (IOException e) {
90 | log.error("Error while loading config file:{}",
91 | cf.getAbsolutePath());
92 | }
93 | }
94 | }
95 | }, "Config file refresher");
96 | t.setDaemon(true);
97 | t.start();
98 | } catch (IOException ex) {
99 | log.warn("cannot create log file", ex);
100 | }
101 | }
102 |
103 | public static final TestConfig getInstance(String confFilePath) {
104 | if (!configMap.containsKey(confFilePath)) {
105 | TestConfig config = new TestConfig(confFilePath);
106 | configMap.put(confFilePath, config);
107 | }
108 | return configMap.get(confFilePath);
109 | }
110 |
111 | public String get(String key) {
112 | return properties.getProperty(key);
113 | }
114 |
115 | public String get(String k, String defaultValue) {
116 | String s = properties.getProperty(k);
117 | if (s == null ) {
118 | properties.setProperty(k, defaultValue);
119 | modified = true;
120 | return defaultValue;
121 | }else if( s.equals("")){
122 | properties.setProperty(k, defaultValue);
123 | return defaultValue;
124 | }
125 | return s;
126 | }
127 |
128 | public int getInt(String k, int defaultValue) {
129 | String s = this.get(k, defaultValue + "");
130 | try {
131 | return Integer.parseInt(s);
132 | } catch (Exception e) {
133 | return defaultValue;
134 | }
135 | }
136 |
137 | public boolean getBoolean(String k, boolean defaultValue) {
138 | String s = this.get(k, defaultValue + "");
139 | try {
140 | return Boolean.parseBoolean(s);
141 | } catch (Exception e) {
142 | return defaultValue;
143 | }
144 | }
145 |
146 | public boolean setProperty(String key, String value) {
147 | properties.setProperty(key, value);
148 | try {
149 | FileOutputStream fos = new java.io.FileOutputStream(cf);
150 | properties.store(fos, "");
151 | fos.close();
152 | return true;
153 | } catch (Exception ex) {
154 | log.warn("store config", ex);
155 | return false;
156 | }
157 | }
158 |
159 | }
160 |
--------------------------------------------------------------------------------
/src/org/langke/testscript/tag/Querywd.java:
--------------------------------------------------------------------------------
1 | package org.langke.testscript.tag;
2 |
3 | import java.io.File;
4 | import java.util.Random;
5 |
6 | import org.apache.commons.lang.RandomStringUtils;
7 | import org.langke.testscript.common.FileUtil;
8 |
9 | /**
10 | * 把标签替换为随机关键词
11 | * @author langke
12 | *
13 | */
14 | public class Querywd implements Tag{
15 |
16 | Random random = new Random(Integer.MAX_VALUE);//设置随机种子数
17 | private String querywdFilePath;
18 | public String getQuerywdFilePath() {
19 | return querywdFilePath;
20 | }
21 | public void setQuerywdFilePath(String querywdFilePath) {
22 | this.querywdFilePath = querywdFilePath;
23 | }
24 | private int randomLength = 10;
25 | public int getRandomLength() {
26 | return randomLength;
27 | }
28 | public void setRandomLength(int randomLength) {
29 | this.randomLength = randomLength;
30 | }
31 | public Object replaceTag(String str,String key) {
32 | String tag = "${"+key+".";
33 | String temp ;
34 | int min =0;
35 | int max = 0;
36 | String randomStr ;
37 | int randNumber ;
38 |
39 | FileUtil common = new FileUtil();
40 | File querywdFile = new File(querywdFilePath);
41 | String querywd[] = null;
42 | if(querywdFilePath!=null && querywdFile.exists())
43 | querywd = common.getFile(querywdFilePath).toString().split("\n");
44 | while(str.indexOf(tag)!=-1 ){
45 | temp = str.substring(str.indexOf(tag)+tag.length());
46 | temp = temp.substring(0,temp.indexOf('}'));
47 | if(temp.endsWith(".txt")){
48 | if(querywdFilePath.endsWith(".txt")){
49 | querywdFilePath = querywdFilePath.substring(0,querywdFilePath.lastIndexOf(File.separator)+1)+temp;
50 | }else{
51 | querywdFilePath +=temp;
52 | }
53 | if(querywdFilePath!=null && querywdFile.exists())
54 | querywd = common.getFile(querywdFilePath).toString().split("\n");
55 | }
56 |
57 | if(querywd!= null && querywd.length>0){
58 | max = querywd.length-1;
59 | min = 0;
60 | randNumber = random.nextInt(max - min + 1) + min;
61 | randomStr = querywd[randNumber];
62 | }else
63 | randomStr = RandomStringUtils.randomAlphanumeric(randomLength);//如果没有指定关键词文件,随机生成英文字母与数字组合
64 | str = str.replaceFirst("\\$\\{"+key+"."+temp+"}",randomStr);
65 | }
66 | return str;
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/src/org/langke/testscript/tag/RandInt.java:
--------------------------------------------------------------------------------
1 | package org.langke.testscript.tag;
2 |
3 | import java.util.Random;
4 |
5 | /**
6 | * 标签替换为随机数
7 | * 有设置随机种了
8 | * @author langke
9 | *
10 | */
11 | public class RandInt implements Tag{
12 | //设置随机种子数
13 | Random random = new Random(Integer.MAX_VALUE);
14 | public Object replaceTag(String str,String key) {
15 | String tag = "${"+key+".";
16 | String temp ;
17 | int min =0;
18 | int max = 0;
19 | //Random random = new Random();
20 | int randNumber ;
21 |
22 | temp = str.substring(str.indexOf(tag)+tag.length());
23 | temp = temp.substring(0,temp.indexOf('}'));
24 | min = Integer.valueOf(temp.substring(0, temp.indexOf("_")));
25 | max = Integer.valueOf(temp.substring(temp.indexOf("_")+1));
26 | // randNumber 将被赋值为一个 MIN 和 MAX 范围内的随机数
27 | randNumber = random.nextInt(max - min + 1) + min;
28 | str = str.replace(tag+temp+"}", String.valueOf(randNumber));
29 | return str;
30 | }
31 |
32 | public static void main(String args[]) throws Exception{
33 | for(int i=0;i<10;i++){
34 | RandInt tag = (RandInt) TagFactory.getTag("RANDINT");
35 | System.out.println(tag.random.nextInt(10-0+1)+0);
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/org/langke/testscript/tag/SeqInt.java:
--------------------------------------------------------------------------------
1 | package org.langke.testscript.tag;
2 |
3 | /**
4 | * 自增数
5 | * @author langke
6 | *
7 | */
8 | public class SeqInt implements Tag{
9 | public synchronized Object replaceTag(String str,String key) {
10 | String tag = "${"+key+".";
11 | String temp ;
12 | Integer seqint = null;
13 | String seqIntKey = System.getProperty("TESTSCRIPT.SEQINT.KEY");
14 | String sseqIntValue = System.getProperty(seqIntKey, null);
15 | if(null != sseqIntValue)
16 | seqint = Integer.valueOf(sseqIntValue);
17 | while(str.indexOf(tag)!=-1 ){
18 | temp = str.substring(str.indexOf(tag)+tag.length());
19 | temp = temp.substring(0,temp.indexOf('}'));
20 | if(temp.equals("")) temp = "0";
21 | if(seqint==null)
22 | seqint = Integer.valueOf(temp);
23 | str = str.replaceFirst("\\$\\{"+key+"."+temp+"}", String.valueOf(seqint));//$和{在replaceFirst,replaceAll作为正则表达式需要转义\\$\\{
24 | }
25 | //写在循环外表单个脚本里自增变量值相同
26 | seqint ++;
27 | System.setProperty(seqIntKey, String.valueOf(seqint));
28 | return str;
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/org/langke/testscript/tag/Tag.java:
--------------------------------------------------------------------------------
1 | package org.langke.testscript.tag;
2 |
3 | /**
4 | * 标签接口
5 | * 传入模板和标签,返回被替换后内容
6 | * @author langke
7 | *
8 | */
9 | public interface Tag {
10 | public Object replaceTag(String str,String key);
11 | }
12 |
--------------------------------------------------------------------------------
/src/org/langke/testscript/tag/TagFactory.java:
--------------------------------------------------------------------------------
1 | package org.langke.testscript.tag;
2 |
3 | import java.util.HashMap;
4 | import java.util.Map;
5 | /**
6 | * 标签定义
7 | * @author langke
8 | *
9 | */
10 | public class TagFactory {
11 | private static Map tagClasses = new HashMap();
12 | static {
13 | tagClasses.put("SEQINT",new SeqInt());
14 | tagClasses.put("RANDINT", new RandInt());
15 | tagClasses.put("QUERYWD", new Querywd());
16 | }
17 | public static Tag getTag(String tagName) throws InstantiationException,IllegalAccessException {
18 | return tagClasses.get(tagName);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/org/langke/util/logging/ESLogger.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to Elastic Search and Shay Banon under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. Elastic Search licenses this
6 | * file to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.langke.util.logging;
21 |
22 | /**
23 | * @author kimchy (shay.banon)
24 | */
25 | public interface ESLogger {
26 |
27 | String getPrefix();
28 |
29 | String getName();
30 |
31 | /**
32 | * Returns {@code true} if a TRACE level message is logged.
33 | */
34 | boolean isTraceEnabled();
35 |
36 | /**
37 | * Returns {@code true} if a DEBUG level message is logged.
38 | */
39 | boolean isDebugEnabled();
40 |
41 | /**
42 | * Returns {@code true} if an INFO level message is logged.
43 | */
44 | boolean isInfoEnabled();
45 |
46 | /**
47 | * Returns {@code true} if a WARN level message is logged.
48 | */
49 | boolean isWarnEnabled();
50 |
51 | /**
52 | * Returns {@code true} if an ERROR level message is logged.
53 | */
54 | boolean isErrorEnabled();
55 |
56 | /**
57 | * Logs a DEBUG level message.
58 | */
59 | void trace(String msg, Object... params);
60 |
61 | /**
62 | * Logs a DEBUG level message.
63 | */
64 | void trace(String msg, Throwable cause, Object... params);
65 |
66 | /**
67 | * Logs a DEBUG level message.
68 | */
69 | void debug(String msg, Object... params);
70 |
71 | /**
72 | * Logs a DEBUG level message.
73 | */
74 | void debug(String msg, Throwable cause, Object... params);
75 |
76 | /**
77 | * Logs an INFO level message.
78 | */
79 | void info(String msg, Object... params);
80 |
81 | /**
82 | * Logs an INFO level message.
83 | */
84 | void info(String msg, Throwable cause, Object... params);
85 |
86 | /**
87 | * Logs a WARN level message.
88 | */
89 | void warn(String msg, Object... params);
90 |
91 | /**
92 | * Logs a WARN level message.
93 | */
94 | void warn(String msg, Throwable cause, Object... params);
95 |
96 | /**
97 | * Logs an ERROR level message.
98 | */
99 | void error(String msg, Object... params);
100 |
101 | /**
102 | * Logs an ERROR level message.
103 | */
104 | void error(String msg, Throwable cause, Object... params);
105 |
106 | }
107 |
--------------------------------------------------------------------------------
/src/org/langke/util/logging/ESLoggerFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to Elastic Search and Shay Banon under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. Elastic Search licenses this
6 | * file to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.langke.util.logging;
21 |
22 | //import com.woyo.search.util.logging.log4j.Log4jESLoggerFactory;
23 |
24 | import java.io.File;
25 |
26 | import org.apache.log4j.PropertyConfigurator;
27 | import org.langke.util.logging.jdk.JdkESLoggerFactory;
28 | import org.langke.util.logging.log4j.Log4jESLoggerFactory;
29 |
30 | /**
31 | * @author kimchy (shay.banon)
32 | */
33 | public abstract class ESLoggerFactory {
34 |
35 | private static volatile ESLoggerFactory defaultFactory = new JdkESLoggerFactory();
36 |
37 | static {
38 | // try {
39 | // Class.forName("org.slf4j.Logger");
40 | // defaultFactory = new Slf4jESLoggerFactory();
41 | // } catch (Throwable e) {
42 | // throw new RuntimeException(e);
43 | // no slf4j
44 | try {
45 | Class.forName("org.apache.log4j.Logger");
46 | File f = new File("../conf/log4j.properties");
47 | if (!f.exists()) {
48 | System.out.println("Cannot find log config file:"
49 | + f.getAbsolutePath());
50 | }
51 | PropertyConfigurator.configureAndWatch(f.getAbsolutePath());
52 | defaultFactory = new Log4jESLoggerFactory();
53 |
54 | } catch (Throwable e1) {
55 | // no log4j
56 | }
57 | // }
58 | }
59 |
60 | /**
61 | * Changes the default factory.
62 | */
63 | public static void setDefaultFactory(ESLoggerFactory defaultFactory) {
64 | if (defaultFactory == null) {
65 | throw new NullPointerException("defaultFactory");
66 | }
67 | ESLoggerFactory.defaultFactory = defaultFactory;
68 | }
69 |
70 | public static ESLogger getLogger(String prefix, String name) {
71 | return defaultFactory.newInstance(prefix, name);
72 | }
73 |
74 | public static ESLogger getLogger(String name) {
75 | return defaultFactory.newInstance(name);
76 | }
77 |
78 | public ESLogger newInstance(String name) {
79 | return newInstance(null, name);
80 | }
81 |
82 | public abstract ESLogger newInstance(String prefix, String name);
83 | }
84 |
--------------------------------------------------------------------------------
/src/org/langke/util/logging/Loggers.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to Elastic Search and Shay Banon under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. Elastic Search licenses this
6 | * file to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.langke.util.logging;
21 |
22 |
23 | /**
24 | * A set of utilities around Logging.
25 | *
26 | * @author kimchy (shay.banon)
27 | */
28 | public class Loggers {
29 |
30 | private static boolean consoleLoggingEnabled = true;
31 |
32 | public static void disableConsoleLogging() {
33 | consoleLoggingEnabled = false;
34 | }
35 |
36 | public static void enableConsoleLogging() {
37 | consoleLoggingEnabled = true;
38 | }
39 |
40 | public static boolean consoleLoggingEnabled() {
41 | return consoleLoggingEnabled;
42 | }
43 |
44 | public static ESLogger getLogger(ESLogger parentLogger, String s) {
45 | return getLogger(parentLogger.getName() + s, parentLogger.getPrefix());
46 | }
47 |
48 | public static ESLogger getLogger(String s) {
49 | return ESLoggerFactory.getLogger(s);
50 | }
51 |
52 | public static ESLogger getLogger(Class> clazz) {
53 | return ESLoggerFactory.getLogger(getLoggerName(clazz));
54 | }
55 |
56 | public static ESLogger getLogger(Class> clazz, String... prefixes) {
57 | return getLogger(getLoggerName(clazz), prefixes);
58 | }
59 |
60 | public static ESLogger getLogger(String name, String... prefixes) {
61 | String prefix = null;
62 | if (prefixes != null && prefixes.length > 0) {
63 | StringBuilder sb = new StringBuilder();
64 | for (String prefixX : prefixes) {
65 | if (prefixX != null) {
66 | sb.append("[").append(prefixX).append("]");
67 | }
68 | }
69 | if (sb.length() > 0) {
70 | sb.append(" ");
71 | prefix = sb.toString();
72 | }
73 | }
74 | return ESLoggerFactory.getLogger(prefix, getLoggerName(name));
75 | }
76 |
77 | private static String getLoggerName(Class> clazz) {
78 | String name = clazz.getName();
79 | // if (name.startsWith("org.elasticsearch.")) {
80 | // name = Classes.getPackageName(clazz);
81 | // }
82 | return getLoggerName(name);
83 | }
84 |
85 | private static String getLoggerName(String name) {
86 | if (name.startsWith("org.elasticsearch.")) {
87 | return name.substring("org.elasticsearch.".length());
88 | }
89 | return name;
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/src/org/langke/util/logging/jdk/JdkESLogger.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to Elastic Search and Shay Banon under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. Elastic Search licenses this
6 | * file to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.langke.util.logging.jdk;
21 |
22 |
23 | import java.util.logging.Level;
24 | import java.util.logging.Logger;
25 |
26 | import org.langke.util.logging.support.AbstractESLogger;
27 |
28 | /**
29 | * @author kimchy (shay.banon)
30 | */
31 | public class JdkESLogger extends AbstractESLogger {
32 |
33 | private final Logger logger;
34 |
35 | public JdkESLogger(String prefix, Logger logger) {
36 | super(prefix);
37 | this.logger = logger;
38 | }
39 |
40 | public String getName() {
41 | return logger.getName();
42 | }
43 |
44 | public boolean isTraceEnabled() {
45 | return logger.isLoggable(Level.FINEST);
46 | }
47 |
48 | public boolean isDebugEnabled() {
49 | return logger.isLoggable(Level.FINE);
50 | }
51 |
52 | public boolean isInfoEnabled() {
53 | return logger.isLoggable(Level.INFO);
54 | }
55 |
56 | public boolean isWarnEnabled() {
57 | return logger.isLoggable(Level.WARNING);
58 | }
59 |
60 | public boolean isErrorEnabled() {
61 | return logger.isLoggable(Level.SEVERE);
62 | }
63 |
64 | protected void internalTrace(String msg) {
65 | logger.log(Level.FINEST, msg);
66 | }
67 |
68 | protected void internalTrace(String msg, Throwable cause) {
69 | logger.log(Level.FINEST, msg, cause);
70 | }
71 |
72 | protected void internalDebug(String msg) {
73 | logger.log(Level.FINE, msg);
74 | }
75 |
76 | protected void internalDebug(String msg, Throwable cause) {
77 | logger.log(Level.FINE, msg, cause);
78 | }
79 |
80 | protected void internalInfo(String msg) {
81 | logger.log(Level.INFO, msg);
82 | }
83 |
84 | protected void internalInfo(String msg, Throwable cause) {
85 | logger.log(Level.INFO, msg, cause);
86 | }
87 |
88 | protected void internalWarn(String msg) {
89 | logger.log(Level.WARNING, msg);
90 | }
91 |
92 | protected void internalWarn(String msg, Throwable cause) {
93 | logger.log(Level.WARNING, msg, cause);
94 | }
95 |
96 | protected void internalError(String msg) {
97 | logger.log(Level.SEVERE, msg);
98 | }
99 |
100 | protected void internalError(String msg, Throwable cause) {
101 | logger.log(Level.SEVERE, msg, cause);
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/src/org/langke/util/logging/jdk/JdkESLoggerFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to Elastic Search and Shay Banon under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. Elastic Search licenses this
6 | * file to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.langke.util.logging.jdk;
21 |
22 | import org.langke.util.logging.ESLogger;
23 | import org.langke.util.logging.ESLoggerFactory;
24 |
25 | /**
26 | * @author kimchy (shay.banon)
27 | */
28 | public class JdkESLoggerFactory extends ESLoggerFactory {
29 |
30 | public ESLogger newInstance(String prefix, String name) {
31 | final java.util.logging.Logger logger = java.util.logging.Logger
32 | .getLogger(name);
33 | return new JdkESLogger(prefix, logger);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/org/langke/util/logging/log4j/ConsoleAppender.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to Elastic Search and Shay Banon under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. Elastic Search licenses this
6 | * file to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.langke.util.logging.log4j;
21 |
22 | import org.apache.log4j.Layout;
23 | import org.apache.log4j.WriterAppender;
24 | import org.apache.log4j.helpers.LogLog;
25 | import org.langke.util.logging.Loggers;
26 |
27 |
28 | import java.io.IOException;
29 | import java.io.OutputStream;
30 |
31 | /**
32 | * ConsoleAppender appends log events to System.out
or
33 | * System.err
using a layout specified by the user. The default
34 | * target is System.out
.
35 | *
36 | *
37 | * ElasticSearch: Adapter from log4j to allow to disable console logging...
38 | *
39 | *
40 | * @author Ceki Gülcü
41 | * @author Curt Arnold
42 | * @since 1.1
43 | */
44 | public class ConsoleAppender extends WriterAppender {
45 |
46 | public static final String SYSTEM_OUT = "System.out";
47 | public static final String SYSTEM_ERR = "System.err";
48 |
49 | protected String target = SYSTEM_OUT;
50 |
51 | /**
52 | * Determines if the appender honors reassignments of System.out or
53 | * System.err made after configuration.
54 | */
55 | private boolean follow = true;
56 |
57 | /**
58 | * Constructs an unconfigured appender.
59 | */
60 | public ConsoleAppender() {
61 | }
62 |
63 | /**
64 | * Creates a configured appender.
65 | *
66 | * @param layout
67 | * layout, may not be null.
68 | */
69 | public ConsoleAppender(Layout layout) {
70 | this(layout, SYSTEM_OUT);
71 | }
72 |
73 | /**
74 | * Creates a configured appender.
75 | *
76 | * @param layout
77 | * layout, may not be null.
78 | * @param target
79 | * target, either "System.err" or "System.out".
80 | */
81 | public ConsoleAppender(Layout layout, String target) {
82 | setLayout(layout);
83 | setTarget(target);
84 | activateOptions();
85 | }
86 |
87 | /**
88 | * Sets the value of the Target option. Recognized values are
89 | * "System.out" and "System.err". Any other value will be ignored.
90 | */
91 | public void setTarget(String value) {
92 | String v = value.trim();
93 |
94 | if (SYSTEM_OUT.equalsIgnoreCase(v)) {
95 | target = SYSTEM_OUT;
96 | } else if (SYSTEM_ERR.equalsIgnoreCase(v)) {
97 | target = SYSTEM_ERR;
98 | } else {
99 | targetWarn(value);
100 | }
101 | }
102 |
103 | /**
104 | * Returns the current value of the Target property. The default
105 | * value of the option is "System.out".
106 | *
107 | * See also {@link #setTarget}.
108 | */
109 | public String getTarget() {
110 | return target;
111 | }
112 |
113 | /**
114 | * Sets whether the appender honors reassignments of System.out or
115 | * System.err made after configuration.
116 | *
117 | * @param newValue
118 | * if true, appender will use value of System.out or System.err
119 | * in force at the time when logging events are appended.
120 | * @since 1.2.13
121 | */
122 | public final void setFollow(final boolean newValue) {
123 | follow = newValue;
124 | }
125 |
126 | /**
127 | * Gets whether the appender honors reassignments of System.out or
128 | * System.err made after configuration.
129 | *
130 | * @return true if appender will use value of System.out or System.err in
131 | * force at the time when logging events are appended.
132 | * @since 1.2.13
133 | */
134 | public final boolean getFollow() {
135 | return follow;
136 | }
137 |
138 | void targetWarn(String val) {
139 | LogLog.warn("[" + val + "] should be System.out or System.err.");
140 | LogLog.warn("Using previously set target, System.out by default.");
141 | }
142 |
143 | /**
144 | * Prepares the appender for use.
145 | */
146 | public void activateOptions() {
147 | if (follow) {
148 | if (target.equals(SYSTEM_ERR)) {
149 | setWriter(createWriter(new SystemErrStream()));
150 | } else {
151 | setWriter(createWriter(new SystemOutStream()));
152 | }
153 | } else {
154 | if (target.equals(SYSTEM_ERR)) {
155 | setWriter(createWriter(System.err));
156 | } else {
157 | setWriter(createWriter(System.out));
158 | }
159 | }
160 |
161 | super.activateOptions();
162 | }
163 |
164 | /**
165 | * {@inheritDoc}
166 | */
167 | protected final void closeWriter() {
168 | if (follow) {
169 | super.closeWriter();
170 | }
171 | }
172 |
173 | /**
174 | * An implementation of OutputStream that redirects to the current
175 | * System.err.
176 | */
177 | private static class SystemErrStream extends OutputStream {
178 | public SystemErrStream() {
179 | }
180 |
181 | public void close() {
182 | }
183 |
184 | public void flush() {
185 | System.err.flush();
186 | }
187 |
188 | public void write(final byte[] b) throws IOException {
189 | if (!Loggers.consoleLoggingEnabled()) {
190 | return;
191 | }
192 | System.err.write(b);
193 | }
194 |
195 | public void write(final byte[] b, final int off, final int len)
196 | throws IOException {
197 | if (!Loggers.consoleLoggingEnabled()) {
198 | return;
199 | }
200 | System.err.write(b, off, len);
201 | }
202 |
203 | public void write(final int b) throws IOException {
204 | if (!Loggers.consoleLoggingEnabled()) {
205 | return;
206 | }
207 | System.err.write(b);
208 | }
209 | }
210 |
211 | /**
212 | * An implementation of OutputStream that redirects to the current
213 | * System.out.
214 | */
215 | private static class SystemOutStream extends OutputStream {
216 | public SystemOutStream() {
217 | }
218 |
219 | public void close() {
220 | }
221 |
222 | public void flush() {
223 | System.out.flush();
224 | }
225 |
226 | public void write(final byte[] b) throws IOException {
227 | if (!Loggers.consoleLoggingEnabled()) {
228 | return;
229 | }
230 | System.out.write(b);
231 | }
232 |
233 | public void write(final byte[] b, final int off, final int len)
234 | throws IOException {
235 | if (!Loggers.consoleLoggingEnabled()) {
236 | return;
237 | }
238 | System.out.write(b, off, len);
239 | }
240 |
241 | public void write(final int b) throws IOException {
242 | if (!Loggers.consoleLoggingEnabled()) {
243 | return;
244 | }
245 | System.out.write(b);
246 | }
247 | }
248 |
249 | }
250 |
--------------------------------------------------------------------------------
/src/org/langke/util/logging/log4j/JLinePatternLayout.java:
--------------------------------------------------------------------------------
1 | package org.langke.util.logging.log4j;
2 | ///*
3 | // * Licensed to Elastic Search and Shay Banon under one
4 | // * or more contributor license agreements. See the NOTICE file
5 | // * distributed with this work for additional information
6 | // * regarding copyright ownership. Elastic Search licenses this
7 | // * file to you under the Apache License, Version 2.0 (the
8 | // * "License"); you may not use this file except in compliance
9 | // * with the License. You may obtain a copy of the License at
10 | // *
11 | // * http://www.apache.org/licenses/LICENSE-2.0
12 | // *
13 | // * Unless required by applicable law or agreed to in writing,
14 | // * software distributed under the License is distributed on an
15 | // * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | // * KIND, either express or implied. See the License for the
17 | // * specific language governing permissions and limitations
18 | // * under the License.
19 | // */
20 | //
21 | //package com.woyo.search.util.logging.log4j;
22 | //
23 | //import org.apache.log4j.Level;
24 | //import org.apache.log4j.PatternLayout;
25 | //import org.apache.log4j.helpers.FormattingInfo;
26 | //import org.apache.log4j.helpers.PatternConverter;
27 | //import org.apache.log4j.helpers.PatternParser;
28 | //import org.apache.log4j.spi.LoggingEvent;
29 | //import org.elasticsearch.util.jline.ANSI;
30 | //
31 | //import java.lang.reflect.Field;
32 | //
33 | //import static jline.ANSIBuffer.ANSICodes.*;
34 | //import static org.elasticsearch.util.jline.ANSI.Code.FG_BLUE;
35 | //import static org.elasticsearch.util.jline.ANSI.Code.FG_CYAN;
36 | //import static org.elasticsearch.util.jline.ANSI.Code.FG_GREEN;
37 | //import static org.elasticsearch.util.jline.ANSI.Code.FG_RED;
38 | //import static org.elasticsearch.util.jline.ANSI.Code.FG_YELLOW;
39 | //import static org.elasticsearch.util.jline.ANSI.Code.OFF;
40 | //
41 | ///**
42 | // * @author kimchy (Shay Banon)
43 | // */
44 | //public class JLinePatternLayout extends PatternLayout {
45 | //
46 | // @Override protected PatternParser createPatternParser(String pattern) {
47 | // try {
48 | // return new JLinePatternParser(pattern);
49 | // } catch (Throwable t) {
50 | // return super.createPatternParser(pattern);
51 | // }
52 | // }
53 | //
54 | // private final static class JLinePatternParser extends PatternParser {
55 | //
56 | // private JLinePatternParser(String pattern) {
57 | // super(pattern);
58 | // }
59 | //
60 | // @Override protected void addConverter(PatternConverter pc) {
61 | // try {
62 | // if (ANSI.isEnabled()) {
63 | // if (pc.getClass().getName().endsWith("BasicPatternConverter")) {
64 | // Field typeField = pc.getClass().getDeclaredField("type");
65 | // typeField.setAccessible(true);
66 | // Integer type = (Integer) typeField.get(pc);
67 | // if (type == 2002) {
68 | // pc = new ColoredLevelPatternConverter(formattingInfo);
69 | // }
70 | // }
71 | // }
72 | // } catch (Throwable t) {
73 | // // ignore
74 | // }
75 | // super.addConverter(pc);
76 | // }
77 | //
78 | // private static class ColoredLevelPatternConverter extends PatternConverter {
79 | //
80 | // ColoredLevelPatternConverter(FormattingInfo formattingInfo) {
81 | // super(formattingInfo);
82 | // }
83 | //
84 | // public String convert(LoggingEvent event) {
85 | // if (!ANSI.isEnabled()) {
86 | // return event.getLevel().toString();
87 | // }
88 | // if (event.getLevel() == Level.FATAL) {
89 | // return attrib(FG_RED) + event.getLevel().toString() + attrib(OFF);
90 | // } else if (event.getLevel() == Level.ERROR) {
91 | // return attrib(FG_RED) + event.getLevel().toString() + attrib(OFF);
92 | // } else if (event.getLevel() == Level.WARN) {
93 | // return attrib(FG_YELLOW) + event.getLevel().toString() + ' ' + attrib(OFF);
94 | // } else if (event.getLevel() == Level.INFO) {
95 | // return attrib(FG_GREEN) + event.getLevel().toString() + ' ' + attrib(OFF);
96 | // } else if (event.getLevel() == Level.DEBUG) {
97 | // return attrib(FG_CYAN) + event.getLevel().toString() + attrib(OFF);
98 | // } else if (event.getLevel() == Level.TRACE) {
99 | // return attrib(FG_BLUE) + event.getLevel().toString() + attrib(OFF);
100 | // }
101 | // return event.getLevel().toString();
102 | // }
103 | // }
104 | // }
105 | // }
106 |
--------------------------------------------------------------------------------
/src/org/langke/util/logging/log4j/Log4jESLogger.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to Elastic Search and Shay Banon under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. Elastic Search licenses this
6 | * file to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.langke.util.logging.log4j;
21 |
22 | import org.apache.log4j.Level;
23 | import org.apache.log4j.Logger;
24 | import org.langke.util.logging.support.AbstractESLogger;
25 |
26 | /**
27 | * @author kimchy (shay.banon)
28 | */
29 | public class Log4jESLogger extends AbstractESLogger {
30 |
31 | private final org.apache.log4j.Logger logger;
32 |
33 | public Log4jESLogger(String prefix, Logger logger) {
34 | super(prefix);
35 | this.logger = logger;
36 |
37 | }
38 |
39 | public String getName() {
40 | return logger.getName();
41 | }
42 |
43 | public boolean isTraceEnabled() {
44 | return logger.isTraceEnabled();
45 | }
46 |
47 | public boolean isDebugEnabled() {
48 | return logger.isDebugEnabled();
49 | }
50 |
51 | public boolean isInfoEnabled() {
52 | return logger.isInfoEnabled();
53 | }
54 |
55 | public boolean isWarnEnabled() {
56 | return logger.isEnabledFor(Level.WARN);
57 | }
58 |
59 | public boolean isErrorEnabled() {
60 | return logger.isEnabledFor(Level.ERROR);
61 | }
62 |
63 | protected void internalTrace(String msg) {
64 | logger.trace(msg);
65 | }
66 |
67 | protected void internalTrace(String msg, Throwable cause) {
68 | logger.trace(msg, cause);
69 | }
70 |
71 | protected void internalDebug(String msg) {
72 | logger.debug(msg);
73 | }
74 |
75 | protected void internalDebug(String msg, Throwable cause) {
76 | logger.debug(msg, cause);
77 | }
78 |
79 | protected void internalInfo(String msg) {
80 | logger.info(msg);
81 | }
82 |
83 | protected void internalInfo(String msg, Throwable cause) {
84 | logger.info(msg, cause);
85 | }
86 |
87 | protected void internalWarn(String msg) {
88 | logger.warn(msg);
89 | }
90 |
91 | protected void internalWarn(String msg, Throwable cause) {
92 | logger.warn(msg, cause);
93 | }
94 |
95 | protected void internalError(String msg) {
96 | logger.error(msg);
97 | }
98 |
99 | protected void internalError(String msg, Throwable cause) {
100 | logger.error(msg, cause);
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/src/org/langke/util/logging/log4j/Log4jESLoggerFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to Elastic Search and Shay Banon under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. Elastic Search licenses this
6 | * file to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.langke.util.logging.log4j;
21 |
22 | import org.langke.util.logging.ESLogger;
23 | import org.langke.util.logging.ESLoggerFactory;
24 |
25 | /**
26 | * @author kimchy (shay.banon)
27 | */
28 | public class Log4jESLoggerFactory extends ESLoggerFactory {
29 |
30 | @Override
31 | public ESLogger newInstance(String prefix, String name) {
32 | final org.apache.log4j.Logger logger = org.apache.log4j.Logger
33 | .getLogger(name);
34 | return new Log4jESLogger(prefix, logger);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/org/langke/util/logging/log4j/LogConfigurator.java:
--------------------------------------------------------------------------------
1 | package org.langke.util.logging.log4j;
2 | ///*
3 | // * Licensed to Elastic Search and Shay Banon under one
4 | // * or more contributor license agreements. See the NOTICE file
5 | // * distributed with this work for additional information
6 | // * regarding copyright ownership. Elastic Search licenses this
7 | // * file to you under the Apache License, Version 2.0 (the
8 | // * "License"); you may not use this file except in compliance
9 | // * with the License. You may obtain a copy of the License at
10 | // *
11 | // * http://www.apache.org/licenses/LICENSE-2.0
12 | // *
13 | // * Unless required by applicable law or agreed to in writing,
14 | // * software distributed under the License is distributed on an
15 | // * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | // * KIND, either express or implied. See the License for the
17 | // * specific language governing permissions and limitations
18 | // * under the License.
19 | // */
20 | //
21 | //package com.woyo.search.util.logging.log4j;
22 | //
23 | //import org.apache.log4j.PropertyConfigurator;
24 | //
25 | //
26 | //import java.util.Map;
27 | //import java.util.Properties;
28 | //
29 | //import static org.elasticsearch.util.settings.ImmutableSettings.*;
30 | //
31 | ///**
32 | // * @author kimchy (Shay Banon)
33 | // */
34 | //public class LogConfigurator {
35 | //
36 | // private static boolean loaded;
37 | //
38 | // private static ImmutableMap replacements = new MapBuilder()
39 | // .put("console", "org.elasticsearch.util.logging.log4j.ConsoleAppender")
40 | // .put("async", "org.apache.log4j.AsyncAppender")
41 | // .put("dailyRollingFile", "org.apache.log4j.DailyRollingFileAppender")
42 | // .put("externallyRolledFile", "org.apache.log4j.ExternallyRolledFileAppender")
43 | // .put("file", "org.apache.log4j.FileAppender")
44 | // .put("jdbc", "org.apache.log4j.JDBCAppender")
45 | // .put("jms", "org.apache.log4j.JMSAppender")
46 | // .put("lf5", "org.apache.log4j.LF5Appender")
47 | // .put("ntevent", "org.apache.log4j.NTEventLogAppender")
48 | // .put("null", "org.apache.log4j.NullAppender")
49 | // .put("rollingFile", "org.apache.log4j.RollingFileAppender")
50 | // .put("smtp", "org.apache.log4j.SMTPAppender")
51 | // .put("socket", "org.apache.log4j.SocketAppender")
52 | // .put("socketHub", "org.apache.log4j.SocketHubAppender")
53 | // .put("syslog", "org.apache.log4j.SyslogAppender")
54 | // .put("telnet", "org.apache.log4j.TelnetAppender")
55 | // // layouts
56 | // .put("simple", "org.apache.log4j.SimpleLayout")
57 | // .put("html", "org.apache.log4j.HTMLLayout")
58 | // .put("pattern", "org.apache.log4j.PatternLayout")
59 | // // .put("consolePattern", "org.elasticsearch.util.logging.log4j.JLinePatternLayout")
60 | // .put("ttcc", "org.apache.log4j.TTCCLayout")
61 | // .put("xml", "org.apache.log4j.XMLLayout")
62 | // .immutableMap();
63 | //
64 | // public static void configure(Settings settings) {
65 | // if (loaded) {
66 | // return;
67 | // }
68 | // loaded = true;
69 | // Environment environment = new Environment(settings);
70 | // ImmutableSettings.Builder settingsBuilder = settingsBuilder().put(settings);
71 | // try {
72 | // settingsBuilder.loadFromUrl(environment.resolveConfig("logging.yml"));
73 | // } catch (FailedToResolveConfigException e) {
74 | // // ignore
75 | // } catch (NoClassDefFoundError e) {
76 | // // ignore, no yaml
77 | // }
78 | // try {
79 | // settingsBuilder.loadFromUrl(environment.resolveConfig("logging.json"));
80 | // } catch (FailedToResolveConfigException e) {
81 | // // ignore
82 | // }
83 | // try {
84 | // settingsBuilder.loadFromUrl(environment.resolveConfig("logging.properties"));
85 | // } catch (FailedToResolveConfigException e) {
86 | // // ignore
87 | // }
88 | // settingsBuilder
89 | // .putProperties("elasticsearch.", System.getProperties())
90 | // .putProperties("es.", System.getProperties())
91 | // .replacePropertyPlaceholders();
92 | // Properties props = new Properties();
93 | // for (Map.Entry entry : settingsBuilder.build().getAsMap().entrySet()) {
94 | // String key = "log4j." + entry.getKey();
95 | // String value = entry.getValue();
96 | // if (replacements.containsKey(value)) {
97 | // value = replacements.get(value);
98 | // }
99 | // if (key.endsWith(".value")) {
100 | // props.setProperty(key.substring(0, key.length() - ".value".length()), value);
101 | // } else if (key.endsWith(".type")) {
102 | // props.setProperty(key.substring(0, key.length() - ".type".length()), value);
103 | // } else {
104 | // props.setProperty(key, value);
105 | // }
106 | // }
107 | // PropertyConfigurator.configure(props);
108 | // }
109 | // }
110 |
--------------------------------------------------------------------------------
/src/org/langke/util/logging/slf4j/Slf4jESLogger.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to Elastic Search and Shay Banon under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. Elastic Search licenses this
6 | * file to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.langke.util.logging.slf4j;
21 |
22 |
23 | import org.langke.util.logging.support.AbstractESLogger;
24 | import org.slf4j.Logger;
25 |
26 | /**
27 | * @author kimchy (shay.banon)
28 | */
29 | public class Slf4jESLogger extends AbstractESLogger {
30 |
31 | private final Logger logger;
32 |
33 | public Slf4jESLogger(String prefix, Logger logger) {
34 | super(prefix);
35 | this.logger = logger;
36 | }
37 |
38 | public String getName() {
39 | return logger.getName();
40 | }
41 |
42 | public boolean isTraceEnabled() {
43 | return logger.isTraceEnabled();
44 | }
45 |
46 | public boolean isDebugEnabled() {
47 | return logger.isDebugEnabled();
48 | }
49 |
50 | public boolean isInfoEnabled() {
51 | return logger.isInfoEnabled();
52 | }
53 |
54 | public boolean isWarnEnabled() {
55 | return logger.isWarnEnabled();
56 | }
57 |
58 | public boolean isErrorEnabled() {
59 | return logger.isErrorEnabled();
60 | }
61 |
62 | protected void internalTrace(String msg) {
63 | logger.trace(msg);
64 | }
65 |
66 | protected void internalTrace(String msg, Throwable cause) {
67 | logger.trace(msg, cause);
68 | }
69 |
70 | protected void internalDebug(String msg) {
71 | logger.debug(msg);
72 | }
73 |
74 | protected void internalDebug(String msg, Throwable cause) {
75 | logger.debug(msg, cause);
76 | }
77 |
78 | protected void internalInfo(String msg) {
79 | logger.info(msg);
80 | }
81 |
82 | protected void internalInfo(String msg, Throwable cause) {
83 | logger.info(msg, cause);
84 | }
85 |
86 | protected void internalWarn(String msg) {
87 | logger.warn(msg);
88 | }
89 |
90 | protected void internalWarn(String msg, Throwable cause) {
91 | logger.warn(msg, cause);
92 | }
93 |
94 | protected void internalError(String msg) {
95 | logger.error(msg);
96 | }
97 |
98 | protected void internalError(String msg, Throwable cause) {
99 | logger.error(msg, cause);
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/src/org/langke/util/logging/slf4j/Slf4jESLoggerFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to Elastic Search and Shay Banon under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. Elastic Search licenses this
6 | * file to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.langke.util.logging.slf4j;
21 |
22 |
23 | import org.langke.util.logging.ESLogger;
24 | import org.langke.util.logging.ESLoggerFactory;
25 | import org.slf4j.LoggerFactory;
26 |
27 | /**
28 | * @author kimchy (shay.banon)
29 | */
30 | public class Slf4jESLoggerFactory extends ESLoggerFactory {
31 |
32 | @Override
33 | public ESLogger newInstance(String prefix, String name) {
34 | return new Slf4jESLogger(prefix, LoggerFactory.getLogger(name));
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/org/langke/util/logging/support/AbstractESLogger.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to Elastic Search and Shay Banon under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. Elastic Search licenses this
6 | * file to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.langke.util.logging.support;
21 |
22 | import org.langke.util.logging.ESLogger;
23 |
24 | /**
25 | * @author kimchy (shay.banon)
26 | */
27 | public abstract class AbstractESLogger implements ESLogger {
28 |
29 | private final String prefix;
30 |
31 | protected AbstractESLogger(String prefix) {
32 | this.prefix = prefix;
33 | }
34 |
35 | public String getPrefix() {
36 | return this.prefix;
37 | }
38 |
39 | public void trace(String msg, Object... params) {
40 | if (isTraceEnabled()) {
41 | internalTrace(LoggerMessageFormat.format(prefix, msg, params));
42 | }
43 | }
44 |
45 | protected abstract void internalTrace(String msg);
46 |
47 | public void trace(String msg, Throwable cause, Object... params) {
48 | if (isTraceEnabled()) {
49 | internalTrace(LoggerMessageFormat.format(prefix, msg, params),
50 | cause);
51 | }
52 | }
53 |
54 | protected abstract void internalTrace(String msg, Throwable cause);
55 |
56 | public void debug(String msg, Object... params) {
57 | if (isDebugEnabled()) {
58 | internalDebug(LoggerMessageFormat.format(prefix, msg, params));
59 | }
60 | }
61 |
62 | protected abstract void internalDebug(String msg);
63 |
64 | public void debug(String msg, Throwable cause, Object... params) {
65 | if (isDebugEnabled()) {
66 | internalDebug(LoggerMessageFormat.format(prefix, msg, params),
67 | cause);
68 | }
69 | }
70 |
71 | protected abstract void internalDebug(String msg, Throwable cause);
72 |
73 | public void info(String msg, Object... params) {
74 | if (isInfoEnabled()) {
75 | internalInfo(LoggerMessageFormat.format(prefix, msg, params));
76 | }
77 | }
78 |
79 | protected abstract void internalInfo(String msg);
80 |
81 | public void info(String msg, Throwable cause, Object... params) {
82 | if (isInfoEnabled()) {
83 | internalInfo(LoggerMessageFormat.format(prefix, msg, params), cause);
84 | }
85 | }
86 |
87 | protected abstract void internalInfo(String msg, Throwable cause);
88 |
89 | public void warn(String msg, Object... params) {
90 | if (isWarnEnabled()) {
91 | internalWarn(LoggerMessageFormat.format(prefix, msg, params));
92 | }
93 | }
94 |
95 | protected abstract void internalWarn(String msg);
96 |
97 | public void warn(String msg, Throwable cause, Object... params) {
98 | if (isWarnEnabled()) {
99 | internalWarn(LoggerMessageFormat.format(prefix, msg, params), cause);
100 | }
101 | }
102 |
103 | protected abstract void internalWarn(String msg, Throwable cause);
104 |
105 | public void error(String msg, Object... params) {
106 | if (isErrorEnabled()) {
107 | internalError(LoggerMessageFormat.format(prefix, msg, params));
108 | }
109 | }
110 |
111 | protected abstract void internalError(String msg);
112 |
113 | public void error(String msg, Throwable cause, Object... params) {
114 | if (isErrorEnabled()) {
115 | internalError(LoggerMessageFormat.format(prefix, msg, params),
116 | cause);
117 | }
118 | }
119 |
120 | protected abstract void internalError(String msg, Throwable cause);
121 | }
122 |
--------------------------------------------------------------------------------
/src/org/langke/util/logging/support/LoggerMessageFormat.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to Elastic Search and Shay Banon under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. Elastic Search licenses this
6 | * file to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | package org.langke.util.logging.support;
21 |
22 | import java.util.HashMap;
23 | import java.util.Map;
24 |
25 | /**
26 | * @author kimchy (shay.banon)
27 | */
28 | public class LoggerMessageFormat {
29 |
30 | static final char DELIM_START = '{';
31 | static final char DELIM_STOP = '}';
32 | static final String DELIM_STR = "{}";
33 | private static final char ESCAPE_CHAR = '\\';
34 |
35 | public static String format(final String messagePattern,
36 | final Object... argArray) {
37 | return format(null, messagePattern, argArray);
38 | }
39 |
40 | @SuppressWarnings("rawtypes")
41 | public static String format(final String prefix,
42 | final String messagePattern, final Object... argArray) {
43 | if (messagePattern == null) {
44 | return null;
45 | }
46 | if (argArray == null) {
47 | if (prefix == null) {
48 | return messagePattern;
49 | } else {
50 | return prefix + messagePattern;
51 | }
52 | }
53 | int i = 0;
54 | int j;
55 | StringBuffer sbuf = new StringBuffer(messagePattern.length() + 50);
56 | if (prefix != null) {
57 | sbuf.append(prefix);
58 | }
59 |
60 | for (int L = 0; L < argArray.length; L++) {
61 |
62 | j = messagePattern.indexOf(DELIM_STR, i);
63 |
64 | if (j == -1) {
65 | // no more variables
66 | if (i == 0) { // this is a simple string
67 | return messagePattern;
68 | } else { // add the tail string which contains no variables and
69 | // return
70 | // the result.
71 | sbuf.append(messagePattern.substring(i,
72 | messagePattern.length()));
73 | return sbuf.toString();
74 | }
75 | } else {
76 | if (isEscapedDelimeter(messagePattern, j)) {
77 | if (!isDoubleEscaped(messagePattern, j)) {
78 | L--; // DELIM_START was escaped, thus should not be
79 | // incremented
80 | sbuf.append(messagePattern.substring(i, j - 1));
81 | sbuf.append(DELIM_START);
82 | i = j + 1;
83 | } else {
84 | // The escape character preceding the delimiter start is
85 | // itself escaped: "abc x:\\{}"
86 | // we have to consume one backward slash
87 | sbuf.append(messagePattern.substring(i, j - 1));
88 | deeplyAppendParameter(sbuf, argArray[L], new HashMap());
89 | i = j + 2;
90 | }
91 | } else {
92 | // normal case
93 | sbuf.append(messagePattern.substring(i, j));
94 | deeplyAppendParameter(sbuf, argArray[L], new HashMap());
95 | i = j + 2;
96 | }
97 | }
98 | }
99 | // append the characters following the last {} pair.
100 | sbuf.append(messagePattern.substring(i, messagePattern.length()));
101 | return sbuf.toString();
102 | }
103 |
104 | static boolean isEscapedDelimeter(String messagePattern,
105 | int delimeterStartIndex) {
106 |
107 | if (delimeterStartIndex == 0) {
108 | return false;
109 | }
110 | char potentialEscape = messagePattern.charAt(delimeterStartIndex - 1);
111 | if (potentialEscape == ESCAPE_CHAR) {
112 | return true;
113 | } else {
114 | return false;
115 | }
116 | }
117 |
118 | static boolean isDoubleEscaped(String messagePattern,
119 | int delimeterStartIndex) {
120 | if (delimeterStartIndex >= 2
121 | && messagePattern.charAt(delimeterStartIndex - 2) == ESCAPE_CHAR) {
122 | return true;
123 | } else {
124 | return false;
125 | }
126 | }
127 |
128 | @SuppressWarnings("rawtypes")
129 | private static void deeplyAppendParameter(StringBuffer sbuf, Object o,
130 | Map seenMap) {
131 | if (o == null) {
132 | sbuf.append("null");
133 | return;
134 | }
135 | if (!o.getClass().isArray()) {
136 | safeObjectAppend(sbuf, o);
137 | } else {
138 | // check for primitive array types because they
139 | // unfortunately cannot be cast to Object[]
140 | if (o instanceof boolean[]) {
141 | booleanArrayAppend(sbuf, (boolean[]) o);
142 | } else if (o instanceof byte[]) {
143 | byteArrayAppend(sbuf, (byte[]) o);
144 | } else if (o instanceof char[]) {
145 | charArrayAppend(sbuf, (char[]) o);
146 | } else if (o instanceof short[]) {
147 | shortArrayAppend(sbuf, (short[]) o);
148 | } else if (o instanceof int[]) {
149 | intArrayAppend(sbuf, (int[]) o);
150 | } else if (o instanceof long[]) {
151 | longArrayAppend(sbuf, (long[]) o);
152 | } else if (o instanceof float[]) {
153 | floatArrayAppend(sbuf, (float[]) o);
154 | } else if (o instanceof double[]) {
155 | doubleArrayAppend(sbuf, (double[]) o);
156 | } else {
157 | objectArrayAppend(sbuf, (Object[]) o, seenMap);
158 | }
159 | }
160 | }
161 |
162 | private static void safeObjectAppend(StringBuffer sbuf, Object o) {
163 | try {
164 | String oAsString = o.toString();
165 | sbuf.append(oAsString);
166 | } catch (Throwable t) {
167 | System.err
168 | .println("Logger: Failed toString() invocation on an object of type ["
169 | + o.getClass().getName() + "]");
170 | t.printStackTrace();
171 | sbuf.append("[FAILED toString()]");
172 | }
173 |
174 | }
175 |
176 | @SuppressWarnings({ "unchecked", "rawtypes" })
177 | private static void objectArrayAppend(StringBuffer sbuf, Object[] a,
178 | Map seenMap) {
179 | sbuf.append('[');
180 | if (!seenMap.containsKey(a)) {
181 | seenMap.put(a, null);
182 | final int len = a.length;
183 | for (int i = 0; i < len; i++) {
184 | deeplyAppendParameter(sbuf, a[i], seenMap);
185 | if (i != len - 1)
186 | sbuf.append(", ");
187 | }
188 | // allow repeats in siblings
189 | seenMap.remove(a);
190 | } else {
191 | sbuf.append("...");
192 | }
193 | sbuf.append(']');
194 | }
195 |
196 | private static void booleanArrayAppend(StringBuffer sbuf, boolean[] a) {
197 | sbuf.append('[');
198 | final int len = a.length;
199 | for (int i = 0; i < len; i++) {
200 | sbuf.append(a[i]);
201 | if (i != len - 1)
202 | sbuf.append(", ");
203 | }
204 | sbuf.append(']');
205 | }
206 |
207 | private static void byteArrayAppend(StringBuffer sbuf, byte[] a) {
208 | sbuf.append('[');
209 | final int len = a.length;
210 | for (int i = 0; i < len; i++) {
211 | sbuf.append(a[i]);
212 | if (i != len - 1)
213 | sbuf.append(", ");
214 | }
215 | sbuf.append(']');
216 | }
217 |
218 | private static void charArrayAppend(StringBuffer sbuf, char[] a) {
219 | sbuf.append('[');
220 | final int len = a.length;
221 | for (int i = 0; i < len; i++) {
222 | sbuf.append(a[i]);
223 | if (i != len - 1)
224 | sbuf.append(", ");
225 | }
226 | sbuf.append(']');
227 | }
228 |
229 | private static void shortArrayAppend(StringBuffer sbuf, short[] a) {
230 | sbuf.append('[');
231 | final int len = a.length;
232 | for (int i = 0; i < len; i++) {
233 | sbuf.append(a[i]);
234 | if (i != len - 1)
235 | sbuf.append(", ");
236 | }
237 | sbuf.append(']');
238 | }
239 |
240 | private static void intArrayAppend(StringBuffer sbuf, int[] a) {
241 | sbuf.append('[');
242 | final int len = a.length;
243 | for (int i = 0; i < len; i++) {
244 | sbuf.append(a[i]);
245 | if (i != len - 1)
246 | sbuf.append(", ");
247 | }
248 | sbuf.append(']');
249 | }
250 |
251 | private static void longArrayAppend(StringBuffer sbuf, long[] a) {
252 | sbuf.append('[');
253 | final int len = a.length;
254 | for (int i = 0; i < len; i++) {
255 | sbuf.append(a[i]);
256 | if (i != len - 1)
257 | sbuf.append(", ");
258 | }
259 | sbuf.append(']');
260 | }
261 |
262 | private static void floatArrayAppend(StringBuffer sbuf, float[] a) {
263 | sbuf.append('[');
264 | final int len = a.length;
265 | for (int i = 0; i < len; i++) {
266 | sbuf.append(a[i]);
267 | if (i != len - 1)
268 | sbuf.append(", ");
269 | }
270 | sbuf.append(']');
271 | }
272 |
273 | private static void doubleArrayAppend(StringBuffer sbuf, double[] a) {
274 | sbuf.append('[');
275 | final int len = a.length;
276 | for (int i = 0; i < len; i++) {
277 | sbuf.append(a[i]);
278 | if (i != len - 1)
279 | sbuf.append(", ");
280 | }
281 | sbuf.append(']');
282 | }
283 | }
284 |
--------------------------------------------------------------------------------
/src/org/langke/util/logging/support/PrintLogger.java:
--------------------------------------------------------------------------------
1 | package org.langke.util.logging.support;
2 |
3 | import org.langke.testscript.common.Strings;
4 |
5 | public class PrintLogger
6 | extends AbstractESLogger
7 | {
8 |
9 | StringBuilder sb = new StringBuilder();
10 |
11 | public PrintLogger(String string)
12 | {
13 | super(string);
14 | }
15 |
16 | protected void internalTrace(String msg)
17 | {
18 | sb.append("[TRACE]").append(msg);
19 | sb.append("\n");
20 | }
21 |
22 | protected void internalTrace(String msg, Throwable cause)
23 | {
24 | internalTrace(msg);
25 | String string = Strings.throwableToString(cause);
26 | sb.append(string);
27 | sb.append("\n");
28 | }
29 |
30 | protected void internalDebug(String msg)
31 | {
32 | sb.append("[DEBUG]").append(msg);
33 | sb.append("\n");
34 | }
35 |
36 | protected void internalDebug(String msg, Throwable cause)
37 | {
38 | internalDebug(msg);
39 | String string = Strings.throwableToString(cause);
40 | sb.append(string);
41 | sb.append("\n");
42 | }
43 |
44 | protected void internalInfo(String msg)
45 | {
46 | sb.append("[INFO]").append(msg);
47 | sb.append("\n");
48 | }
49 |
50 | protected void internalInfo(String msg, Throwable cause)
51 | {
52 | internalInfo(msg);
53 | String string = Strings.throwableToString(cause);
54 | sb.append(string);
55 | sb.append("\n");
56 | }
57 |
58 | protected void internalWarn(String msg)
59 | {
60 | sb.append("[WARN]").append(msg);
61 | sb.append("\n");
62 | }
63 |
64 | protected void internalWarn(String msg, Throwable cause)
65 | {
66 | internalWarn(msg);
67 | String string = Strings.throwableToString(cause);
68 | sb.append(string);
69 | sb.append("\n");
70 | }
71 |
72 | protected void internalError(String msg)
73 | {
74 | sb.append("[ERROR]").append(msg);
75 | sb.append("\n");
76 | }
77 |
78 | protected void internalError(String msg, Throwable cause)
79 | {
80 | internalError(msg);
81 | String string = Strings.throwableToString(cause);
82 | sb.append(string);
83 | sb.append("\n");
84 | }
85 |
86 | public String getName()
87 | {
88 | return null;
89 | }
90 |
91 | public boolean isTraceEnabled()
92 | {
93 | return true;
94 | }
95 |
96 | public boolean isDebugEnabled()
97 | {
98 | return true;
99 | }
100 |
101 | public boolean isInfoEnabled()
102 | {
103 | return true;
104 | }
105 |
106 | public boolean isWarnEnabled()
107 | {
108 | return true;
109 | }
110 |
111 | public boolean isErrorEnabled()
112 | {
113 | return true;
114 | }
115 |
116 |
117 | @Override
118 | public String toString()
119 | {
120 | return sb.toString();
121 | }
122 | }
123 |
--------------------------------------------------------------------------------