📄 monitoringservlet.java
字号:
// BlackList list
List blacklist=bean.getBlackList();
for(int index=0;index<blacklist.size();index++){
BlackList blacklistlog = (BlackList)blacklist.get(index);
Hashtable blackTable = blacklistlog.blacklist;
Enumeration eBlack = blackTable.keys();
int i = 1;
while(eBlack.hasMoreElements())
{
//System.err.println(i);
i++;
out.write("<tr>");
out.write("<td><font color='#ba55d3' >");
out.write(eBlack.nextElement().toString());
out.write("</font></td>");
out.write("</tr>");
}
}
}
}
out.write("</table>");
out.write("</td>");
out.write("</tr>");
out.write("</table>");
}
if(messageLogPage.equals("detailPage"))
{
// requset ,response
out.write("<table>");
out.write("<tr>");
out.write("<td>");
out.write("监控日志查看");
out.write("</td>");
out.write("</tr>");
out.write("<tr>");
out.write("<td>");
out.write(" 通道名称:"+bean.getServerName());
out.write("</td>");
out.write("</tr>");
out.write("<tr>");
out.write("<td width='70%' >");
out.write("<table>");
out.write("<tr>");
out.write("<td width='40' ></td>");
out.write("<td>短信总数:</td>");
out.write("<td>"+bean.getMessageTotalCount()+"</td>");
out.write("<td width='40' ></td>");
out.write("<td>平均发送时间:</td>");
out.write("<td>"+bean.getMessageAverageTime()+"</td>");
out.write("<td width='40' ></td>");
out.write("<td>发送成功:</td>");
out.write("<td>"+bean.getMessageSuccessfulCount()+"</td>");
out.write("<td width='40' ></td>");
out.write("<td>发送失败:</td>");
out.write("<td>"+bean.getMessageFailCount()+"</td>");
out.write("</tr>");
out.write("</table>");
out.write("</td>");
out.write("</tr>");
out.write("<tr>");
out.write("<td colspan='3' align='right' >");
out.write("<font size='2' color='red' >最后一次更新时间是:"+sdf.format(new java.util.Date())+"</font>");
out.write("</td>");
out.write("</tr>");
out.write("</table>");
}
}
out.flush();
out.close();
}
else
{
doPost(request,response);
}
log.info("doGet method end");
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
log.info("doPost method start");
monitoringAgent agent = new monitoringAgent();
request.getParameter("act");
Hashtable table = Common.parseParameters(request);
if(table.get("rmiRestart") != null && table.get("rmiRestart").equals("Y"))
{
mlc = null;
dcc = null;
scc=null;
tokenC = null;
tokenD = null;
initConfigration();
}
if(mlc == null)
{
initConfigration();
mlc = new MessageLauncherController[MessageLauncherController.length];
dcc = new DatabaseCacheController[MessageLauncherController.length];
scc= new SuperChannelController[SuperChannelController.length];
tokenC = new ControllerUserToken[MessageLauncherController.length];
tokenD = new ControllerUserToken[MessageLauncherController.length];
lookUp(table);
}
inita(request,table);
for(int i = 0; i < rmiDataBaseList.size(); i++)
{
if(rmiDataBaseList.get(i).equals("")) continue;
table.put("oldList"+i,request.getSession().getAttribute("oldList"+i)!= null ? request.getSession().getAttribute("oldList"+i) : new ArrayList() );
table.put("errList"+i,request.getSession().getAttribute("errList"+i)!= null ? request.getSession().getAttribute("errList"+i) : new ArrayList() );
table.put("blackList"+i,request.getSession().getAttribute("blackList"+i)!= null ? request.getSession().getAttribute("blackList"+i) : "" );
}
agent.execute(table);
for(int i = 0; i < rmiDataBaseList.size(); i++)
{
if(rmiDataBaseList.get(i).equals("")) continue;
request.getSession().setAttribute("oldList"+i,table.get("oldList"+i));
request.getSession().setAttribute("errList"+i,table.get("errList"+i));
request.getSession().setAttribute("blackList"+i,table.get("blackList"+i));
}
request.setAttribute("return", table);
log.info("doPost method end");
RequestDispatcher rd = request.getRequestDispatcher((String)table.get(constants.RETURN_PAGE));
rd.forward(request, response);
}
public void lookUp(Hashtable table)
{
log.info("lookUp method start");
try{
for(int i = 0; i < MessageLauncherController.length; i++)
{
try {
rmiDataBaseList.add(DatabaseCacheController[i]);
rmiMessageList.add(MessageLauncherController[i]);
mlc[i]=(MessageLauncherController) Naming.lookup("rmi://"+ip[i]+":"+port[i]+"/"+MessageLauncherController[i]);
dcc[i]=(DatabaseCacheController) Naming.lookup("rmi://"+ip[i]+":"+port[i]+"/"+DatabaseCacheController[i]);
scc[i]=(SuperChannelController) Naming.lookup("rmi://"+ip[i]+":"+port[i]+"/"+DatabaseCacheController[i]);
tokenC[i]=scc[i].logon("admin", "admin");
tokenD[i]=scc[i].logon("admin", "admin");
} catch (Exception e) {
//e.printStackTrace();
log.info(e,e);
continue;
// TODO: handle exception
}
}
table.put("rmiDataBaseList", rmiDataBaseList);
table.put("rmiMessageList", rmiMessageList);
}
catch(Exception e){
System.err.println("Client Exception: "+e.toString());
log.info(e,e);
//e.printStackTrace();
}
log.info("lookUp method end");
}
public void inita(HttpServletRequest request,Hashtable table)
{
log.info("inita method start");
for(int i = 0; i < rmiDataBaseList.size(); i++)
{
try {
if(rmiDataBaseList.get(i).equals("")) continue;
request.getSession().setAttribute("mlc"+i, mlc[i]);
request.getSession().setAttribute("tokenC"+i, tokenC[i]);
request.getSession().setAttribute("tokenD"+i, tokenD[i]);
request.getSession().setAttribute("dcc"+i, dcc[i]);
request.getSession().setAttribute("scc"+i, scc[i]);
request.getSession().setAttribute("rmiDataBaseList", rmiDataBaseList);
request.getSession().setAttribute("rmiMessageList", rmiMessageList);
table.put("mlc"+i,request.getSession().getAttribute("mlc"+i));
table.put("tokenC"+i,request.getSession().getAttribute("tokenC"+i));
table.put("tokenD"+i,request.getSession().getAttribute("tokenD"+i));
table.put("dcc"+i,request.getSession().getAttribute("dcc"+i));
table.put("scc"+i,request.getSession().getAttribute("scc"+i));
} catch (Exception e) {
e.printStackTrace();
log.info(e,e);
continue;
}
}
table.put("rmiDataBaseList",request.getSession().getAttribute("rmiDataBaseList"));
table.put("rmiMessageList",request.getSession().getAttribute("rmiMessageList"));
log.info("inita method end");
}
private void initConfigration()
{
log.info("initConfigration method start");
Properties p = new Properties();
InputStream fis = null;
try {
fis = monitoringServlet.class.getResourceAsStream("/channelListConfig.property");
p.load(fis);
int channelCount = Integer.parseInt(p.getProperty("channelSize"));
MessageLauncherController = new String[channelCount];
DatabaseCacheController = new String[channelCount];
ip = new String[channelCount];
port = new String[channelCount];
for(int i = 0; i < channelCount; i++)
{
DatabaseCacheController[i] = p.getProperty("channel"+(i+1)+".DataBase.name");
MessageLauncherController[i] = p.getProperty("channel"+(i+1)+".Message.name");
ip[i] = p.getProperty("channel"+(i+1)+".ip.name");
port[i] = p.getProperty("channel"+(i+1)+".port.name");
}
} catch (Exception e) {
System.out.println("配置文件错误.");
log.info(e,e);
e.printStackTrace();
// TODO: handle exception
}
log.info("initConfigration method end");
}
private void setLogData(HttpServletRequest request, HttpServletResponse response,Hashtable table)
{
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -