📄 monitoringagent.java
字号:
package com.infobank.monitoringSystem.agent;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import java.util.Properties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.infobank.monitoringSystem.bean.moniroting;
import com.infobank.monitoringSystem.util.PropertyRead;
import com.infobank.monitoringSystem.util.constants;
import com.infobank.monitoringSystem.util.propertyFile;
import com.infobank.superchannel.admin.controller.DatabaseCacheController;
import com.infobank.superchannel.admin.controller.MessageLauncherController;
import com.infobank.superchannel.admin.monitor.ChannelStatusMonitor;
import com.infobank.superchannel.admin.monitor.DatabaseCacheStatusMonitor;
import com.infobank.superchannel.pojo.BlackListLog;
import com.infobank.superchannel.pojo.ControllerUserToken;
import com.infobank.superchannel.pojo.TextMessage;
import com.infobank.superchannel.pojo.TextMessageLog;
import com.infobank.superchannel.admin.controller.*;
//����ҵ����
public class monitoringAgent {
Log log = LogFactory.getLog(monitoringAgent.class);
public void execute(Hashtable table)
{
log.info("execute method start");
String strAct = (String)table.get("act");
//��½
if(strAct.equals("logIn"))
{
//processLogIn(table);
getMonitoringList(table);
table.put(constants.RETURN_PAGE, constants.MONITORING_LIST);
}
if(strAct.equals("toMain"))
{
table.put(constants.RETURN_PAGE, constants.MAIN);
}
else if(strAct.equals("monitoringRefrensh"))
{
getMonitoringList(table);
table.put(constants.RETURN_PAGE, constants.MONITORING_LIST);
}
//��ȡLOG
else if(strAct.equals("toLogPage"))
{
processGetLog(table);
}
//������Ϣˢ��
else if(strAct.equals("QueueRefensh"))
{
processMonitoringRefrensh(table);
table.put(constants.RETURN_PAGE, constants.MONITORING_QUEUE);
}
else if(strAct.equals("changeStatus"))
{
processChangeStatus(table);
table.put(constants.RETURN_PAGE, constants.MONITORING_LIST);
}
else if(strAct.equals("openConfigFile"))
{
processOpenConfigFile(table);
table.put(constants.RETURN_PAGE, constants.CONFIG_FILE_EDIT);
}
else if(strAct.equals("configFileView"))
{
processConfigFileView(table);
}
else if(strAct.equals("saveData"))
{
processSaveData(table);
}
log.info("execute method end");
}
//读取log信息
public void processGetLog(Hashtable table)
{
log.info("processGetLog method start");
moniroting bean = null;
try{
List rmiDataBaseList = (List)table.get("rmiDataBaseList");
for(int j = 0; j < rmiDataBaseList.size(); j++)
{
if(rmiDataBaseList.get(j).equals("")) continue;
String threadId = (String)table.get("threadId");
List oldMessageList = table.get("oldList"+j) != null ? (List)table.get("oldList"+j) : new ArrayList();
ControllerUserToken tokenC= (ControllerUserToken)table.get("tokenC"+j);
ControllerUserToken tokenD= (ControllerUserToken)table.get("tokenD"+j);
if(tokenC == null) continue;
// List channelList = ((MessageLauncherController)table.get("mlc"+j)).getChannelMonitor(tokenC);
List channelList = ((SuperChannelController)table.get("mlc"+j)).getAllMessageLauncherController(tokenC);
for(int i = 0; i < channelList.size(); i++)
{
ChannelStatusMonitor csm = (ChannelStatusMonitor)channelList.get(i);
if(csm.getChannelInfo(tokenC).name.equals(threadId))
{
bean = new moniroting();
bean.setServerName(csm.getChannelInfo(tokenC).description);
bean.setThreadId(csm.getChannelInfo(tokenC).name);
List messageNewList = csm.getDeliverMessageLog(tokenC);
if(oldMessageList.size()+messageNewList.size() > 100)
{
bean.setTextMessageLog(messageNewList != null ? messageNewList : new ArrayList());
table.put("oldList"+j, messageNewList);
}
else
{
List list = new ArrayList();
list.addAll(oldMessageList);
list.addAll(messageNewList != null ? messageNewList : new ArrayList());
bean.setTextMessageLog(list);
table.put("oldList"+j, list);
}
//处理错误信息
bean.setErrList(processErrList((List<TextMessageLog>)table.get("errList"+j),messageNewList));
bean.setMessageSuccessfulCount(csm.getNumberOfSuccessfulMessages(tokenC));
bean.setMessageFailCount(csm.getNumberOfFailedMessages(tokenC));
bean.setMessageAverageTime(csm.getAverageTimeUsagePerMessage(tokenC));
bean.setMessageTotalCount(csm.getNumberOfSentMessages(tokenC));
bean.setStatus("start");
DatabaseCacheStatusMonitor dcm = ((DatabaseCacheController)table.get("dcc"+j)).getStatusMonitor(tokenD);
bean.setBlackList(dcm.getBlackListLog(tokenD));
bean.setIncoming(dcm.getNewIncomingMessageLog(tokenD));
table.put("blackList"+j,bean.getBlackList());
table.put("errList"+j, bean.getErrList());
}
}
}
}
catch(Exception e){
System.err.println("Client Exception: "+e.toString());
log.info(e,e);
e.printStackTrace();
}
table.put("moniroting", bean);
if(table.get("messageType") == null)
{
table.put(constants.RETURN_PAGE, constants.MONITORING_DETAIL);
}
else if(((String)table.get("messageType")).equals("messgeLog"))
{
table.put(constants.RETURN_PAGE, constants.MONITORING_MESSAGE_LOG);
}
else if(((String)table.get("messageType")).equals("errMessgeLog"))
{
table.put(constants.RETURN_PAGE, constants.MONITORING_ERR_MESSAGE_LOG);
}
log.info("processGetLog method end");
}
public void processMonitoringRefrensh(Hashtable table)
{
log.info("processMonitoringRefrensh method start");
moniroting bean = null;
try{
List rmiDataBaseList = (List)table.get("rmiDataBaseList");
for(int j = 0; j < rmiDataBaseList.size(); j++)
{
if(rmiDataBaseList.get(j).equals("")) continue;
ControllerUserToken tokenC= (ControllerUserToken)table.get("tokenC"+j);
if(tokenC == null) continue;
MessageLauncherController mlc = (MessageLauncherController)table.get("mlc"+j);
bean = new moniroting();
bean.setMessageMassQueueSize(bean.getMessageMassQueueSize()+mlc.getStatusMonitor(tokenC).getMassMessageQueueSize(tokenC));
bean.setMessageGeneralQueueSize(bean.getMessageGeneralQueueSize()+mlc.getStatusMonitor(tokenC).getGeneralMessageQueueSize(tokenC));
}
}
catch(Exception e){
System.err.println("Client Exception: "+e.toString());
log.info(e,e);
e.printStackTrace();
}
table.put("moniroting", bean == null ? new moniroting() : bean);
table.put(constants.RETURN_PAGE, constants.MONITORING_DETAIL);
log.info("processMonitoringRefrensh method end");
}
//��½
public void processLogIn(Hashtable table)
{
String strThreadId = (String)table.get("threadId");
}
//��½�û����
public void checkUser(Hashtable table)
{
}
//ȡ���û�Ȩ��
public void getUserRole(Hashtable table)
{
}
//ȡ��ͨ���б�
public void getMonitoringList(Hashtable table)
{
log.info("getMonitoringList method start");
List list = new ArrayList();
List rmiDataBaseList = (List)table.get("rmiDataBaseList");
try{
for(int j = 0; j < rmiDataBaseList.size(); j++)
{
if(rmiDataBaseList.get(j).equals("")) continue;
ControllerUserToken tokenC= (ControllerUserToken)table.get("tokenC"+j);
MessageLauncherController mlc = (MessageLauncherController)table.get("mlc"+j);
SuperChannelController scc = (SuperChannelController)table.get("mlc"+j);
if(tokenC == null) continue;
/****************************/
List AllchannelList=scc.getAllMessageLauncherController(tokenC);
List channelList =null;
for(int index=0;index<AllchannelList.size();index++){
mlc=(MessageLauncherController) AllchannelList.get(index);
channelList.add(mlc.getChannelMonitor(tokenC));
}
for(int i = 0; i < channelList.size(); i++)
{
ChannelStatusMonitor csm = (ChannelStatusMonitor)channelList.get(i);
moniroting bean = new moniroting();
bean.setServerName(csm.getChannelInfo(tokenC).description);
bean.setThreadId(csm.getChannelInfo(tokenC).name);
bean.setLogName("");
bean.setStatus("start");
list.add(bean);
}
}
}
catch(Exception e){
System.err.println("Client Exception: "+e.toString());
log.info(e,e);
e.printStackTrace();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -