afunms

My Software,My Dream—Forge a more perfect NMS product.

#

Tomcat连接池的当前连接数

        关于如何配置Tomcat数据库连接池,网上已有太多文章了。可是找不到一篇文章能
告诉我,怎么能得到Tomcat连接池的当前连接数。如果想要监视Tomcat的运行状况,这
是一个重要参数。所以我花了半天的时间,专门来研究这个问题。
   
       先是看了Tomcat的相关源码,得到它用了jakarta commons-dbcp这个包,又下载了
commons-dbcp这个包的源吗。终于在BasicDataSource找到getNumActive方法,这就是我想
要的。

    Context initCtx = new InitialContext();
    BasicDataSource bds = (BasicDataSource)initCtx.lookup("java:comp/env/jdbc/afunms");
    initCtx.close();    
    bds.getConnection();
    System.out.println("当前连接数=" + bds.getNumActive());

    随时getConnection()的增加,这个numActive也会增多(如果不关闭connection的话)。
当numActive>maxActive(这个maxActive在xml文件中)时,程序就再不能连上DB了。这就
是我以前的程序为什么会出错的原因,哈哈。 

    注:在连接池配置文件.xml中要写明
    <parameter>
      <name>factory</name>
      <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
    </parameter>

posted @ 2007-09-21 21:37 afunms 阅读(4066) | 评论 (0)编辑 收藏

pl_table

 

从《Port分配》里导出三个表:PL_UNITPL_ATMPL_ATM_PORT

ATM交换机在每个单位都有一台,其实可以把PL_UNITPL_ATM两表合一,但后来考虑到以后还有其他的设备比如路由和视频都要加入,它们也得和单位相关联,所以把单位信息单独拿出,放到一张表里。

    PL_UNIT

字段

属性

说明

备注

ID

NUMBER(3)

ID

UNIT

VARCHAR(30)

单位信息

    PL_ATM

字段

属性

说明

备注

ID

NUMBER(3)

ID

UNIT_ID

NUMBER(3)

单位ID

PL_UNIT.ID

ATM

VARCHAR(30)

ATM机器名

IP

VARCHAR(15)

IP地址

    PL_ATM_PORT

字段

属性

说明

备注

ID

NUMBER(3)

ID

ATM_ID

NUMBER(3)

ATM交换机ID

PL_ATM.ID

SLOT

NUMBER(3)

板卡

PORT

NUMBER(3)

端口

DESCRIPTION

VARCHAR(30)

端口描述

TOPO_HOST_NODEPL_ATM有重复的数据,但没办法,因为前者的数据为拓扑自动发现的,而后者的数据是从Excel文件中导入的,二者数据不可能完全一致,所以只能保留两个表。而PL_ATM表中的IP地址是从表TOPO_HOST_NODE查询得到的。因为在Excel文件,没有任何ATMIP对应的信息,我只能从发现的结果中查询得到各机器的IP地址。

从《PVC规划和配置》中导入ATM PVC数据,我觉得这些数据应该与PL_UNIT关联,但由于《PVC规划和配置》中单位名称与《Port分配》中的单位名称不一致,所以关联起来有困难,就是要人为一个个去找。晕,暂时先这样吧,给用户看过后再说吧。

posted @ 2007-09-20 19:57 afunms 阅读(130) | 评论 (0)编辑 收藏

cheer

(1)CVS提交或更新的时候老是出现一个错误:
     cvs server: C:\WINDOWS\TEMP\cvsC7.tmp: No such file or directory
     cvs [server aborted]: error diffing test.txt
    
    根据网上资料提示,觉得可能是以下原因:
    1.CVSROOT下的Reposity下的路径设置不真确.
    2.可能该用户没有设置该权限.

    一一排查,最后才发现是因为CVSNT服务器上运行的账号是USER用户组的,没有对C:\WINDOWS操作权限

,因此我更改CVSNET临时目录,从c:\windows\temp到d:\cvs_temp,再运行提交,问题解决。


(2)第一次用正则表达式。
    以前一直认为正则表达式是很神秘的东西,今天努力试用一下,才知道其实很简单。
    我要从“Switch code: GDFY1P45”找出ATM的机器名“GDFY1P45”,
    因为机器名总是xxxx1P(或G)dd,所以我写一个正则表达式来匹配它
    Pattern aliasPattern = Pattern.compile("[1]{1}(P|G){1}[1-9]{1,2}");
    很容易就找出机器名了,呵呵。
 
    要从GDFY1P45_s5p7-GDFY_MON_SP找出_后的s5p7-GDFY_MON_SP
    Pattern  portPattern = Pattern.compile("[_]{1}[s][0-9]{1}[p][0-9]{1}[-]{1}");
    感觉很爽。

posted @ 2007-09-19 19:48 afunms 阅读(129) | 评论 (0)编辑 收藏

Serious Bug

**  Version 1.3.2.Alpha, Release Date 2007.09.18    
    * Serious Bug:add a new node dynamically at runtime,the polling thread
      doesn't query it.The involved classes are TopoResourcePool.java and 
      PollingEngine.java.

posted @ 2007-09-18 22:51 afunms 阅读(101) | 评论 (0)编辑 收藏

解决从tomcat移植到weblogic的两个问题

1. 用XmlHttp获取xml,responseXml为空。
  
   解决方法:
   在web.xml中加入
   <mime-mapping>
      <extension>xml</extension>
      <mime-type>text/xml</mime-type>
   </mime-mapping>
   <mime-mapping>
      <extension>xsl</extension>
      <mime-type>text/xml</mime-type>
   </mime-mapping>

2. 用SmartUpload下载文件时出错   
   出错信息:
   java.io.IOException: 文件名、目录名或卷标语法不正确。
        at java.io.WinNTFileSystem.canonicalize0(Native Method)
        at java.io.Win32FileSystem.canonicalize(Win32FileSystem.java:395)
        at java.io.File.getCanonicalPath(File.java:531)
        at weblogic.servlet.internal.WebAppServletContext.getRealPath       

        (WebAppServletContext.java:666)
        at com.jspsmart.upload.SmartUpload.isVirtual(SmartUpload.java:1180)
        Truncated. see log file for complete stacktrace
        解决方法:自己写了一个Servlet来下载文件,代码如下:
  

 1public class DownLoad extends HttpServlet
 2{
 3    private static final long serialVersionUID = -84138329260803824L;
 4    public void init() throws ServletException
 5    {
 6    }

 7
 8    public void doGet(HttpServletRequest request, HttpServletResponse response) 
 9        throws ServletException, IOException
10    {
11        OutputStream os = null
12        FileInputStream fis = null;
13        try
14        {            
15            String fileName = request.getParameter("filename");  //要下载的文件,包括路径
16            String downFileName = fileName.substring(fileName.lastIndexOf("\\"+ 1); //去掉路径
17            
18            os = response.getOutputStream();
19            File f = new File(fileName);
20            
21            response.setHeader("Content-type:""application/octet-stream");
22            response.setHeader("Accept-Ranges:""bytes");
23            response.setHeader("Accept-Length:", Long.toString(f.length()));
24            response.setHeader("Content-Disposition""attachment; filename=" + downFileName);
25                
26            fis = new FileInputStream(f);
27            byte[] b = new byte[1024];    
28            int i = 0;    
29            while((i = fis.read(b)) > 0
30              os.write(b, 0 ,i);
31        }

32        catch (Exception e)
33        {
34            e.printStackTrace();
35        }

36        finally
37        {
38            fis.close();
39            os.flush();
40            os.close();
41        }

42    }

43
44    public void doPost(HttpServletRequest request, HttpServletResponse response) 
45       throws ServletException, IOException
46    {
47         doGet(request,response);
48    }

49}


 

posted @ 2007-09-17 22:00 afunms 阅读(2939) | 评论 (3)编辑 收藏

recreation

这周末全公司组织出去旅游,大家都玩得很开心。

昨天去漂流,今早骑马,然后泡温泉。

posted @ 2007-09-16 22:31 afunms 阅读(76) | 评论 (0)编辑 收藏

My Goal

1.  December,2007: Add distributed feature to SourceView1.0
     with JMX.
2.  February,2008: Refactor SourceView,update to version2.0.
     The new version must have three features:
     a. MVC 
     b. NMS 
     c. Distributed.
3.  June,2008: A new product,NetFlow.

posted @ 2007-09-15 05:59 afunms 阅读(106) | 评论 (0)编辑 收藏

weblogic + oracle

  1. Replaced Ping by SnmpPing.(ResponseTime.collectData())
  2. Started to remove GDPLN project from Tomcat to Weblogic.
  3. Massive data will be created in future,so we choose Oracle instead of MySQL.
     Combine Weblogic with Oracle,we can build a more powerful system.

posted @ 2007-09-14 22:24 afunms 阅读(77) | 评论 (0)编辑 收藏

summary

        昨日给用户演示了我们的软件,他们对我们的软件表示认可。至少是相信,
我们能很好地完成这个项目。

        工作近四年,回顾一下,自己的代码在哪些单位的服务器上跑着:

        1. 山东济南将军集团 (2004.06)
        2. 辽宁辽宁电力         (2004.10)
        3. 辽宁沈阳供电局     (2005.02)
        4. 河北秦皇岛港务局(2005.06)
        5. 山东齐鲁石化        (2006.11)
        6. 河北衡水信用社    (2007.04)
        7. 安徽恒源煤电        (2007.06)
        8. 广东PLN                (2007.09)

posted @ 2007-09-13 20:51 afunms 阅读(72) | 评论 (0)编辑 收藏

阶段性胜利

昨天完成有关PVC的所有程序,今天上午调试通过,包括与ITSM的接口程序。
今天让XUE先看一下,他表示基本满意,算是一个阶段性的胜利吧。

明天给用户演示一下,根据他们的意见,再作进一步的工作安排。

至于物理链路,我想一定也能在mib中找到,只是,目前来说,我对atm还不够了解。

posted @ 2007-09-12 20:23 afunms 阅读(88) | 评论 (0)编辑 收藏

pvc

1. Tested SourceView1.3.1.Alpha,that is ok.

    -------GDPLN---------
2. Ignored ATM switches' interfaces,because they are insignificant.
    (DiscoverEngine.addHost())
3. ATM switches' interfaces are ignored,so deleted those traffic monitors for them.
    (monitors.xml)
4. Modified ip resource module,two factors contribute to this,
    added a new feature about PVC and deleted the feature about VLAN.
5. Added a new class LucentTypeHelper to convert type digit to the description   
    accordingly.
6. Fetchs PVC information through another SNMP table intfAtmPvcConnDisplayTable,
    instead of ipAtmAppPvcVccStatsTable,simplified the relative program consequently.
7. Created a new db table NMS_ATM_PVC,which stores PVC data.
8. Added two device categories,5=Lucent ATM switch,6=Keda video. 

posted @ 2007-09-11 21:04 afunms 阅读(98) | 评论 (0)编辑 收藏

1.3.1

--------SourceView-----------
**  Version 1.3.1.Alpha, Release Date 2007.09.11   
    * Modifiy: Sometimes the bridgeAddress of switch(or router) can not be got,
       thereby fetching again before this node is added to the nodes list.  
        (DiscoverEngine.addHost())
    * Modifiy: SnmpWalk operation.(SnmpService.snmpWalk())
    * Modifiy: Vlan-interface mapping,affected by modification of SnmpWalk 
       operation(ExtendSnmpUtil.getVlanIfMap()).
    * Add: Printing out the debug information when it is needed.
      (SysProperty.isLogDebug())


--------GDPLN------------
1.完成有关“板卡、接口和通道”的程序。
2.找到完整的PVC信息,包括PVC两端的设备、接口和通道。

posted @ 2007-09-10 20:35 afunms 阅读(106) | 评论 (0)编辑 收藏

LucentATM

今天写一些Lucent ATM相关程序,明天拿到GDPLN去测试一下。

现在我对这个项目越来越有信心了。

posted @ 2007-09-09 22:16 afunms 阅读(83) | 评论 (0)编辑 收藏

jmx

看了一天jmx的相关文档,还是云里雾里。晕啊

不过,我已经决心要多研究开源代码,然后,做一个更好的架构,以实现分布式网管。

posted @ 2007-09-08 23:27 afunms 阅读(115) | 评论 (0)编辑 收藏

1.3.0.Alpha

**  Version 1.3.0.Alpha, Release Date 2007.09.07   
    * Add: SQL-Server monitor.
    * Add: Algorithm for topology display.
    * Modifiy: loads the monitor class when it is needed,rather than loads all classes at the beginning.

posted @ 2007-09-07 15:01 afunms 阅读(103) | 评论 (0)编辑 收藏

仅列出标题
共25页: First 上一页 14 15 16 17 18 19 20 21 22 下一页 Last 

My Links

News

留言簿(18)

随笔档案

相册

搜索

最新评论

阅读排行榜