发布新日志

  • POI相关知识

    2009-06-09 11:43:30

    POI相关知识
    一.POI 介绍
        POI是Apache的Jakata项目,POI 代表 Poor Obfuscation Implementation,即不良模糊化实现。POI 的目标就是提供一组 Java API 来使得基于 Microsoft OLE 2 Compound Document 格式的 Microsoft Office 文件易于操作。一些 POI API 仅仅是为最常用的 Microsoft Office 文件 Word 和 Excel 而开发的;而其他的 API 则是用于通用的 OLE 2 Compound Document 和属性文件。POI可以到www.apache.org下载到。编译好的jar主要有这样4个:poi包,poi Browser包,poi hdf包,poi hssf例程包。实际运行时,需要有poi包就可以了。POI 是一个开放源代码项目,并且得到了数百名志愿者的不断更新。可以在 http://jakarta/apache.org/ 上获得源代码和文档。通过POI包,我们不仅可以操纵excel文档,也能够操控word文档,以及其他的OLE2格式的文档。
    下载了poi-bin-2.5.1-final-20040804.zip将其解压,其目录结构如下:
    docs(帮助文档)
    legal(协议)
    poi-2.5.1-final-20040804.jar
    poi-contrib-2.5.1-final-20040804.jar
    poi-scratchpad-2.5.1-final-20040804.jar
    把poi-2.5.1-final-20040804.jar考到eclipse项目的vlib下(如果以前没有,先新建lib文件夹),然后在项目中将JAR文件引入库,方法是:右击项目〉属性〉JAVA构建路径〉库〉添加JAR
    加入之后就可以引用其中的类了;
     
    2.原理:把Ecxel真正转换为对象
    3.常识:
       HSSF 代表 Horrible Spreadsheet Format(可怕的电子表格格式)。API 给程序员提供了极其容易地读写或操作 Microsoft Excel 97-2002 文件的能力。这些API都由POI包来提供,实际使用是我们只需要POI包就可以了。
    4.简单介绍:
      HSSF提供给用户使用的对象在org.apache.poi.hssf.usermodel包中,主要部分包括Excell对象,样式和格式,还有辅助操作。有以下几种对象:
      HSSFWorkbook excell的文档对象
      HSSFSheet excell的表单
      HSSFRow excell的行
      HSSFCell excell的格子单元
      HSSFFont excell字体
      HSSFName 名称
      HSSFDataFormat 日期格式
      在poi1.7中才有以下2项:
      HSSFHeader sheet头
      HSSFFooter sheet尾
      和这个样式
      HSSFCellStyle. cell样式
      辅助操作包括
      HSSFDateUtil 日期
      HSSFPrintSetup 打印
      HSSFErrorConstants 错误信息表
    5.工程例子部份
        创建excel对象 HSSFWorkbook wb= new HSSFWorkbook(“文件”);
        建立与sheet联系  HSSFSheet sheet=wb.getSheetAt(0);
        建立行数据   HSSFRow row=sheet.getRow(i);
        返回行数据   HSSFCell cell=row.getCell((short)0);
                    HSSFCell cell1=row.getCell((short)1);
        读取列   cell.getStringCellValue()
        注意有点说明:
        1)excel中只要是数字就是double型的通过cellgetNumericCellValue()读取
        2)在excel中一份workbook中可能会有好几个表格,这些表格的顺序是从0开始 
          的;行列也都是从下标0开始的。         
    6. 其他的方法
      将数据从excel文件中读出来还有一个方法,就是使用odbc。然后再用jdbc-odbc桥来将数据从excel文件中读出到java中来,不过这种方法必须配odbc,针对excle文件配odbc是一件很麻烦的事情,而且难以操控,所以这只能是一种暂时的解决方法。
  • cruiseControl learning

    2009-01-21 11:00:17

    最近 research CruiseControl tool .自己mark 一下

    CruiseControl is both a continuous integration tool and an extensible framework for creating a custom continuous build process. It includes dozens of plugins for a variety of source controls, build technologies, and notifications schemes including email and instant messaging. A web interface provides details of the current and previous builds. And the standard CruiseControl distribution is augmented through a rich selection of 3rd Party Tools.

    一个 continuous integration 工具,能团队进行敏捷开发,每过一段时间来进行集成,以便随时能发现引入的错误。当build失败后,将会通知提交者,使其能够更改代码。

    cruiseControl(CC)的配置是围绕六个插件来展开的。

    在提交之后,build失败了,如果不希望在再次提交代码之前重复的构建,可以有如下设置  <project name="integration" buildafterfailed="false">
    ----


    1. Bootstrapper: cc创建之前运行,是创建前的准备工作 ....Bootstrappers are run before a build takes place
    <bootstrappers> 
      <currentbuildstatusbootstrapper> 指定了状态文件的位置,主要是用来访问项目当前创建的状态
      <cvsbootstrappers> 可以是其他的源码控制系统,.....就是为从源码控制系统更新ant 的 buildfile 文件而设计的.....
      因为我们每次项目的创建都应该基于最新的代码,因此在创建之前就要获得最新的项目文件, 如果你使用的是ant, 这个工作是由ant 的buildfile来完成的。


    2. SourceControl:访问源码控制系统,查看源码自上次build之后是否被修改。并据此决定是否需要进行下一次Build
    <modificationset>  ,用于检查各个源码控制系统中是否发生变化,<schedule>会用到这里面的配置信息,如果检测到变化,会触发创建过程。



    3. Builder:对项目进行创建,(包括对项目源码的的编译,测试,打包)
    <schedule>  定时驱动<modificationset>,如果检测到变化,就执行所指定的builder 的任务。
    当<modificationset>检测到修改时,如果没有调用build,下次也不会调用build,因为下次没有检测到失败。
    但是build失败时,会一直要重新构建,直到构建成功。有时候需要force build
    因此build失败后,再此成功时,至少有两次被修改了,即modifications 为2

    ----------------------------------------------------------------
    <schedule interval="60">
          <ant anthome="apache-ant-1.7.0" buildfile="cc-build.xml" saveLogDir="projects/${project.name}" antworkingdir="projects/${project.name}"
    target="build" />
    </schedule> 
    当ant节点的antworkingdir属性设定之后,buildfile的起始位置将是  antworkingdir的位置,切记。(ant应用中)ant调用其他文件时,好像也是样的吧,需要查查
    -------------------------------------------------------------


    4. LabelIncrementer:对源码打标签,自动增加标签的编号

    5. Publisher:发布创建的结果,可以通过email的方式通知开发人员()。。。。


    IRCPublisher   将结果发入一irc服务器,需要一个 ircPublicsher插件, http://confluence.public.thoughtworks.org/display/CC/IRCPublisher
    --------------------------------
    当提交的人提交的内容导致了错误,将发送错误消息给他,配置如下:需要注意的一点是,如果cvs用户名是"Paul wei"形式,用户名之间有空格的,CC只提取前面一部分,作为用户名,所以需要加个<map alias="Paul" address="**@**"
    />
        <publishers>
          <onsuccess>
            <artifactspublisher dest="artifacts/${project.name}" file="projects/${project.name}/target/${project.name}.jar" />
          </onsuccess>
       <currentbuildstatuspublisher file="logs/${project.name}/status.txt" />
         <email mailhost="smtp.host"
            returnaddress="admin@smtp.host"
            skipusers="false"
            reportsuccess="fixes"
            subjectprefix="[CruiseControl]"
            buildresultsurl="http://localhost:8080/buildresults/integration"
        >
        <map alias="Paul" address="paul@smtp.host" /> 
                 </email>
        </publishers>

    至于 config.xml 很多参数,需要参考 http://cruisecontrol.sourceforge.net
     

  • mark 一下

    2008-08-19 15:34:41

    来新的公司已经2个多月了,新的公司很多很多和以前不一样的东西,我不想说什么技术的东西,最重要的业务数据很难懂,也没有什么人培训,也只有靠自己瞎子摸象,走到哪里是哪里,也只有靠自己去不停的请教别人。
  • 了解APACHE HTTP SERVER 工具的使用

    2007-05-17 15:21:40

    自己在测试一个HTTP 请求的一个压力测试.同时在请求的时候,要传送一个文本包:我就利用这个工具来测试的.觉得还不错.就把这个工具的使用方法贴出来,做为纪念.

    ab是Apache超文本传输协议(HTTP)的性能测试工具。 其设计意图是描绘当前所安装的Apache的执行性能, 主要是显示你安装的Apache每秒可以处理多少个请求。

     参数:
    -n requests Number of requests to perform
    //在测试会话中所执行的请求个数。默认时,仅执行一个请求
    -c concurrency Number of multiple requests to make
    //一次产生的请求个数。默认是一次一个。
    -t timelimit Seconds to max. wait for responses
    //测试所进行的最大秒数。其内部隐含值是-n 50000。它可以使对服务器的测试限制在一个固定的总时间以内。默认时,没有时间限制。
    -p postfile File containing data to POST
    //包含了需要POST的数据的文件.
    -T content-type Content-type header for POSTing
    //POST数据所使用的Content-type头信息。
    -v verbosity How much troubleshooting info to print
    //设置显示信息的详细程度 - 4或更大值会显示头信息, 3或更大值可以显示响应代码(404, 200等), 2或更大值可以显示警告和其他信息。 -V 显示版本号并退出。
    -w Print out results in HTML tables
    //以HTML表的格式输出结果。默认时,它是白色背景的两列宽度的一张表。
    -i Use HEAD instead of GET
    // 执行HEAD请求,而不是GET。
    -x attributes String to insert as table attributes
    //
    -y attributes String to insert as tr attributes
    //
    -z attributes String to insert as td or th attributes
    //
    -C attribute Add cookie, eg. 'Apache=1234. (repeatable)
    //-C cookie-name=value 对请求附加一个Cookie:行。 其典型形式是name=value的一个参数对。此参数可以重复。
    -H attribute Add Arbitrary header line, eg. 'Accept-Encoding: gzip'
    Inserted after all normal header lines. (repeatable)
    -A attribute Add Basic WWW Authentication, the attributes
    are a colon separated username and password.
    -P attribute Add Basic Proxy Authentication, the attributes
    are a colon separated username and password.
    //-P proxy-auth-username:password 对一个中转代理提供BASIC认证信任。用户名和密码由一个:隔开,并以base64编码形式发送。无论服务器是否需要(即, 是否发送了401认证需求代码),此字符串都会被发送。
    -X proxy:port Proxyserver and port number to use
    -V Print version number and exit
    -k Use HTTP KeepAlive feature
    -d Do not show percentiles served table.
    -S Do not show confidence estimators and warnings.
    -g filename Output collected data to gnuplot format file.
    -e filename Output CSV file with percentages served
    -h Display usage information (this message)
    //-attributes 设置 属性的字符串. 缺陷程序中有各种静态声明的固定长度的缓冲区。另外,对命令行参数、服务器的响应头和其他外部输入的解析也很简单,这可能会有不良后果。它没有完整地实现 HTTP/1.x; 仅接受某些'预想'的响应格式。 strstr(3)的频繁使用可能会带来性能问题,即, 你可能是在测试ab而不是服务器的性能。

    参数很多,一般我们用 -c 和 -n 参数就可以了. 例如:

    ./ab -c 1000 -n 1000 http://127.0.0.1/index.php

    这个表示同时处理1000个请求并运行1000次index.php文件.
    #/usr/local/xiaobai/apache2054/bin/ab -c 1000 -n 1000 http://127.0.0.1/index.html.zh-cn.gb2312
    This is ApacheBench, Version 2.0.41-dev <$Revision: 1.121.2.12 $> apache-2.0
    Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
    Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/

    Benchmarking 127.0.0.1 (be patient)
    Completed 100 requests
    Completed 200 requests
    Completed 300 requests
    Completed 400 requests
    Completed 500 requests
    Completed 600 requests
    Completed 700 requests
    Completed 800 requests
    Completed 900 requests
    Finished 1000 requests


    Server Software: Apache/2.0.54
    //平台apache 版本2.0.54
    Server Hostname: 127.0.0.1
    //服务器主机名
    Server Port: 80
    //服务器端口

    Document Path: /index.html.zh-cn.gb2312
    //测试的页面文档
    Document Length: 1018 bytes
    //文档大小

    Concurrency Level: 1000
    //并发数
    Time taken for tests: 8.188731 seconds
    //整个测试持续的时间
    Complete requests: 1000
    //完成的请求数量
    Failed requests: 0
    //失败的请求数量
    Write errors: 0

    Total transferred: 1361581 bytes
    //整个场景中的网络传输量
    HTML transferred: 1055666 bytes
    //整个场景中的HTML内容传输量
    Requests per second: 122.12 [#/sec] (mean)
    //大家最关心的指标之一,相当于 LR 中的 每秒事务数 ,后面括号中的 mean 表示这是一个平均值
    Time per request: 8188.731 [ms] (mean)
    //大家最关心的指标之二,相当于 LR 中的 平均事务响应时间 ,后面括号中的 mean 表示这是一个平均值
    Time per request: 8.189 [ms] (mean, across all concurrent requests)
    //每个请求实际运行时间的平均值
    Transfer rate: 162.30 [Kbytes/sec] received
    //平均每秒网络上的流量,可以帮助排除是否存在网络流量过大导致响应时间延长的问题

    Connection Times (ms)
    min mean[+/-sd] median max
    Connect: 4 646 1078.7 89 3291
    Processing: 165 992 493.1 938 4712
    Waiting: 118 934 480.6 882 4554
    Total: 813 1638 1338.9 1093 7785
    //网络上消耗的时间的分解,各项数据的具体算法还不是很清楚

    Percentage of the requests served within a certain time (ms)
    50% 1093
    66% 1247
    75% 1373
    80% 1493
    90% 4061
    95% 4398
    98% 5608
    99% 7368
    100% 7785 (longest request)
    //整个场景中所有请求的响应情况。在场景中每个请求都有一个响应时间,其中50%的用户响应时间小于1093 毫秒,60% 的用户响应时间小于1247 毫秒,最大的响应时间小于7785 毫秒

    由于对于并发请求,cpu实际上并不是同时处理的,而是按照每个请求获得的时间片逐个轮转处理的,所以基本上第一个Time per request时间约等于第二个Time per request时间乘以并发请求数

  • 今天我也开始写点东西了

    2007-05-17 15:12:07

     今天是我可爱的女儿正好满14个月.14个月来,每天累并快乐着,当然也夹杂着各种不可调和的矛盾.呵呵,都随着女儿的成长烟消云散了.自己的职业生涯也到了一定的年限,忽然想记点什么.来纪念我的走过的岁月.

     

Open Toolbar