⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tailtools.java

📁 使用华为cmpp2.0网关
💻 JAVA
字号:
package com.hoten.tail;
import java.sql.*;
import java.util.*;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */

public class TailTools {
  private static int flag = 0;
  private static Hashtable list = new Hashtable(10);
  public synchronized static void dealTail(String program,String ptype,String mtype,String msgdata) {
    if(program==null||ptype==null||mtype==null||msgdata==null){
      com.hoten.util.Log.printEvent("Program:" + program + " pType:" + ptype +
                                    " mType:" + mtype + " Msg:" + msgdata,
                                    com.hoten.util.MOParam.getInstance().
                                    logFile);
      return;
    }
    if (flag == 1) {
      int size = list.size();
      Enumeration keys = list.keys();
      while(keys.hasMoreElements()){
        String ip = (String)keys.nextElement();
        String port = (String)list.get(ip);
        int pt=0;
        try {
          pt = Integer.parseInt(port);
        }
        catch (Exception ex) {
          continue;
        }
        TailInfo tailInfo = new TailInfo();
        tailInfo.setStartFlag("@@@@");
        tailInfo.setHost(ip);
        tailInfo.setPort(pt);
        tailInfo.setProgram(program);
        tailInfo.setPType(ptype);
        tailInfo.setMType(mtype);
        tailInfo.setMsg(msgdata);
        tailInfo.setEndFlag("####");
        TailList.getInstance().add(tailInfo);
      }
    }
  }
  public synchronized static void setTailFlag(com.hoten.util.DBAccess dba){
       String sql = "select ip,port from ddtservice where flag='2'";
       Connection cn = null;
       Statement stmt = null;
       ResultSet rs = null;
       boolean check = false;
       try{
         cn = dba.getConnection();
         stmt = cn.createStatement();
         rs = stmt.executeQuery(sql);
         while(rs.next()){
           String ip = rs.getString(1);
           String port = rs.getString(2);
           if (ip != null && port != null) {
             if (!check) {
               list.clear();
               check = true;
             }
             list.put(ip, port);
           }
         }
       }catch(Exception ex){
         check=false;
       }
       finally{
           sql = null;
           try{
             rs.close();
             stmt.close();
           }catch(Exception ex){
           }
           dba.freeConnection(cn);
       }
       if(check&&flag==0) flag=1;
       if(!check&&flag==1) flag=0;
   }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -