OSDN Git Service

Initial commit
[ultramonkey-l7/l7gui.git] / src / WebContent / log_ha.jsp
1 <%@ page import="org.ultramonkey.l7.model.*,
2                                  org.ultramonkey.l7.controller.*,
3                                  org.ultramonkey.l7.view.*, java.util.*,
4                                  java.text.SimpleDateFormat,java.text.NumberFormat"
5         language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
6 <%
7     /*
8      * check session
9      */
10     if (session.isNew()) {
11         MessageView error = new MessageView(41272, LogCategorySet.GUI_USER_AUTHENTICATION, Message.INVALID_SESSSION); 
12         session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
13         response.sendRedirect(RedirectPages.LOGIN);
14         return;
15     }
16
17     /*
18      * get result message
19      */
20     MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE);
21     String errorMessage = "";
22     int errorNumber = 0;
23     String category = "";
24     String resultJudge = "success";
25     if (message != null) {
26       errorMessage = message.getMessage();
27       errorNumber = message.getErrno();
28       category = message.getCategory();
29       session.setAttribute(SessionKeys.RESULT_MESSAGE, null);
30       if ( errorNumber >= ErrNo.ERRORNUMBER )
31           resultJudge = "error";
32     }
33     
34     /*
35      * get command message
36      */
37     MessageView commandmessage = (MessageView) session.getAttribute(SessionKeys.COMMAND_MESSAGE);
38     String commandMessage = "";
39     int commandNumber = 0;
40     String commandCategory = "";
41     if (commandmessage != null) {
42       commandMessage = commandmessage.getMessage();
43       commandNumber = commandmessage.getErrno();
44       commandCategory = commandmessage.getCategory();
45       session.setAttribute(SessionKeys.COMMAND_MESSAGE, null);
46     }
47     
48     /*
49      * get ha_log info
50      */
51      L7guiFramework framework = new L7guiFramework();
52      LogData logdata = framework.getLogData();
53      
54      if (logdata == null){
55          MessageView error = new MessageView(41273, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
56          session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
57          response.sendRedirect(RedirectPages.LOGIN);
58          return;
59      }
60
61      LogSet data = logdata.haLog;
62      
63      if (data == null){
64          MessageView error = new MessageView(41274, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
65          session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
66          response.sendRedirect(RedirectPages.LOGIN);
67          return;
68      } 
69
70      Vector<LogFileData> logfiles = data.logFiles;
71      if (logfiles == null){
72          MessageView error = new MessageView(41275, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
73          session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
74          response.sendRedirect(RedirectPages.LOGIN);
75          return;
76      }
77
78      
79      /*
80       * get cluster status
81       */
82      ClusterData cd = framework.getClusterData();
83      
84      if (cd == null){
85          MessageView error = new MessageView(41276, LogCategorySet.GUI_IO_COMMAND, Message.CLUSTER_DATA_ERROR);
86          session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
87          response.sendRedirect(RedirectPages.LOGIN);
88      }
89       
90     /*
91      * fix style seat
92      */
93     String cssSeat = "l7gui_single_style.css";
94     if ( cd.self_status == ClusterStatus.ACTIVE ){
95       cssSeat = "l7gui_act_style.css";
96     }
97     else if ( cd.self_status == ClusterStatus.STANDBY ){
98       cssSeat = "l7gui_sby_style.css";
99     }
100
101 %>
102
103
104 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
105
106 <html>
107   <head>
108     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
109         <meta http-equiv="Pragma" content="no-cache">
110         <meta http-equiv="Cache-Control" content="no-cache">
111         <meta http-equiv="Expires" content="0">                 
112     <meta http-equiv="Content-Script-Type" content="text/javascript" />
113     <meta http-equiv="Content-Style-Type" content="text/css" />
114     <script src="l7gui.js" type="text/javascript"></script>
115     <noscript> 
116          <meta http-equiv="refresh" content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>"/>
117       </noscript> 
118     <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
119     <link rel="shortcut icon" href="images/favicon.ico"/>
120         <title>Log - HA -</title>
121     </head>
122
123   <body class="normal">
124   <jsp:include page="menu.jsp" flush="false"/>
125   <div id="content">
126
127     <h1>Log - HA (Heartbeat2) -</h1>
128      <%
129     if ( (message != null) && (errorMessage != null) ) {
130     %>  
131             <p class="<%=resultJudge %>">[<%=category%>-<%=errorNumber%>]</p>
132             <p class="<%=resultJudge %>"><%=errorMessage%></p>
133     <%
134     } 
135     %>
136     
137     <h2> Download Log File</h2>
138     <h4>Please select the following list you would like to download the log file. </h4>
139
140       <table  class="infotable" cellspacing="0">
141
142       <tr>
143       <th>LogFileName</th><th>LastUpdate</th><th>FileSize(byte)</th>
144       </tr>
145       
146       <%
147                 SimpleDateFormat dfm = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss");
148                 NumberFormat num = NumberFormat.getInstance();
149         Iterator<LogFileData> i = logfiles.iterator();
150         
151         while ( i.hasNext() ){
152             LogFileData log = (LogFileData) i.next();
153             
154             if ( log != null && log.fileName != null){
155                    out.println("<tr>");
156                    out.println("<td>");
157                    out.println("<a href=\"LogOutputServlet?type=" + LogCategorySet.HA + "&log=" + log.fileName + "\">" + log.fileName + "</a>");
158                    out.println("</td>");
159                    out.println("<td class=\"center\">" + dfm.format(log.time) + "</td>");            
160                    out.println("<td class=\"right\">" + num.format(log.size) + "</td>");               
161                    out.println("</tr>");
162             }
163         }
164       %>     
165     </table>
166
167   </div>
168   </body>
169 </html>