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

📄 dooverflowthread.java

📁 中国联通短信通信协议
💻 JAVA
字号:
package com.wireless.sms.gwif.smsagent.workthread;


/**
 * <p>Title: WVAS-PLATFORM-SMS</p>
 * <p>Description: 无线增值业务平台-----短信接口机</p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: moon</p>
 * @author: tech team
 * @version 1.0
 */

import java.util.Vector;
//import com.wireless.sms.gwif.smsagent.*;
import com.wireless.sms.pub.mq.*;
//import com.wireless.sms.gwif.smsagent.net.DoBackQueue;
import com.wireless.sms.pub.net.DoBackMOMT;
import java.util.*;
import org.apache.log4j.Logger;
import com.wireless.sms.gwif.smsagent.global.*;

public class DoOverflowThread  {

    private SmsGWIFGlobal smsagent = SmsGWIFGlobal.getInstance();
    private MTQueue mtqueue = GetMoMtGlobalForUsual.mtqueue;
    private MOQueue moqueue = GetMoMtGlobalForUsual.moqueue;
    private ObjectQueue objqueue = ObjectQueue.getInstance();

    private String [] mtflowfilepath = smsagent.MTOVERFLOW;
    private String objflowfilepath = smsagent.STATOVERFLOW;
    private String moflowfilepath = smsagent.MOOVERFLOW;

    private Logger statlog = LoggerConstant.stat_log;
    private Timer timer = null;

    private static final DoOverflowThread _instance = new DoOverflowThread();

    private DoOverflowThread() {
    }

    public static DoOverflowThread getInstance(){
        return _instance;
    }

    public void stop() {
        if( timer != null ){
            timer.cancel();
            timer = null;
        }
    }
    /** 处理数据溢出线程 */
    public void start() {
    	LoggerConstant.stat_log.info("启动处理数据溢出线程....");
        if( timer == null ){

            final Vector vmtqueue = mtqueue.getPriorityQueue();
            final Vector vdoBackmt = new Vector();
            for(int i=0; i<vmtqueue.size(); i++){
                DoBackMOMT doBackmt = new DoBackMOMT( (MTQueue)vmtqueue.elementAt(i) ,mtflowfilepath[i]);
                doBackmt.setLOADSUM(1000);
                doBackmt.setSAVESUM(1000);
//                doBackmt.setLog(statlog);
                vdoBackmt.add( doBackmt );
            }

            final DoBackMOMT doBackmo = new DoBackMOMT(moqueue,moflowfilepath);
            doBackmo.setLOADSUM(1000);
            doBackmo.setSAVESUM(1000);

            final DoBackMOMT doBackobj = new DoBackMOMT(objqueue,objflowfilepath);
            doBackobj.setLOADSUM(1000);
            doBackobj.setSAVESUM(1000);

            timer = new Timer(true);
            timer.schedule(new TimerTask(){
                public void run(){
                    try {
                        //statlog.info("size= " + mtqueue.sizeByPriority());

                        //mt队列的控制
                        for(int i=0; i<vmtqueue.size(); i++){
                            MTQueue tmpQueue = (MTQueue)vmtqueue.elementAt(i);

                            if (tmpQueue.size() > smsagent.maxMTQueueCnt) {
                            	statlog.info("mtqueue[" + i + "].size = " + tmpQueue.size()+" > "+smsagent.maxMTQueueCnt+" start flowMT!");
                                DoBackMOMT doBackmt = (DoBackMOMT)vdoBackmt.elementAt(i);
                                doBackmt.flowMT();
                            }
                            else if (tmpQueue.size() == 0) {
                                DoBackMOMT doBackmt = (DoBackMOMT)vdoBackmt.elementAt(i);
                                doBackmt.loadMT();
                            }
                            else{
                                statlog.info("mtqueue[" + i + "].size = " + tmpQueue.size());
                            }
                        }

                        //object队列的控制
                        if (objqueue.size() > smsagent.maxMTQueueCnt) {
                            doBackobj.flowObj();
                        }
                        else if (objqueue.size() == 0) {
                            doBackobj.loadObj();
                        }else{
                            statlog.info("objqueue.size = "+ objqueue.size());
                        }

                        //下面是mo队列的控制
                        if (moqueue.size() > smsagent.maxMTQueueCnt) {
                            doBackmo.flowMO();
                        }else if (moqueue.size() == 0) {
                            doBackmo.loadMO();
                        }else{
                            statlog.info("moqueue.size = "+ moqueue.size());
                        }

                     } catch (Exception ex) {
                         ex.printStackTrace();
                         statlog.error(ex.getMessage());
                     }
                }
            }, 5000, 5000);

        }
    }
}

⌨️ 快捷键说明

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