From: Shinya TAKEBAYASHI Date: Mon, 20 Apr 2009 02:28:56 +0000 (+0900) Subject: Initial commit X-Git-Url: http://git.osdn.net/view?p=ultramonkey-l7%2Fl7gui.git;a=commitdiff_plain;h=b49cafc4bda7e2dcd0fa197d56a93b86c400244a Initial commit --- b49cafc4bda7e2dcd0fa197d56a93b86c400244a diff --git a/L7SyncCommand/l7vs/L7SyncCommand b/L7SyncCommand/l7vs/L7SyncCommand new file mode 100755 index 0000000..c249499 --- /dev/null +++ b/L7SyncCommand/l7vs/L7SyncCommand @@ -0,0 +1,7 @@ +#!/bin/sh + +SYNC_DIR=`dirname $0` +JAVA_HOME=/usr/java/jdk1.5.0_14 +CLASSPATH=${SYNC_DIR}/lib/log4j-1.2.13.jar:${SYNC_DIR}/lib/l7gui.jar:${SYNC_DIR}/lib/mail.jar + +${JAVA_HOME}/bin/java -classpath ${CLASSPATH} org.ultramonkey.l7.model.L7SyncCommand $* diff --git a/L7SyncCommand/l7vs/lib/l7gui.jar b/L7SyncCommand/l7vs/lib/l7gui.jar new file mode 100644 index 0000000..241081a Binary files /dev/null and b/L7SyncCommand/l7vs/lib/l7gui.jar differ diff --git a/L7SyncCommand/l7vs/lib/log4j-1.2.13.jar b/L7SyncCommand/l7vs/lib/log4j-1.2.13.jar new file mode 100644 index 0000000..393b505 Binary files /dev/null and b/L7SyncCommand/l7vs/lib/log4j-1.2.13.jar differ diff --git a/L7SyncCommand/l7vs/lib/mail.jar b/L7SyncCommand/l7vs/lib/mail.jar new file mode 100644 index 0000000..5954377 Binary files /dev/null and b/L7SyncCommand/l7vs/lib/mail.jar differ diff --git a/L7SyncCommand/xinetd.d/L7SyncCommand b/L7SyncCommand/xinetd.d/L7SyncCommand new file mode 100644 index 0000000..1a49a4d --- /dev/null +++ b/L7SyncCommand/xinetd.d/L7SyncCommand @@ -0,0 +1,13 @@ +# default: off +# description: The UltraMonkey-L7 sync server. +service L7SyncCommand +{ + socket_type = stream + wait = no + user = tomcat + server = /usr/local/l7vs/L7SyncCommand + server_args = -s + disable = no + port = 60000 + type = UNLISTED +} diff --git a/conf/l7gui-sample.cf b/conf/l7gui-sample.cf new file mode 100644 index 0000000..826a50e --- /dev/null +++ b/conf/l7gui-sample.cf @@ -0,0 +1,18 @@ +#==================================================================== +# l7gui.cf +#==================================================================== +#-------------------------------------------------------------------- +# sync settings +# actHost : IP address of this server used to synchronize +# sbyHost : IP address of peer server used to synchronize +# sbyPort : Port number of peer server used to synchronize +#-------------------------------------------------------------------- +#actHost=192.168.0.1 +#sbyHost=192.168.0.2 +#sbyPort=60000 + +#-------------------------------------------------------------------- +# l7gui session setting +# max_session_time : Session time-out seconds +#-------------------------------------------------------------------- +max_session_time=1200 diff --git a/conf/userdata.dat b/conf/userdata.dat new file mode 100644 index 0000000..de74311 Binary files /dev/null and b/conf/userdata.dat differ diff --git a/l7gui.war b/l7gui.war new file mode 100644 index 0000000..75d6142 Binary files /dev/null and b/l7gui.war differ diff --git a/src/.classpath b/src/.classpath new file mode 100644 index 0000000..8940e94 --- /dev/null +++ b/src/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/.project b/src/.project new file mode 100644 index 0000000..50d5048 --- /dev/null +++ b/src/.project @@ -0,0 +1,30 @@ + + + l7gui + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.jdt.core.javanature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jem.workbench.JavaEMFNature + + diff --git a/src/.settings/org.eclipse.jdt.core.prefs b/src/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..f198535 --- /dev/null +++ b/src/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +#Wed Apr 23 11:39:37 JST 2008 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/src/.settings/org.eclipse.jst.common.project.facet.core.prefs b/src/.settings/org.eclipse.jst.common.project.facet.core.prefs new file mode 100644 index 0000000..17a7a97 --- /dev/null +++ b/src/.settings/org.eclipse.jst.common.project.facet.core.prefs @@ -0,0 +1,4 @@ +#Wed Apr 23 11:39:39 JST 2008 +classpath.helper/org.eclipse.jdt.launching.JRE_CONTAINER/owners=jst.java\:5.0 +classpath.helper/org.eclipse.jst.server.core.container\:\:org.eclipse.jst.server.tomcat.runtimeTarget\:\:Apache\ Tomcat\ v5.5/owners=jst.web\:2.4 +eclipse.preferences.version=1 diff --git a/src/.settings/org.eclipse.jst.j2ee.ejb.annotations.xdoclet.prefs b/src/.settings/org.eclipse.jst.j2ee.ejb.annotations.xdoclet.prefs new file mode 100644 index 0000000..fcef433 --- /dev/null +++ b/src/.settings/org.eclipse.jst.j2ee.ejb.annotations.xdoclet.prefs @@ -0,0 +1,6 @@ +#Wed Apr 23 11:44:07 JST 2008 +XDOCLETBUILDERACTIVE=false +XDOCLETHOME= +XDOCLETUSEGLOBAL=false +XDOCLETVERSION=1.2.1 +eclipse.preferences.version=1 diff --git a/src/.settings/org.eclipse.wst.common.component b/src/.settings/org.eclipse.wst.common.component new file mode 100644 index 0000000..44f0fb8 --- /dev/null +++ b/src/.settings/org.eclipse.wst.common.component @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/src/.settings/org.eclipse.wst.common.project.facet.core.xml b/src/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 0000000..3ad96d2 --- /dev/null +++ b/src/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/WebContent/META-INF/MANIFEST.MF b/src/WebContent/META-INF/MANIFEST.MF new file mode 100644 index 0000000..59499bc --- /dev/null +++ b/src/WebContent/META-INF/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/src/WebContent/WEB-INF/lib/log4j-1.2.13.jar b/src/WebContent/WEB-INF/lib/log4j-1.2.13.jar new file mode 100644 index 0000000..393b505 Binary files /dev/null and b/src/WebContent/WEB-INF/lib/log4j-1.2.13.jar differ diff --git a/src/WebContent/WEB-INF/lib/mail.jar b/src/WebContent/WEB-INF/lib/mail.jar new file mode 100644 index 0000000..5954377 Binary files /dev/null and b/src/WebContent/WEB-INF/lib/mail.jar differ diff --git a/src/WebContent/WEB-INF/lib/tomcat5-servlet-2.4-api-5.5.23.jar b/src/WebContent/WEB-INF/lib/tomcat5-servlet-2.4-api-5.5.23.jar new file mode 100644 index 0000000..41df421 Binary files /dev/null and b/src/WebContent/WEB-INF/lib/tomcat5-servlet-2.4-api-5.5.23.jar differ diff --git a/src/WebContent/WEB-INF/web.xml b/src/WebContent/WEB-INF/web.xml new file mode 100644 index 0000000..98a3d4d --- /dev/null +++ b/src/WebContent/WEB-INF/web.xml @@ -0,0 +1,236 @@ + + + l7gui + + login servlet + LoginServlet + LoginServlet + org.ultramonkey.l7.view.LoginServlet + + user name despriction + UserName + + + + password description + Password + + + + + LoginServlet + /LoginServlet + + + index.html + index.jsp + + + + VirtualService add servlet + + VSAddServlet + VSAddServlet + + org.ultramonkey.l7.view.VSAddServlet + + + VSAddServlet + /VSAddServlet + + + + VirtualService remove servlet + + VSRemoveServlet + VSRemoveServlet + + org.ultramonkey.l7.view.VSRemoveServlet + + + VSRemoveServlet + /VSRemoveServlet + + + + VirtualService modify servlet + + VSModServlet + VSModServlet + + org.ultramonkey.l7.view.VSModServlet + + + + + + SoRun + SoRunServlet + + org.ultramonkey.l7.view.SoRunServlet + + + + + + SnmpAgentServlet + SnmpAgentServlet + + org.ultramonkey.l7.view.SnmpAgentServlet + + + + + + ReplicationModeChangeServlet + ReplicationModeChangeServlet + + org.ultramonkey.l7.view.ReplicationModeChangeServlet + + + + + + ReplicationInfoChangeServlet + ReplicationInfoChangeServlet + + org.ultramonkey.l7.view.ReplicationInfoChangeServlet + + + + + + ReplicationRunServlet + ReplicationRunServlet + + org.ultramonkey.l7.view.ReplicationRunServlet + + + + + + SaveStateServlet + SaveStateServlet + + org.ultramonkey.l7.view.SaveStateServlet + + + + + + UserModServlet + UserModServlet + + org.ultramonkey.l7.view.UserModServlet + + + + + + SyncStateServlet + SyncStateServlet + + org.ultramonkey.l7.view.SyncStateServlet + + + + + + UserAddServlet + UserAddServlet + + org.ultramonkey.l7.view.UserAddServlet + + + + + + UserRemoveServlet + UserRemoveServlet + + org.ultramonkey.l7.view.UserRemoveServlet + + + + + + LogOutputServlet + LogOutputServlet + + org.ultramonkey.l7.view.LogOutputServlet + + + + + + LogLevelServlet + LogLevelServlet + + org.ultramonkey.l7.view.LogLevelServlet + + + + + + MonitorSetServlet + MonitorSetServlet + + org.ultramonkey.l7.view.MonitorSetServlet + + + VSModServlet + /VSModServlet + + + SoRunServlet + /SoRunServlet + + + SnmpAgentServlet + /SnmpAgentServlet + + + ReplicationModeChangeServlet + /ReplicationModeChangeServlet + + + ReplicationInfoChangeServlet + /ReplicationInfoChangeServlet + + + ReplicationRunServlet + /ReplicationRunServlet + + + SaveStateServlet + /SaveStateServlet + + + UserModServlet + /UserModServlet + + + SyncStateServlet + /SyncStateServlet + + + UserAddServlet + /UserAddServlet + + + UserRemoveServlet + /UserRemoveServlet + + + LogOutputServlet + /LogOutputServlet + + + LogLevelServlet + /LogLevelServlet + + + MonitorSetServlet + /MonitorSetServlet + + diff --git a/src/WebContent/images/Monkey.gif b/src/WebContent/images/Monkey.gif new file mode 100644 index 0000000..d400e60 Binary files /dev/null and b/src/WebContent/images/Monkey.gif differ diff --git a/src/WebContent/images/UM-L7rogo.gif b/src/WebContent/images/UM-L7rogo.gif new file mode 100644 index 0000000..6c08a78 Binary files /dev/null and b/src/WebContent/images/UM-L7rogo.gif differ diff --git a/src/WebContent/images/arrowlogo1.gif b/src/WebContent/images/arrowlogo1.gif new file mode 100644 index 0000000..950eed9 Binary files /dev/null and b/src/WebContent/images/arrowlogo1.gif differ diff --git a/src/WebContent/images/arrowlogo2.gif b/src/WebContent/images/arrowlogo2.gif new file mode 100644 index 0000000..50ddfc8 Binary files /dev/null and b/src/WebContent/images/arrowlogo2.gif differ diff --git a/src/WebContent/images/exclamation1.gif b/src/WebContent/images/exclamation1.gif new file mode 100644 index 0000000..8298c28 Binary files /dev/null and b/src/WebContent/images/exclamation1.gif differ diff --git a/src/WebContent/images/exclamation2.gif b/src/WebContent/images/exclamation2.gif new file mode 100644 index 0000000..486d839 Binary files /dev/null and b/src/WebContent/images/exclamation2.gif differ diff --git a/src/WebContent/images/exclamation3.gif b/src/WebContent/images/exclamation3.gif new file mode 100644 index 0000000..7bf915e Binary files /dev/null and b/src/WebContent/images/exclamation3.gif differ diff --git a/src/WebContent/images/favicon.ico b/src/WebContent/images/favicon.ico new file mode 100644 index 0000000..d905437 Binary files /dev/null and b/src/WebContent/images/favicon.ico differ diff --git a/src/WebContent/images/minus.gif b/src/WebContent/images/minus.gif new file mode 100644 index 0000000..fda6c80 Binary files /dev/null and b/src/WebContent/images/minus.gif differ diff --git a/src/WebContent/images/monkey_wht.jpg b/src/WebContent/images/monkey_wht.jpg new file mode 100644 index 0000000..78f8926 Binary files /dev/null and b/src/WebContent/images/monkey_wht.jpg differ diff --git a/src/WebContent/images/plus.gif b/src/WebContent/images/plus.gif new file mode 100644 index 0000000..25fe99d Binary files /dev/null and b/src/WebContent/images/plus.gif differ diff --git a/src/WebContent/images/side_act.png b/src/WebContent/images/side_act.png new file mode 100644 index 0000000..ef398d9 Binary files /dev/null and b/src/WebContent/images/side_act.png differ diff --git a/src/WebContent/images/side_sby.png b/src/WebContent/images/side_sby.png new file mode 100644 index 0000000..6169f19 Binary files /dev/null and b/src/WebContent/images/side_sby.png differ diff --git a/src/WebContent/images/side_single.png b/src/WebContent/images/side_single.png new file mode 100644 index 0000000..aef5f80 Binary files /dev/null and b/src/WebContent/images/side_single.png differ diff --git a/src/WebContent/images/toAct.gif b/src/WebContent/images/toAct.gif new file mode 100644 index 0000000..b96f734 Binary files /dev/null and b/src/WebContent/images/toAct.gif differ diff --git a/src/WebContent/images/toSby.gif b/src/WebContent/images/toSby.gif new file mode 100644 index 0000000..1a42042 Binary files /dev/null and b/src/WebContent/images/toSby.gif differ diff --git a/src/WebContent/images/ultraMonkey-L7rogo.gif b/src/WebContent/images/ultraMonkey-L7rogo.gif new file mode 100644 index 0000000..8dd86b7 Binary files /dev/null and b/src/WebContent/images/ultraMonkey-L7rogo.gif differ diff --git a/src/WebContent/images/ultramonkey.gif b/src/WebContent/images/ultramonkey.gif new file mode 100644 index 0000000..8e2ac6e Binary files /dev/null and b/src/WebContent/images/ultramonkey.gif differ diff --git a/src/WebContent/index.jsp b/src/WebContent/index.jsp new file mode 100644 index 0000000..46535b3 --- /dev/null +++ b/src/WebContent/index.jsp @@ -0,0 +1,72 @@ +<%@ page import="org.ultramonkey.l7.model.*, org.ultramonkey.l7.controller.*, org.ultramonkey.l7.view.*" + language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> + + + + + + + + + + + + + + + Login + + + + + UltraMonkey-l7 logo + UltraMonkey-L7 graffic + + + +<% + MessageView mv = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE); + if (mv != null) { + String message = mv.getMessage(); + int errno = mv.getErrno(); + String category = mv.getCategory(); + out.println("

[" + category + "-" + errno + "] " + message + "

"); + } + session.invalidate(); +%> + + + + + + + + diff --git a/src/WebContent/l7gui.js b/src/WebContent/l7gui.js new file mode 100644 index 0000000..0d0f95e --- /dev/null +++ b/src/WebContent/l7gui.js @@ -0,0 +1,53 @@ +// button confirm messages +var add_vs_apply = 'Add a VirtualService(Apply) OK?\nDisable Monitor Settings!!\n'; +var add_vs_save = 'Add a VirtualService(Save) OK?\n'; +var add_vs_savesync = 'Add a VirtualService(Save+Sync) OK?\n'; +var modify_vs_apply = 'Modify a VirtualService(Apply) OK?\nDisable Monitor Settings!!\n'; +var modify_vs_save = 'Modify a VirtualService(Save) OK?\n'; +var modify_vs_savesync = 'Modify a VirtualService(Save+Sync) OK?\n'; +var remove_vs_apply = 'Remove a VirtualService(Apply) OK?\n'; +var remove_vs_save = 'Remove a VirtualService(Save) OK?\n'; +var remove_vs_savesync = 'Remove a VirtualService(Save+Sync) OK?'; +var monitor_modify_save = 'Modify Monitor Settings(Save) OK?\n'; +var monitor_modify_savesync = 'Modify Monitor Settings(Save+Sync) OK?\n'; +var switch_over = 'Run a Switch-over OK?\n'; +var replication_stop_send = 'Stopping Send Replication Data OK?\n'; +var replication_stop_receive = 'Stopping Receive Replication Data OK?\n'; +var replication_start_send = 'Sending Replication Data OK?\n'; +var replication_start_receive = 'Receiving Replication Data OK?\n'; +var replication_modify_save = 'Modify a Replication Status(Save) OK?\n'; +var replication_modify_savesync = 'Modify a Replication Status(Save+Sync) OK?\n'; +var replication_dump = 'Execute immediate Replication OK?\n'; +var save = 'Save OK?\n'; +var savesync = 'Save+Sync OK?\n'; +var snmp_save = 'Modify a SNMP Agent Interval(Save) OK?\n'; +var snmp_savesync = 'Modify a SNMP Agent Interval(Save+Sync) OK?\n'; +var log_lb_apply = 'Change Load balancer (l7vsd) Log Level (Apply) OK?\n'; +var log_lb_save = 'Change Load balancer (l7vsd) Log Level (Save) OK?\n'; +var log_lb_savesync = 'Change Load balancer (l7vsd) Log Level (Save+Sync) OK?\n'; +var log_adm_save = 'Change Admin command (l7vsadm) Log Level (Save) OK?\n'; +var log_adm_savesync = 'Change Admin command (l7vsadm) Log Level (Save+Sync) OK?\n' +var log_snmp_apply = 'Change SNMPAgent Log Level (Apply) OK?\n'; +var log_snmp_save = 'Change SNMPAgent Log Level (Save) OK?\n'; +var log_snmp_savesync = 'Change SNMPAgent Log Level (Save+Sync) OK?\n'; +var user_add = 'User Add OK?\n'; +var user_delete = 'User Delete OK?\n'; +var user_modify = 'Modify your info OK?\n'; +var logout = 'Logout OK?\n'; + +function openTree(name, img) { + menu = document.all[name].style; + if (menu.display == "none") { + menu.display = "block"; + img.src = "images/minus.gif"; + } + else { + menu.display = "none"; + img.src = "images/plus.gif"; + } +} + +function vs_modify(page) { + document.getElementById("vs_info").action = page; + document.vs_info.submit(); +} diff --git a/src/WebContent/l7gui_act_style.css b/src/WebContent/l7gui_act_style.css new file mode 100644 index 0000000..2725826 --- /dev/null +++ b/src/WebContent/l7gui_act_style.css @@ -0,0 +1,30 @@ +@import "l7gui_basic_style.css"; + +body.ref{ + /* ACT Color */ + background-color : #CCFFCC; + /* SBY Color */ + /* background-color : #CCCCCC; */ + /* SYNGLE Color */ + /* background-color : #FFCC99; */ + + /* background-color : #FFCC66; */ + /* background-color : #CCFFFF; */ +} + + +body.normal{ + background-color : #FFFFFF; + background-image : url(images/side_act.png); + background-position : left; + background-repeat : repeat-y; +} + +div#sidebar{ + background-color: #CCFFCC; + position: absolute; + top:0; + left:0; + width: 210px; +} + diff --git a/src/WebContent/l7gui_basic_style.css b/src/WebContent/l7gui_basic_style.css new file mode 100644 index 0000000..4b60c3a --- /dev/null +++ b/src/WebContent/l7gui_basic_style.css @@ -0,0 +1,431 @@ +body{ + font-family : Verdana, Arial, Helvetica, sans-serif; +} + +body.center{ + text-align: center; +} + +/* img */ +img{ + border: 0; +} + +img.top{ + margin-top : 15px; + margin-bottom : 1px; + margin-left : 3px; + margin-right : 3px; +} + + +img.arrow1{ + width:20px; + height:58px; + margin-left: 30px; +} + +img.arrow2{ + width:58px; + height:20px; + margin-left: 10px; + margin-right: 10px; +} + +input.topeer{ + margin-top : 10px; + margin-bottom : 5px; + margin-left: 10px; +} + +img.icon{ + margin : 3px; +} + + + + +/* link */ +a{ + color : #000066; + font-size : 110%; + font-weight : bold; +} + +a:visited{ + color: navy; + font-weight : bold; +} + +a:hover{ + color : #FF0066; + font-weight : bold; +} + +a.sub{ + font-size : 95%; + font-weight : bold; + margin-left : 20px; +} + + + + +h1{ + font-size : 200%; + font-weight : bold; + color : #ffffff; + background-color : #191970; + text-align : left; + margin-bottom : 50px; + padding-top : 10px; + padding-bottom : 10px; + padding-left : 20px; +} + +h2{ + font-size : 150%; + color : #191970; + padding-left: 10px; +} + +h2.menu{ + text-align: center; +} + +h3{ + font-size : 100%; + color : #000000; + text-indent : 10pt +} + + +h4{ + font-size : 80%; + color : #000000; + padding-top : 5px; + padding-bottom : 0px; + padding-left : 6px; + margin-top : 5px; + margin-bottom : 0px; + margin-left : 6px; +} + +h4.menu{ + color: #000000; + font-size: 80%; + font-weight:bold; +} + +h4.note{ + color: #FF0066; + font-weight:bold; + margin-left: 10px; + padding-left: 10px; +} + +table.loginStatus{ + margin : 10px; + margin-left:auto; + margin-right:auto; + border-collapse: collapse; + font-size: 80%; + cellspacing: 2; +} + + +table.loginStatus th, +table.loginStatus td{ + padding-top: 2px; + padding-bottom: 2px; + padding-left : 5px; + padding-right : 3px; + border: 5px solid white; +} + + +table.loginStatus th{ + background-repeat:no-repeat; + background-color: #FFFFCC; + font-weight : bolder; + text-align : left; + vertical-align : middle; + width: 200px; +} + +table.menu { + line-height : 150%; +} + +table.menu td{ + vertical-align: top; +} + +table.status td.bar { + color: #FFEBCD; + text-align: left; +} + + +table.infotable{ + border: 2px #000000 solid; + border-collapse: collapse; + font-size: 80%; + margin-bottom: 15px; + margin-top: 15px; + margin-left: 15px; +} + + +table.infotable th, +table.infotable td{ + border: 1px solid #000000; + padding: 3.0px 5.0px; +} + +table.infotable th.error, +table.infotable td.error{ + text-align: center; + background-color: #CCCCCC; + } + +table.infotable th.side_error, +table.infotable td.side_error{ + text-align: center; + background-color: #CCCCCC; + border-right: 2px solid #000000; + } + + +table.infotable th.ins, +table.infotable td.ins{ + text-align: center; + background-color: #CCFFCC; + } + +table.infotable th.side_ins, +table.infotable td.side_ins{ + text-align: center; + background-color: #CCFFCC; + border-right: 2px solid #000000; + } + + +table.infotable th{ + border-bottom: 3px double #000000; + background-color: #FFFFCC; + font-weight: bolder; + text-align: center; +} + +table.infotable th.center{ + background-color: #FFFFFF; + border-bottom: 3px double #000000; + font-weight: bolder; + text-align: center; +} + +table.infotable th.left{ + background-color: #FFFFCC;; + font-weight: bolder; + text-align: left; + border-bottom: 1px #000000; + +} + +table.infotable th.point{ + border-bottom: 3px double #000000; + border-right: 2px solid #000000; + font-weight: bolder; + text-align: center; +} + + +table.infotable th.head{ + border-bottom: 2px solid #000000; + border-right: 2px solid #000000; + font-weight: bolder; + text-align: center; +} + +table.infotable td.center{ + text-align: center; +} + +table.infotable td.left{ + text-align: left; +} + +table.infotable td.right{ + text-align: right; +} + + +table.infotable td.left_point{ + border-right: 2px solid #000000; + font-weight: bolder; + text-align: center; +} + + +table.infotable td.null{ + width: 200px; +} + +table.infotable td.point{ + text-align: center; + border-right: 2px solid #000000; +} + +table.status{ + /*border: 2px #000000 solid; */ + border-collapse: collapse; + font-size: 80%; + cellspacing: 2; + margin : 10px; +} + + +table.status th, +table.status td{ + padding-top: 2px; + padding-bottom: 2px; + padding-left : 5px; + padding-right : 3px; + border: 5px solid white; +} + + +table.status th{ + background-repeat:no-repeat; + background-color: #FFFFCC; + font-weight : bolder; + text-align : left; + vertical-align : middle; + width: 200px; +} + +table.status th.check{ + background-repeat:no-repeat; + background-color: #FFFFCC; + font-weight : bolder; + text-align : left; + vertical-align : middle; + width: 165px; +} + +table.status td{ + text-align : left; + vertical-align : middle; + width : 200px; +} + + +table.status td.check{ + background-color: #FFFFCC; + text-align : center; + vertical-align : middle; + width : 30px; +} + +div#container{ + position: relative; + width: 100%; +} + + +div#content{ + margin-left: 210px; +} + + + +p{ + margin: 0 0 0.75em,0; + padding: 0; +} + + +p.success{ + color : #191970; + font-size : 80%; + font-style: italic; + font-weight:bold; +} + + +p.error{ + color : #FF0000; + font-size : 80%; + font-style: italic; + font-weight:bold; +} + +p.caution{ + color : #FF0000; + font-size : 80%; + font-style: italic; + font-weight:bold; + margin-left: 30px; + margin-top: 10px; +} + + +p.invalid{ + color : #FF0000; + font-style: italic; + font-size : 85%; + font-weight:bold; +} + +p.required{ + color : #191970; + font-style: italic; + font-size : 85%; +/* font-weight:bold; */ + line-height: 95% +} + +p.item{ + color : #FF0000; + font-size : 80%; + font-style: italic; + font-weight:bold; + line-height: 95% +} + +p.text{ + color : #000000; + font-size : 100%; +} + +fieldset{ + padding: 5px; + border: 2px dashed #191970; + margin-bottom: 10px; + margin-top: 10px; +} + +fieldset legend{ + padding: 10px; + font-size: 100%; + font-weight: bold; + color: #FFFFFF; + background-color: #191970; +} + + +input.menu{ + vertical-align: middle; + margin: -1px -1px 5px 0px; +} + +input.read{ + vertical-align: middle; + background-color: #CCCCCC; +} + +select.read{ + vertical-align: middle; + background-color: #CCCCCC; +} \ No newline at end of file diff --git a/src/WebContent/l7gui_sby_style.css b/src/WebContent/l7gui_sby_style.css new file mode 100644 index 0000000..a5d4d5e --- /dev/null +++ b/src/WebContent/l7gui_sby_style.css @@ -0,0 +1,32 @@ +@import "l7gui_basic_style.css"; + + +body.ref{ + /* ACT Color */ + /*background-color : #CCFFCC;*/ + /* SBY Color */ + background-color : #CCCCCC; + /* SYNGLE Color */ + /* background-color : #FFCC99; */ + + /* background-color : #FFCC66; */ + /* background-color : #CCFFFF; */ +} + + +body.normal{ + background-color : #FFFFFF; + background-image : url(images/side_sby.png); + background-position : left; + background-repeat : repeat-y; +} + + +div#sidebar{ + background-color: #CCCCCC; /* sby color */ + position: absolute; + top:0; + left:0; + width: 210px; +} + diff --git a/src/WebContent/l7gui_single_style.css b/src/WebContent/l7gui_single_style.css new file mode 100644 index 0000000..6531e9e --- /dev/null +++ b/src/WebContent/l7gui_single_style.css @@ -0,0 +1,30 @@ +@import "l7gui_basic_style.css"; + +body.ref{ + /* ACT Color */ + /* background-color : #CCFFCC; */ + /* SBY Color */ + /* background-color : #CCCCCC; */ + /* SYNGLE Color */ + background-color : #FFCCCC; + + /* background-color : #FFCC66; */ + /* background-color : #CCFFFF; */ +} + + +body.normal{ + background-color : #FFFFFF; + background-image : url(images/side_single.png); + background-position : left; + background-repeat : repeat-y; +} + + +div#sidebar{ + background-color: #FFCCCC; + position: absolute; + top:0; + left:0; + width: 210px; +} diff --git a/src/WebContent/log_adm.jsp b/src/WebContent/log_adm.jsp new file mode 100644 index 0000000..8164703 --- /dev/null +++ b/src/WebContent/log_adm.jsp @@ -0,0 +1,261 @@ +<%@ page import="org.ultramonkey.l7.model.*, + org.ultramonkey.l7.controller.*, + org.ultramonkey.l7.view.*, java.util.*, + java.text.SimpleDateFormat,java.text.NumberFormat" + language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<% + /* + * check session + */ + if (session.isNew()) { + MessageView error = new MessageView(41255, LogCategorySet.GUI_USER_AUTHENTICATION, Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get result message + */ + MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE); + String errorMessage = ""; + int errorNumber = 0; + String category = ""; + String resultJudge = "success"; + if (message != null) { + errorMessage = message.getMessage(); + errorNumber = message.getErrno(); + category = message.getCategory(); + session.setAttribute(SessionKeys.RESULT_MESSAGE, null); + if ( errorNumber >= ErrNo.ERRORNUMBER ) + resultJudge = "error"; + } + + /* + * get command message + */ + MessageView commandmessage = (MessageView) session.getAttribute(SessionKeys.COMMAND_MESSAGE); + String commandMessage = ""; + int commandNumber = 0; + String commandCategory = ""; + String commandJudge = "success"; + if (commandmessage != null) { + commandMessage = commandmessage.getMessage(); + commandNumber = commandmessage.getErrno(); + commandCategory = commandmessage.getCategory(); + session.setAttribute(SessionKeys.COMMAND_MESSAGE, null); + if ( commandNumber >= ErrNo.ERRORNUMBER ) + commandJudge = "error"; + } + + /* + * get adm_log info + */ + L7guiFramework framework = new L7guiFramework(); + LogData logdata = framework.getLogData(); + + if (logdata == null){ + MessageView error = new MessageView(41256, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + LogSet data = logdata.admLog; + + if (data == null){ + MessageView error = new MessageView(41257, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + Vector logfiles = data.logFiles; + if (logfiles == null){ + MessageView error = new MessageView(41258, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + HashMap logcategoryset = data.logLevel; + if (logcategoryset == null){ + MessageView error = new MessageView(41259, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get cluster status + */ + ClusterData cd = framework.getClusterData(); + + if (cd == null){ + MessageView error = new MessageView(41260, LogCategorySet.GUI_IO_COMMAND, Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + } + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if ( cd.self_status == ClusterStatus.ACTIVE ){ + cssSeat = "l7gui_act_style.css"; + } + else if ( cd.self_status == ClusterStatus.STANDBY ){ + cssSeat = "l7gui_sby_style.css"; + } + +%> + + + + + + + + + + + + + + + + + Log - Admin command (l7vsadm) - + + + + + +
+ + +

Log - Admin command (l7vsadm) -

+ <% + if ( (message != null ) && (errorMessage != null) ) { + %> + +

[<%=category%>-<%=errorNumber%>]

+

<%=errorMessage%>

+ + <% + } else if ( (commandmessage != null) && (commandMessage != null) ) { + %> +

[<%=commandCategory%>-<%=commandNumber%>]

+

<%=commandMessage%>

+ <% + } + %> + +

Download Log File

+

Please select the following list you would like to download the log file.

+ + + + + + + <% + SimpleDateFormat dfm = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss"); + NumberFormat num = NumberFormat.getInstance(); + Iterator i = logfiles.iterator(); + + while ( i.hasNext() ){ + LogFileData log = (LogFileData) i.next(); + + if ( log != null && log.fileName != null){ + out.println(""); + out.println(""); + out.println(""); + out.println(""); + out.println(""); + } + } + %> +
LogFileNameLastUpdateFileSize(byte)
"); + out.println("" + log.fileName + ""); + out.println("" + dfm.format(log.time) + "" + num.format(log.size) + "
+ +
+ +

Change Log Level

+

Please select log level you would like to change.

+ +
+ + + + + + + <% + TreeSet tree = new TreeSet(logcategoryset.keySet()); + Iterator it = tree.iterator(); + + while (it.hasNext()) { + LogData.LogCategory logcategory = (LogData.LogCategory) it.next(); + + if (logcategory != null){ + %> + + + + + <% + } + } + %> +
CategoryLevel
<%= logcategory %> + +
+ +
+ + <% + if (cd.self_status == ClusterStatus.ACTIVE || cd.self_status == ClusterStatus.STANDBY) { + %> + + <% + } + %> +
+ +
+ + \ No newline at end of file diff --git a/src/WebContent/log_directord.jsp b/src/WebContent/log_directord.jsp new file mode 100644 index 0000000..2b23ed0 --- /dev/null +++ b/src/WebContent/log_directord.jsp @@ -0,0 +1,156 @@ +<%@ page import="org.ultramonkey.l7.model.*, + org.ultramonkey.l7.controller.*, + org.ultramonkey.l7.view.*, java.util.*, + java.text.SimpleDateFormat,java.text.NumberFormat" + language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<% + /* + * check session + */ + if (session.isNew()) { + MessageView error = new MessageView(41261, LogCategorySet.GUI_USER_AUTHENTICATION, Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get result message + */ + MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE); + String errorMessage = ""; + int errorNumber = 0; + String category = ""; + String resultJudge = "success"; + if (message != null) { + errorMessage = message.getMessage(); + errorNumber = message.getErrno(); + category = message.getCategory(); + session.setAttribute(SessionKeys.RESULT_MESSAGE, null); + if ( errorNumber >= ErrNo.ERRORNUMBER ) + resultJudge = "error"; + } + + + /* + * get directord_log info + */ + L7guiFramework framework = new L7guiFramework(); + LogData logdata = framework.getLogData(); + + if (logdata == null){ + MessageView error = new MessageView(41262, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + LogSet data = logdata.directorLog; + + if (data == null){ + MessageView error = new MessageView(41263, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + Vector logfiles = data.logFiles; + if (logfiles == null){ + MessageView error = new MessageView(41264, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + + /* + * get cluster status + */ + ClusterData cd = framework.getClusterData(); + + if (cd == null){ + MessageView error = new MessageView(41265, LogCategorySet.GUI_IO_COMMAND, Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + } + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if ( cd.self_status == ClusterStatus.ACTIVE ){ + cssSeat = "l7gui_act_style.css"; + } + else if ( cd.self_status == ClusterStatus.STANDBY ){ + cssSeat = "l7gui_sby_style.css"; + } + +%> + + + + + + + + + + + + + + + + + Log - Moniter RealServer (l7directord) - + + + + +
+ +

Log - Moniter RealServer (l7directord) -

+ <% + if ( (message != null) && (errorMessage != null) ) { + %> +

[<%=category%>-<%=errorNumber%>]

+

<%=errorMessage%>

+ <% + } + %> + +

Download Log File

+

Please select the following list you would like to download the log file.

+ + + + + + + <% + SimpleDateFormat dfm = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss"); + NumberFormat num = NumberFormat.getInstance(); + Iterator i = logfiles.iterator(); + + while ( i.hasNext() ){ + LogFileData log = (LogFileData) i.next(); + + if ( log != null && log.fileName != null){ + + out.println(""); + out.println(""); + out.println(""); + out.println(""); + out.println(""); + } + } + %> +
LogFileNameLastUpdateFileSize(byte)
"); + out.println("" + log.fileName + ""); + out.println("" + dfm.format(log.time) + "" + num.format(log.size) + "
+ +
+ + diff --git a/src/WebContent/log_gui.jsp b/src/WebContent/log_gui.jsp new file mode 100644 index 0000000..769909d --- /dev/null +++ b/src/WebContent/log_gui.jsp @@ -0,0 +1,207 @@ +<%@ page import="org.ultramonkey.l7.model.*, + org.ultramonkey.l7.controller.*, + org.ultramonkey.l7.view.*, java.util.*, + java.text.SimpleDateFormat,java.text.NumberFormat" + language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<% + /* + * check session + */ + if (session.isNew()) { + MessageView error = new MessageView(41266, LogCategorySet.GUI_USER_AUTHENTICATION, Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get result message + */ + MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE); + String errorMessage = ""; + int errorNumber = 0; + String category = ""; + String resultJudge = "success"; + if (message != null) { + errorMessage = message.getMessage(); + errorNumber = message.getErrno(); + category = message.getCategory(); + session.setAttribute(SessionKeys.RESULT_MESSAGE, null); + if ( errorNumber >= ErrNo.ERRORNUMBER ) + resultJudge = "error"; + } + + /* + * get gui_log info + */ + L7guiFramework framework = new L7guiFramework(); + LogData logdata = framework.getLogData(); + + if (logdata == null){ + MessageView error = new MessageView(41267, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + LogSet data = logdata.guiLog; + + if (data == null){ + MessageView error = new MessageView(41268, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + Vector logfiles = data.logFiles; + if (logfiles == null){ + MessageView error = new MessageView(41269, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + HashMap logcategoryset = data.logLevel; + if (logcategoryset == null){ + MessageView error = new MessageView(41270, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get cluster status + */ + ClusterData cd = framework.getClusterData(); + + if (cd == null){ + MessageView error = new MessageView(41271, LogCategorySet.GUI_IO_COMMAND, Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + } + + /* + * get log4j properties data + */ + Enumeration loggers = (Enumeration) Logger.getRootLogger().getLoggerRepository().getCurrentLoggers(); + TreeMap levelMap = new TreeMap(); + while (loggers.hasMoreElements()) { + Logger logger = loggers.nextElement(); + if (logger.getLevel() != null) + levelMap.put(logger.getName(), logger.getLevel().toString()); + else if (Logger.getRootLogger().getLevel() != null) + levelMap.put(logger.getName(), Logger.getRootLogger().getLevel().toString()); + else + levelMap.put(logger.getName(), null); + } + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if ( cd.self_status == ClusterStatus.ACTIVE ){ + cssSeat = "l7gui_act_style.css"; + } + else if ( cd.self_status == ClusterStatus.STANDBY ){ + cssSeat = "l7gui_sby_style.css"; + } + +%> + + + +<%@page import="org.apache.log4j.Hierarchy"%> +<%@page import="org.apache.log4j.Logger"%> + + + + + + + + + + + + + Log - GUI (l7gui) - + + + + +
+ +

Log - GUI (l7gui) -

+ <% + if ( (message != null) && (errorMessage != null) ) { + %> +

[<%=category%>-<%=errorNumber%>]

+

<%=errorMessage%>

+ <% + } + %> + +

Download Log File

+

Please select the following list you would like to download the log file.

+ + + + + + + + <% + SimpleDateFormat dfm = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss"); + NumberFormat num = NumberFormat.getInstance(); + Iterator i = logfiles.iterator(); + while ( i.hasNext() ){ + LogFileData log = (LogFileData) i.next(); + + if ( log != null && log.fileName != null){ + out.println(""); + out.println(""); + out.println(""); + out.println(""); + out.println(""); + } + } + %> +
LogFileNameLastUpdateFileSize(byte)
"); + out.println("" + log.fileName + ""); + out.println("" + dfm.format(log.time) + "" + num.format(log.size) + "
+ +
+ + +

Current Log Level

+ +
+ + + + + + + <% + Iterator it = levelMap.keySet().iterator(); + while (it.hasNext()) { + String cat = it.next(); + if (! cat.matches("^l7gui.*$")) + continue; + %> + + + + + <% + } + %> +
CategoryLevel
<%= cat %><%= levelMap.get(cat) %>
+ +
+ +
+ + \ No newline at end of file diff --git a/src/WebContent/log_ha.jsp b/src/WebContent/log_ha.jsp new file mode 100644 index 0000000..c1d1533 --- /dev/null +++ b/src/WebContent/log_ha.jsp @@ -0,0 +1,169 @@ +<%@ page import="org.ultramonkey.l7.model.*, + org.ultramonkey.l7.controller.*, + org.ultramonkey.l7.view.*, java.util.*, + java.text.SimpleDateFormat,java.text.NumberFormat" + language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<% + /* + * check session + */ + if (session.isNew()) { + MessageView error = new MessageView(41272, LogCategorySet.GUI_USER_AUTHENTICATION, Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get result message + */ + MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE); + String errorMessage = ""; + int errorNumber = 0; + String category = ""; + String resultJudge = "success"; + if (message != null) { + errorMessage = message.getMessage(); + errorNumber = message.getErrno(); + category = message.getCategory(); + session.setAttribute(SessionKeys.RESULT_MESSAGE, null); + if ( errorNumber >= ErrNo.ERRORNUMBER ) + resultJudge = "error"; + } + + /* + * get command message + */ + MessageView commandmessage = (MessageView) session.getAttribute(SessionKeys.COMMAND_MESSAGE); + String commandMessage = ""; + int commandNumber = 0; + String commandCategory = ""; + if (commandmessage != null) { + commandMessage = commandmessage.getMessage(); + commandNumber = commandmessage.getErrno(); + commandCategory = commandmessage.getCategory(); + session.setAttribute(SessionKeys.COMMAND_MESSAGE, null); + } + + /* + * get ha_log info + */ + L7guiFramework framework = new L7guiFramework(); + LogData logdata = framework.getLogData(); + + if (logdata == null){ + MessageView error = new MessageView(41273, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + LogSet data = logdata.haLog; + + if (data == null){ + MessageView error = new MessageView(41274, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + Vector logfiles = data.logFiles; + if (logfiles == null){ + MessageView error = new MessageView(41275, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + + /* + * get cluster status + */ + ClusterData cd = framework.getClusterData(); + + if (cd == null){ + MessageView error = new MessageView(41276, LogCategorySet.GUI_IO_COMMAND, Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + } + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if ( cd.self_status == ClusterStatus.ACTIVE ){ + cssSeat = "l7gui_act_style.css"; + } + else if ( cd.self_status == ClusterStatus.STANDBY ){ + cssSeat = "l7gui_sby_style.css"; + } + +%> + + + + + + + + + + + + + + + + + Log - HA - + + + + +
+ +

Log - HA (Heartbeat2) -

+ <% + if ( (message != null) && (errorMessage != null) ) { + %> +

[<%=category%>-<%=errorNumber%>]

+

<%=errorMessage%>

+ <% + } + %> + +

Download Log File

+

Please select the following list you would like to download the log file.

+ + + + + + + + <% + SimpleDateFormat dfm = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss"); + NumberFormat num = NumberFormat.getInstance(); + Iterator i = logfiles.iterator(); + + while ( i.hasNext() ){ + LogFileData log = (LogFileData) i.next(); + + if ( log != null && log.fileName != null){ + out.println(""); + out.println(""); + out.println(""); + out.println(""); + out.println(""); + } + } + %> +
LogFileNameLastUpdateFileSize(byte)
"); + out.println("" + log.fileName + ""); + out.println("" + dfm.format(log.time) + "" + num.format(log.size) + "
+ +
+ + diff --git a/src/WebContent/log_lb.jsp b/src/WebContent/log_lb.jsp new file mode 100644 index 0000000..c41f44f --- /dev/null +++ b/src/WebContent/log_lb.jsp @@ -0,0 +1,255 @@ +<%@ page import="org.ultramonkey.l7.model.*, + org.ultramonkey.l7.controller.*, + org.ultramonkey.l7.view.*, java.util.*, + java.text.SimpleDateFormat,java.text.NumberFormat" + language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> + +<% + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41277, LogCategorySet.GUI_USER_AUTHENTICATION, Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get result message + */ + MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE); + String errorMessage = ""; + int errorNumber = 0; + String category = ""; + String resultJudge = "success"; + if (message != null) { + errorMessage = message.getMessage(); + errorNumber = message.getErrno(); + category = message.getCategory(); + session.setAttribute(SessionKeys.RESULT_MESSAGE, null); + if ( errorNumber >= ErrNo.ERRORNUMBER ) + resultJudge = "error"; + } + + /* + * get command message + */ + MessageView commandmessage = (MessageView) session.getAttribute(SessionKeys.COMMAND_MESSAGE); + String commandMessage = ""; + int commandNumber = 0; + String commandCategory = ""; + String commandJudge = "success"; + if (commandmessage != null) { + commandMessage = commandmessage.getMessage(); + commandNumber = commandmessage.getErrno(); + commandCategory = commandmessage.getCategory(); + session.setAttribute(SessionKeys.COMMAND_MESSAGE, null); + if ( commandNumber >= ErrNo.ERRORNUMBER ) + commandJudge = "error"; + } + + /* + * get lb_log info + */ + L7guiFramework framework = new L7guiFramework(); + LogData logdata = framework.getLogData(); + if (logdata == null){ + MessageView error = new MessageView(41278, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + LogSet lbdata = logdata.lbLog; + if (lbdata == null){ + MessageView error = new MessageView(41279, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + Vector lblogfiles = lbdata.logFiles; + if (lblogfiles == null){ + MessageView error = new MessageView(41280, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + HashMap lblogcategoryset = lbdata.logLevel; + if (lblogcategoryset == null){ + MessageView error = new MessageView(41281, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get cluster status + */ + ClusterData cd = framework.getClusterData(); + if (cd == null){ + MessageView error = new MessageView(41282, LogCategorySet.GUI_IO_COMMAND, Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + } + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if ( cd.self_status == ClusterStatus.ACTIVE ){ + cssSeat = "l7gui_act_style.css"; + } + else if ( cd.self_status == ClusterStatus.STANDBY ){ + cssSeat = "l7gui_sby_style.css"; + } + %> + + + + + + + + + + + + + + + + + Log - Load balancer (l7vsd) - + + + + +
+ +

Log - Load balancer (l7vsd) -

+ <% + if ( (message != null ) && (errorMessage != null) ) { + %> + +

[<%=category%>-<%=errorNumber%>]

+

<%=errorMessage%>

+ + <% + } else if ( (commandmessage != null) && (commandMessage != null) ) { + %> +

[<%=commandCategory%>-<%=commandNumber%>]

+

<%=commandMessage%>

+ <% + } + %> + +

Download Log file

+

Please select the following log file you would like to download.

+ + + + + +<% + SimpleDateFormat dfm = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss"); + NumberFormat num = NumberFormat.getInstance(); + Iterator i = lblogfiles.iterator(); + + while ( i.hasNext() ){ + LogFileData log = (LogFileData) i.next(); + if ( log != null && log.fileName != null){ + out.println(""); + out.println(""); + out.println(""); + out.println(""); + out.println(""); + } + } +%> +
LogFileNameLastUpdateFileSize(byte)
"); + out.println("" + log.fileName + ""); + out.println("" + dfm.format(log.time) + "" + num.format(log.size) + "
+ +
+ +

Change Log Level

+

Please select log level of you would like to change.

+ +
+ + + + + + <% + TreeSet tree = new TreeSet(lblogcategoryset.keySet()); + Iterator it = tree.iterator(); + while (it.hasNext()) { + LogData.LogCategory logcategory = (LogData.LogCategory) it.next(); + if (logcategory != null){ + %> + + + + + <% + } + } + %> +
CategoryLevel
<%= logcategory %> + +
+ +
+ + + + + <% + if (cd.self_status == ClusterStatus.ACTIVE || cd.self_status == ClusterStatus.STANDBY) { + %> + + <% + } + %> +
+ +
+ + \ No newline at end of file diff --git a/src/WebContent/log_level_executive.jsp b/src/WebContent/log_level_executive.jsp new file mode 100644 index 0000000..ad8ad70 --- /dev/null +++ b/src/WebContent/log_level_executive.jsp @@ -0,0 +1,133 @@ +<%@ page + import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*" + language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + +<% + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41283, + LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get sessionTrans + */ + SessionTransData sessionTrans = (SessionTransData) session + .getAttribute(SessionKeys.PAGE_TRANSDATA); + String successpage = ""; + String failpage = ""; + if (sessionTrans == null) { + MessageView error = new MessageView(41284, LogCategorySet.GUI_LOG, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + successpage = sessionTrans.destURI; + failpage = sessionTrans.errorURI; + if ((successpage == null) || (failpage == null)) { + MessageView error = new MessageView(41285, LogCategorySet.GUI_LOG, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get thread status + */ + String threadStatus = (String) session + .getAttribute(SessionKeys.THREAD_STATUS); + if (threadStatus == null) { + MessageView error = new MessageView(41286, LogCategorySet.GUI_LOG, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + if (threadStatus.equals(SessionKeys.THREAD_SUCCESS)) { + response.sendRedirect(successpage); + return; + } else if (threadStatus.equals(SessionKeys.THREAD_RUNNING)) { + // + } else if (threadStatus.equals(SessionKeys.THREAD_FAIL)) { + response.sendRedirect(failpage); + return; + } else { + MessageView error = new MessageView(41287, LogCategorySet.GUI_LOG, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get sourcepage + */ + String logname = ""; + String sourcepage = ""; + sourcepage = sessionTrans.sourceURI; + + if (sourcepage == null) { + MessageView error = new MessageView(41288, LogCategorySet.GUI_LOG, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + if (sourcepage.equals("log_lb.jsp")) { + logname = "Load balancer"; + } else if (sourcepage.equals("log_adm.jsp")) { + logname = "Admin command"; + } else if (sourcepage.equals("log_snmp.jsp")) { + logname = "SNMP Agent"; + } else if (sourcepage.equals("log_gui.jsp")) { + logname = "GUI"; + } else if (sourcepage.equals("log_sync.jsp")) { + logname = "Sync Resource"; + } else { + MessageView error = new MessageView(41289, LogCategorySet.GUI_LOG, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } +%> + + + + + + + + + + + + + + + + + Changing Log Level + + + +

Changing Log Level

+

Please wait.

+ + + diff --git a/src/WebContent/log_snmp.jsp b/src/WebContent/log_snmp.jsp new file mode 100644 index 0000000..fa27982 --- /dev/null +++ b/src/WebContent/log_snmp.jsp @@ -0,0 +1,266 @@ +<%@ page import="org.ultramonkey.l7.model.*, + org.ultramonkey.l7.controller.*, + org.ultramonkey.l7.view.*, java.util.*, + java.text.SimpleDateFormat,java.text.NumberFormat" + language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> + +<% + /* + * check session + */ + if (session.isNew()) { + MessageView error = new MessageView(41290, LogCategorySet.GUI_USER_AUTHENTICATION, Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get result message + */ + MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE); + String errorMessage = ""; + int errorNumber = 0; + String category = ""; + String resultJudge = "success"; + if (message != null) { + errorMessage = message.getMessage(); + errorNumber = message.getErrno(); + category = message.getCategory(); + session.setAttribute(SessionKeys.RESULT_MESSAGE, null); + if ( errorNumber >= ErrNo.ERRORNUMBER ) + resultJudge = "error"; + } + + /* + * get command message + */ + MessageView commandmessage = (MessageView) session.getAttribute(SessionKeys.COMMAND_MESSAGE); + String commandMessage = ""; + int commandNumber = 0; + String commandCategory = ""; + String commandJudge = "success"; + if (commandmessage != null) { + commandMessage = commandmessage.getMessage(); + commandNumber = commandmessage.getErrno(); + commandCategory = commandmessage.getCategory(); + session.setAttribute(SessionKeys.COMMAND_MESSAGE, null); + if ( commandNumber >= ErrNo.ERRORNUMBER ) + commandJudge = "error"; + } + + /* + * get snmp_log info + */ + L7guiFramework framework = new L7guiFramework(); + LogData logdata = framework.getLogData(); + + if (logdata == null){ + MessageView error = new MessageView(41291, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + LogSet data = logdata.snmpLog; + + if (data == null){ + MessageView error = new MessageView(41292, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + Vector logfiles = data.logFiles; + if (logfiles == null){ + MessageView error = new MessageView(41293, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + HashMap logcategoryset = data.logLevel; + if (logcategoryset == null){ + MessageView error = new MessageView(41294, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get cluster status + */ + ClusterData cd = framework.getClusterData(); + + if (cd == null){ + MessageView error = new MessageView(41295, LogCategorySet.GUI_IO_COMMAND, Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + } + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if ( cd.self_status == ClusterStatus.ACTIVE ){ + cssSeat = "l7gui_act_style.css"; + } + else if ( cd.self_status == ClusterStatus.STANDBY ){ + cssSeat = "l7gui_sby_style.css"; + } + +%> + + + + + + + + + + + + + + + Log - SNMPAgent - + + + + + + +
+ +

Log - SNMPAgent -

+ <% + if ( (message != null ) && (errorMessage != null) ) { + %> + +

[<%=category%>-<%=errorNumber%>]

+

<%=errorMessage%>

+ + <% + } else if ( (commandmessage != null) && (commandMessage != null) ) { + %> +

[<%=commandCategory%>-<%=commandNumber%>]

+

<%=commandMessage%>

+ <% + } + %> + +

Download Log File

+

Please select the following list you would like to download the log file.

+ + + + + + + + <% + SimpleDateFormat dfm = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss"); + NumberFormat num = NumberFormat.getInstance(); + Iterator i = logfiles.iterator(); + + while ( i.hasNext() ){ + LogFileData log = (LogFileData) i.next(); + + if ( log != null && log.fileName != null){ + out.println(""); + out.println(""); + out.println(""); + out.println(""); + out.println(""); + } + } + %> + +
LogFileNameLastUpdateFileSize(byte)
"); + out.println("" + log.fileName + ""); + out.println("" + dfm.format(log.time) + "" + num.format(log.size) + "
+ + +
+ +

Change Log Level

+

Please select log level you would like to change.

+ +
+ + + + + + + + <% + TreeSet tree = new TreeSet(logcategoryset.keySet()); + Iterator it = tree.iterator(); + + while (it.hasNext()) { + LogData.LogCategory logcategory = (LogData.LogCategory) it.next(); + + if (logcategory != null){ + %> + + + + + <% + } + } + %> +
CategoryLevel
<%= logcategory %> + +
+ +
+ + + + <% + if (cd.self_status == ClusterStatus.ACTIVE || cd.self_status == ClusterStatus.STANDBY) { + %> + + <% + } + %> +
+ +
+ + \ No newline at end of file diff --git a/src/WebContent/log_sync.jsp b/src/WebContent/log_sync.jsp new file mode 100644 index 0000000..ee8ad57 --- /dev/null +++ b/src/WebContent/log_sync.jsp @@ -0,0 +1,220 @@ +<%@ page import="org.ultramonkey.l7.model.*, + org.ultramonkey.l7.controller.*, + org.ultramonkey.l7.view.*, java.util.*, + java.text.SimpleDateFormat,java.text.NumberFormat" + language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<% + /* + * check session + */ + if (session.isNew()) { + MessageView error = new MessageView(41296, LogCategorySet.GUI_USER_AUTHENTICATION, Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get result message + */ + MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE); + String errorMessage = ""; + int errorNumber = 0; + String category = ""; + String resultJudge = "success"; + if (message != null) { + errorMessage = message.getMessage(); + errorNumber = message.getErrno(); + category = message.getCategory(); + session.setAttribute(SessionKeys.RESULT_MESSAGE, null); + if ( errorNumber >= ErrNo.ERRORNUMBER ) + resultJudge = "error"; + } + + /* + * get command message + */ + MessageView commandmessage = (MessageView) session.getAttribute(SessionKeys.COMMAND_MESSAGE); + String commandMessage = ""; + int commandNumber = 0; + String commandCategory = ""; + if (commandmessage != null) { + commandMessage = commandmessage.getMessage(); + commandNumber = commandmessage.getErrno(); + commandCategory = commandmessage.getCategory(); + session.setAttribute(SessionKeys.COMMAND_MESSAGE, null); + } + + /* + * get sync_log info + */ + L7guiFramework framework = new L7guiFramework(); + LogData logdata = framework.getLogData(); + + if (logdata == null){ + MessageView error = new MessageView(41297, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + LogSet data = logdata.syncLog; + + if (data == null){ + MessageView error = new MessageView(41298, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + Vector logfiles = data.logFiles; + if (logfiles == null){ + MessageView error = new MessageView(41299, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + HashMap logcategoryset = data.logLevel; + if (logcategoryset == null){ + MessageView error = new MessageView(41300, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get cluster status + */ + ClusterData cd = framework.getClusterData(); + + if (cd == null){ + MessageView error = new MessageView(41301, LogCategorySet.GUI_IO_COMMAND, Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + } + + /* + * get log4j properties data + */ + Enumeration loggers = (Enumeration) Logger.getRootLogger().getLoggerRepository().getCurrentLoggers(); + TreeMap levelMap = new TreeMap(); + while (loggers.hasMoreElements()) { + Logger logger = loggers.nextElement(); + if (logger.getLevel() != null) + levelMap.put(logger.getName(), logger.getLevel().toString()); + else if (Logger.getRootLogger().getLevel() != null) + levelMap.put(logger.getName(), Logger.getRootLogger().getLevel().toString()); + else + levelMap.put(logger.getName(), null); + } + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if ( cd.self_status == ClusterStatus.ACTIVE ){ + cssSeat = "l7gui_act_style.css"; + } + else if ( cd.self_status == ClusterStatus.STANDBY ){ + cssSeat = "l7gui_sby_style.css"; + } + +%> + + + +<%@page import="org.apache.log4j.Logger"%> + + + + + + + + + + + + + Log - Sync Resource - + + + + + +
+ +

Log - Sync Resource -

+ <% + if ( (message != null) && (errorMessage != null) ) { + %> +

[<%=category%>-<%=errorNumber%>]

+

<%=errorMessage%>

+ <% + } + %> + +

Download Log File

+

Please select the following list you would like to download the log file.

+ + + + + + + + <% + SimpleDateFormat dfm = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss"); + NumberFormat num = NumberFormat.getInstance(); + Iterator i = logfiles.iterator(); + while ( i.hasNext() ){ + LogFileData log = (LogFileData) i.next(); + + if ( log != null && log.fileName != null){ + out.println(""); + out.println(""); + out.println(""); + out.println(""); + out.println(""); + } + } + %> +
LogFileNameLastUpdateFileSize(byte)
"); + out.println("" + log.fileName + ""); + out.println("" + dfm.format(log.time) + "" + num.format(log.size) + "
+ +
+ +

Current Log Level

+ +
+ + + + + + + <% + Iterator it = levelMap.keySet().iterator(); + while (it.hasNext()) { + String cat = it.next(); + if (! cat.matches("^l7sync.*$")) + continue; + %> + + + + + <% + } + %> +
CategoryLevel
<%= cat %><%= levelMap.get(cat) %>
+ +
+ +
+ + \ No newline at end of file diff --git a/src/WebContent/log_top.jsp b/src/WebContent/log_top.jsp new file mode 100644 index 0000000..fa7bb7b --- /dev/null +++ b/src/WebContent/log_top.jsp @@ -0,0 +1,110 @@ +<%@ page + import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*,java.util.*" + language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + +<% + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41302, + LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + + /* + * check snmpAgent status + */ + L7guiFramework framework = new L7guiFramework(); + SnmpAgentData snmp = framework.getSnmpAgentData(); + if (snmp == null) { + MessageView error = new MessageView(41303, + LogCategorySet.GUI_IO_COMMAND, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + } + + /* + * get cluster status + */ + + ClusterData cd = framework.getClusterData(); + if (cd == null) { + MessageView error = new MessageView(41304, + LogCategorySet.GUI_IO_COMMAND, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + } + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if (cd.self_status == ClusterStatus.ACTIVE) { + cssSeat = "l7gui_act_style.css"; + } else if (cd.self_status == ClusterStatus.STANDBY) { + cssSeat = "l7gui_sby_style.css"; + } +%> + + + + + + + + + + + + + + +Log Top + + + + + +
+ +

Log Info

+ +

Log List

+

Please select one of the following logs that you would like to download or change log level.


+ +

- Load balancer (l7vsd)

+

- Admin command (l7vsadm)

+

- Moniter RealServer (l7directord)

+<% if (snmp.status == SnmpAgentStatus.CONNECTING){ +%> +

- SNMPAgent (l7agent)

+<% +} +%> +

- GUI (l7gui)

+<% + if (cd.self_status == ClusterStatus.ACTIVE + || cd.self_status == ClusterStatus.STANDBY) { +%> + +

- Sync Resource (l7sync)

+

- Cluster

+<% +} +%> + +
+ + diff --git a/src/WebContent/logout.jsp b/src/WebContent/logout.jsp new file mode 100644 index 0000000..fdf0e09 --- /dev/null +++ b/src/WebContent/logout.jsp @@ -0,0 +1,232 @@ +<%@ page import="org.ultramonkey.l7.model.*, + org.ultramonkey.l7.controller.*, + org.ultramonkey.l7.view.*, java.util.*" + language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" +%> +<% + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41305, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get cluster status and fix css seat + */ + L7guiFramework framework = new L7guiFramework(); + ClusterData cd = framework.getClusterData(); + if (cd == null) { + MessageView error = new MessageView(41306, LogCategorySet.GUI_IO_COMMAND, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + String cssSeat = "l7gui_single_style.css"; + if ( cd.self_status == ClusterStatus.ACTIVE ){ + cssSeat = "l7gui_act_style.css"; + } + else if ( cd.self_status == ClusterStatus.STANDBY ){ + cssSeat = "l7gui_sby_style.css"; + } + + /* + * in case : sessionTimeout == null(Adm Command Normal) + * get save status & sync status + */ + + /* + * Adm timeout status + */ + Parameter param = Parameter.getInstance(); + if (param == null){ + MessageView error = new MessageView(41307, LogCategorySet.GUI_START_STOP, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + String sessionTimeout = param.getValue(Parameter.L7VSADM_TIMEOUT_FLAG); + + boolean saveState = false; + String logSaveState = (String)session.getAttribute(SessionKeys.LOG_SAVE_STATE); + String vsSaveState = (String)session.getAttribute(SessionKeys.VS_SAVE_STATE); + + int syncState = 0; + String logSyncState = null; + String vsSyncState = null; + String monitorSyncState = null; + String repSyncState = null; + String snmpSyncState = null; + String guiSyncState = null; + + String legendInfo = null; + + if ( sessionTimeout == null ) { + /* + * get save status + */ + + if ( (logSaveState == null) || (vsSaveState == null) ){ + MessageView error = new MessageView(41308, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + if ((logSaveState.equals(SessionKeys.SAVE)) && (vsSaveState.equals(SessionKeys.SAVE))){ + saveState = true; + } + + + /* + * in case : ACT or SBY get sync status + */ + if ( (cd.self_status == ClusterStatus.ACTIVE) || (cd.self_status == ClusterStatus.STANDBY) ){ + syncState = 1; + logSyncState = (String)session.getAttribute(SessionKeys.LOG_SYNC_STATE); + vsSyncState = (String)session.getAttribute(SessionKeys.VS_SYNC_STATE); + monitorSyncState = (String)session.getAttribute(SessionKeys.MONITOR_SYNC_STATE); + repSyncState = (String)session.getAttribute(SessionKeys.REP_SYNC_STATE); + snmpSyncState = (String)session.getAttribute(SessionKeys.SNMP_SYNC_STATE); + guiSyncState = (String)session.getAttribute(SessionKeys.GUI_SYNC_STATE); + + if ( (logSyncState == null) || (vsSyncState == null) + || (monitorSyncState == null ) || (repSyncState == null ) + || (snmpSyncState == null ) || (guiSyncState == null) ){ + + MessageView error = new MessageView(41309, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + if ( (logSyncState.equals(SessionKeys.SYNC)) && (vsSyncState.equals(SessionKeys.SYNC)) + && (monitorSyncState.equals(SessionKeys.SYNC)) && (repSyncState.equals(SessionKeys.SYNC)) + && (snmpSyncState.equals(SessionKeys.SYNC)) && (guiSyncState.equals(SessionKeys.SYNC)) ){ + + syncState = 2; + } + } + + + if ( (cd.self_status == ClusterStatus.ACTIVE) || (cd.self_status == ClusterStatus.STANDBY) ){ + if ( saveState == true && syncState == 1 ){ + legendInfo = "No Sync Info"; + } + else if ( saveState == false && syncState == 1 ){ + legendInfo = "No Sync & No Save Info"; + } + else if ( saveState == false && syncState == 2 ){ + legendInfo = "No Save Info"; + } + } + else { + if (saveState == false ){ + legendInfo = "No Save Info"; + } + } + } +%> + + + + + + + + + + + + + + + Check Logout + + + + + +
+ +

Check Logout

+
+ <% + if ( sessionTimeout == null ) { + if ( legendInfo != null ){ + %> +
+ <%=legendInfo %> + + <% + if ( saveState == false ){ + %> + + + + + <% + } + %> + <% + if ( syncState == 1){ + %> + + + + + <% + } + %> +
+ + + <% + if ( logSaveState.equals(SessionKeys.NO_SAVE) ) + out.println("

Log

"); + if ( vsSaveState.equals(SessionKeys.NO_SAVE ) ) + out.println("

Service

"); + %> +
+ + + <% + if ( logSyncState.equals(SessionKeys.NO_SYNC) ) + out.println("

Log

"); + if ( monitorSyncState.equals(SessionKeys.NO_SYNC ) ) + out.println("

Monitor

"); + if ( vsSyncState.equals(SessionKeys.NO_SYNC ) ) + out.println("

Service

"); + if ( repSyncState.equals(SessionKeys.NO_SYNC ) ) + out.println("

Replication

"); + if ( snmpSyncState.equals(SessionKeys.NO_SYNC ) ) + out.println("

SNMPAgent

"); + if ( guiSyncState.equals(SessionKeys.NO_SYNC ) ) + out.println("

GUI

"); + %> +
+
+ <% + } + } + %> + +

Logout OK?

+ +
+ +
+ + diff --git a/src/WebContent/logout_success.jsp b/src/WebContent/logout_success.jsp new file mode 100644 index 0000000..c1d0d62 --- /dev/null +++ b/src/WebContent/logout_success.jsp @@ -0,0 +1,53 @@ +<%@ page import="org.ultramonkey.l7.model.*, + org.ultramonkey.l7.controller.*, + org.ultramonkey.l7.view.*, java.util.*" + language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" +%> +<% + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41310, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * invalid session + */ + session.invalidate(); +%> + + + + + + + + + + + + + + + Logout success + + + +

Logout success.

+

Good-Bye.

+ +

+ Login +

+ + + + \ No newline at end of file diff --git a/src/WebContent/menu.jsp b/src/WebContent/menu.jsp new file mode 100644 index 0000000..5805dd4 --- /dev/null +++ b/src/WebContent/menu.jsp @@ -0,0 +1,379 @@ +<%@ page import="org.ultramonkey.l7.model.*, org.ultramonkey.l7.controller.*, org.ultramonkey.l7.view.*, + java.net.InetAddress, java.net.UnknownHostException,java.util.*" + language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" +%> +<% + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41311, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get cluster status + */ + L7guiFramework framework = new L7guiFramework(); + ClusterData cd = framework.getClusterData(); + if (cd == null) { + MessageView error = new MessageView(41312, LogCategorySet.GUI_IO_COMMAND, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get UserNmae + */ + UserData currentUser = (UserData) session.getAttribute(SessionKeys.LOGIN_SESSION); + if (currentUser == null) { + MessageView error = new MessageView(41313, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + String userName = currentUser.userName; + if (userName == null){ + MessageView error = new MessageView(41314, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + + /* + * get host name + */ + InetAddress hostName = null; + try { + hostName = InetAddress.getLocalHost(); + } + catch(UnknownHostException e){ + hostName =null; + } + + /* + * get save status + */ + boolean saveState = false; + String logSaveState = (String)session.getAttribute(SessionKeys.LOG_SAVE_STATE); + String vsSaveState = (String)session.getAttribute(SessionKeys.VS_SAVE_STATE); + + if ( (logSaveState == null) || (vsSaveState == null) ){ + MessageView error = new MessageView(41315, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + if ((logSaveState.equals(SessionKeys.SAVE)) && (vsSaveState.equals(SessionKeys.SAVE))){ + saveState = true; + } + + + /* + * get sync status + */ + boolean syncState = false; + String logSyncState = (String)session.getAttribute(SessionKeys.LOG_SYNC_STATE); + String vsSyncState = (String)session.getAttribute(SessionKeys.VS_SYNC_STATE); + String monitorSyncState = (String)session.getAttribute(SessionKeys.MONITOR_SYNC_STATE); + String repSyncState = (String)session.getAttribute(SessionKeys.REP_SYNC_STATE); + String snmpSyncState = (String)session.getAttribute(SessionKeys.SNMP_SYNC_STATE); + String guiSyncState = (String)session.getAttribute(SessionKeys.GUI_SYNC_STATE); + + if ( (logSyncState.equals(SessionKeys.SYNC)) && (vsSyncState.equals(SessionKeys.SYNC)) + && (monitorSyncState.equals(SessionKeys.SYNC)) && (repSyncState.equals(SessionKeys.SYNC)) + && (snmpSyncState.equals(SessionKeys.SYNC)) && (guiSyncState.equals(SessionKeys.SYNC)) ){ + syncState = true; + } + + /* + * Adm timeout status + */ + Parameter param = Parameter.getInstance(); + if (param == null){ + MessageView error = new MessageView(41316, LogCategorySet.GUI_START_STOP, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + String sessionTimeout = param.getValue(Parameter.L7VSADM_TIMEOUT_FLAG); + + /* + * get L7vsAdmData (SNMPAgent) + */ + L7vsAdmData admData = framework.getAdmData(); + SnmpAgentStatus snmpStatus = SnmpAgentStatus.NON_CONNECTING; + if (admData != null) { + snmpStatus = admData.snmpStatus; + } + + /* + * get L7vsAdmData (Replication) + */ + ReplicationStatus repStatus = ReplicationStatus.SINGLE; + if (admData != null) { + repStatus = admData.replicationMode; + } + + /* + * get user info + */ + UserManager user = UserManager.getInstance(); + Vector userList; + try { + userList = user.getUserList(); + } + catch(Exception e){ + MessageView error = new MessageView(41317, LogCategorySet.GUI_IO_FILE, + Message.READ_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + if ( userList == null ){ + MessageView error = new MessageView(41318, LogCategorySet.GUI_IO_FILE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + int userCount = userList.size(); +%> + + diff --git a/src/WebContent/monitor_info.jsp b/src/WebContent/monitor_info.jsp new file mode 100644 index 0000000..78d4900 --- /dev/null +++ b/src/WebContent/monitor_info.jsp @@ -0,0 +1,250 @@ +<%@ page + import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*,java.util.*" + language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + +<% + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41319, + LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get result message + */ + MessageView message = (MessageView) session + .getAttribute(SessionKeys.RESULT_MESSAGE); + + String errorMessage = ""; + int errorNumber = 0; + String category = ""; + + if (message != null) { + errorMessage = message.getMessage(); + errorNumber = message.getErrno(); + category = message.getCategory(); + session.setAttribute(SessionKeys.RESULT_MESSAGE, null); + } + + /* + * get command message + */ + MessageView commandmessage = (MessageView) session + .getAttribute(SessionKeys.COMMAND_MESSAGE); + + String commandMessage = ""; + int commandNumber = 0; + String commandCategory = ""; + + if (commandmessage != null) { + commandMessage = commandmessage.getMessage(); + commandNumber = commandmessage.getErrno(); + commandCategory = commandmessage.getCategory(); + session.setAttribute(SessionKeys.COMMAND_MESSAGE, null); + } + + /* + * get DirectorData + */ + L7guiFramework framework = new L7guiFramework(); + DirectorData dd = framework.getDirectorData(); + if (dd == null) { + MessageView error = new MessageView(41320, + LogCategorySet.GUI_IO_FILE, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get cluster status + */ + ClusterData cd = framework.getClusterData(); + if (cd == null) { + MessageView error = new MessageView(41321, + LogCategorySet.GUI_IO_COMMAND, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if (cd.self_status == ClusterStatus.ACTIVE) { + cssSeat = "l7gui_act_style.css"; + } else if (cd.self_status == ClusterStatus.STANDBY) { + cssSeat = "l7gui_sby_style.css"; + } +%> + + + + + + + + + + + + + + + + Monitor Current Status + + + + + +
+ + +

Monitor Current Status

+ +<% +if (message != null) { +%> + +

[<%=category%>-<%=errorNumber%>]

+

<%=errorMessage%>

+ +<% +} else if (commandmessage != null) { +%> +

[<%=commandCategory%>-<%=commandNumber%>]

+

<%=commandMessage%>

+<% +} +%> + +
Monitor Settings + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ <% + if ( (null != dd.checkTimeOut) && ("" != dd.checkTimeOut) ) + out.print(dd.checkTimeOut + " [sec]"); + %> +
+ + <% + if ( (null != dd.negotiateTimeOut) && ("" != dd.negotiateTimeOut) ) + out.print(dd.negotiateTimeOut + " [sec]"); + %> +
+ + <% + if ( (null != dd.checkInterval) && ("" != dd.checkInterval) ) + out.print(dd.checkInterval + " [sec]"); + %> +
+ <% + if ( (null != dd.checkCount) && ("" != dd.checkCount) ) + out.print(dd.checkCount + " [time]"); + %> +
+ <% + if (null != dd.callback) + out.print(dd.callback); + %> +
+ <% + if (null != dd.fallback) + out.print(dd.fallback); + %> +
+ <% + if (null != dd.logfile) + out.print(dd.logfile); + %> +
+ <% + if (null != dd.execute) + out.print(dd.execute); + %> +
+ <% + if (null != dd.supervised) + out.print(dd.supervised); + %> +
+ <% + if (null != dd.quiescent) + out.print(dd.quiescent); + %> +
+
+ + +

Modify Monitor setting

+

Please push the following button, if you would like to modify the Monitor setting.

+
+ +
+
+ + diff --git a/src/WebContent/monitor_modify.jsp b/src/WebContent/monitor_modify.jsp new file mode 100644 index 0000000..7c62dc0 --- /dev/null +++ b/src/WebContent/monitor_modify.jsp @@ -0,0 +1,398 @@ +<%@ page + import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*,java.util.*" + language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + +<% + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41322, LogCategorySet.GUI_USER_AUTHENTICATION, Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get result message + */ + MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE); + String errorMessage = ""; + int errorNumber = 0; + String category = ""; + if (message != null) { + errorMessage = message.getMessage(); + errorNumber = message.getErrno(); + category = message.getCategory(); + session.setAttribute(SessionKeys.RESULT_MESSAGE, null); + } + + /* + * get validation error message + */ + HashMap errMessage = (HashMap) session.getAttribute(SessionKeys.INVALID_MESSAGE); + session.setAttribute(SessionKeys.INVALID_MESSAGE, null); + + /* + * get previous inputvalue + */ + L7guiFramework framework = new L7guiFramework(); + DirectorData dd = (DirectorData) session.getAttribute(SessionKeys.INPUT_MONITOR); + + if (dd != null){ + session.setAttribute(SessionKeys.INPUT_MONITOR, null); + } + else{ + /* + * get DirectorData + */ + dd = framework.getDirectorData(); + if (dd == null){ + MessageView error = new MessageView(41323, LogCategorySet.GUI_IO_FILE, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + } + + /* + * get cluster status + */ + ClusterData cd = framework.getClusterData(); + if (cd == null){ + MessageView error = new MessageView(41324, LogCategorySet.GUI_IO_COMMAND, Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + } + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if ( cd.self_status == ClusterStatus.ACTIVE ){ + cssSeat = "l7gui_act_style.css"; + } + else if ( cd.self_status == ClusterStatus.STANDBY ){ + cssSeat = "l7gui_sby_style.css"; + } +%> + + + + + + + + + + + + + + + + + Modify Monitor Info + + + + + + +
+ +

Modify Monitor Setting

+ +<% +if ( (message != null) && (errorMessage != null) ) { +%> +

[<%=category%>-<%=errorNumber%>]

+

<%=errorMessage%>

+<% +} +%> + + +
+ +
Monitor Setting + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ <% + { + String invalidMessage = null; + if ( null != errMessage ){ + invalidMessage = errMessage.get("checkTimeOut"); + } + if ( null == dd.checkTimeOut ){ + out.print(" [sec]"); + } + else{ + out.print(" [sec]"); + } + if ( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

1-2147483647(sec)
+ Default : 5(sec)

+
+ <% + { + String invalidMessage = null; + if ( null != errMessage ){ + invalidMessage = errMessage.get("negotiateTimeOut"); + } + if ( null == dd.negotiateTimeOut ){ + out.print(" [sec]"); + } + else{ + out.print(" [sec]"); + } + if ( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

1-2147483647(sec)
+ Default is defined by the operating system.

+
+ <% + { + String invalidMessage = null; + if ( null != errMessage ){ + invalidMessage = errMessage.get("checkInterval"); + } + if ( null == dd.checkInterval ){ + out.print(" [sec]"); + } + else{ + out.print(" [sec]"); + } + if ( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

1-2147483647(sec)
+ Default : 10(sec)

+
+ <% + { + String invalidMessage = null; + if ( null != errMessage ){ + invalidMessage = errMessage.get("checkCount"); + } + if ( null == dd.checkCount ){ + out.print(" [time]"); + } + else{ + out.print(" [time]"); + } + if ( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

1-2147483647(time)
+ Default : 1(time)

+
+ <% + { + String invalidMessage = null; + if ( null != errMessage ){ + invalidMessage = errMessage.get("callback"); + } + if ( null == dd.callback ){ + out.print(""); + } + else{ + out.print(""); + } + if ( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

+
+ <% + { + String invalidMessage = null; + if ( null != errMessage ){ + invalidMessage = errMessage.get("fallback"); + } + if ( null == dd.fallback ){ + out.print(""); + } + else{ + out.print(""); + } + if ( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

+
+ <% + { + String invalidMessage = null; + if ( null != errMessage ){ + invalidMessage = errMessage.get("logfile"); + } + if ( null == dd.logfile ){ + out.print(""); + } + else{ + out.print(""); + } + if ( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

Default : /var/log/l7directord.log

+
+ <% + { + String invalidMessage = null; + if ( null != errMessage ){ + invalidMessage = errMessage.get("execute"); + } + if ( null == dd.execute ){ + out.print(""); + } + else{ + out.print(""); + } + if ( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

+
<% + if ( null != errMessage ){ + String invalidMessage = errMessage.get("supervised"); + if ( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

Default : No

+
<% + if ( null != errMessage ){ + String invalidMessage = errMessage.get("quiescent"); + if ( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

Default : No

+
+
+ +
+ + +<% +if (cd.self_status == ClusterStatus.ACTIVE || cd.self_status == ClusterStatus.STANDBY) { +%> + +<% +} +%>
+
+ + diff --git a/src/WebContent/monitor_modify_executive.jsp b/src/WebContent/monitor_modify_executive.jsp new file mode 100644 index 0000000..2751961 --- /dev/null +++ b/src/WebContent/monitor_modify_executive.jsp @@ -0,0 +1,75 @@ +<%@ page + import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*" + language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + +<% + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41325, + LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get thread status + */ + String threadStatus = (String) session + .getAttribute(SessionKeys.THREAD_STATUS); + if (threadStatus == null) { + MessageView error = new MessageView(41326, + LogCategorySet.GUI_MONITOR, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } else if (threadStatus.equals(SessionKeys.THREAD_RUNNING)) { + // nothing to do + } else if (threadStatus.equals(SessionKeys.THREAD_SUCCESS)) { + response.sendRedirect(RedirectPages.MONITOR_INFO); + return; + } else if (threadStatus.equals(SessionKeys.THREAD_FAIL)) { + response.sendRedirect(RedirectPages.MONITOR_MODIFY_NG); + return; + } else { + MessageView error = new MessageView(41327, + LogCategorySet.GUI_MONITOR, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } +%> + + + + + + + + + + + + + + + + + Running Modify Monitor RealServer + + + + +

Running Modify Monitor RealServer

+

Please wait.

+ + + diff --git a/src/WebContent/monitor_modify_fail.jsp b/src/WebContent/monitor_modify_fail.jsp new file mode 100644 index 0000000..fcc6c36 --- /dev/null +++ b/src/WebContent/monitor_modify_fail.jsp @@ -0,0 +1,94 @@ +<%@ page + import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*" + language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + +<% + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41328, + LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get result message + */ + MessageView message = (MessageView) session + .getAttribute(SessionKeys.COMMAND_MESSAGE); + + String errorMessage = ""; + int errorNumber = 0; + String category = ""; + + if (message != null) { + errorMessage = message.getMessage(); + errorNumber = message.getErrno(); + category = message.getCategory(); + session.setAttribute(SessionKeys.COMMAND_MESSAGE, null); + } + + /* + * get cluster status + */ + L7guiFramework framework = new L7guiFramework(); + ClusterData cd = framework.getClusterData(); + if (cd == null) { + MessageView error = new MessageView(41329, + LogCategorySet.GUI_IO_COMMAND, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if (cd.self_status == ClusterStatus.ACTIVE) { + cssSeat = "l7gui_act_style.css"; + } else if (cd.self_status == ClusterStatus.STANDBY) { + cssSeat = "l7gui_sby_style.css"; + } +%> + + + + + + + + + + + + + + Failed : Modify Monitor + + + + + + +
+

Failed : Modify Monitor

+

Monitor Info Modify Failed.

+

Error Reason :

+

[<%=category%>-<%=errorNumber%>]

+

<%=errorMessage%>

+ +
+ + diff --git a/src/WebContent/redundant_info.jsp b/src/WebContent/redundant_info.jsp new file mode 100644 index 0000000..2828865 --- /dev/null +++ b/src/WebContent/redundant_info.jsp @@ -0,0 +1,164 @@ +<%@ page import="org.ultramonkey.l7.model.*, + org.ultramonkey.l7.controller.*, + org.ultramonkey.l7.view.*" + language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<% + + /* + * check session + */ + if (session.isNew()) { + MessageView error = new MessageView(41330, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get command message + */ + MessageView commandmessage = (MessageView) session.getAttribute(SessionKeys.COMMAND_MESSAGE); + String commandMessage = ""; + int commandNumber = 0; + String commandCategory = ""; + if (commandmessage != null) { + commandMessage = commandmessage.getMessage(); + commandNumber = commandmessage.getErrno(); + commandCategory = commandmessage.getCategory(); + session.setAttribute(SessionKeys.COMMAND_MESSAGE, null); + } + + + /* + * get cluster status + */ + L7guiFramework framework = new L7guiFramework(); + ClusterData cd = framework.getClusterData(); + if (cd == null) { + MessageView error = new MessageView(41331, LogCategorySet.GUI_IO_COMMAND, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + // IP CHECK + String selfIp = cd.self_ip; + String otherIp = cd.other_ip; + + if ( (selfIp == null) || (otherIp == null) ){ + MessageView error = new MessageView(41332, LogCategorySet.GUI_REDUNDANT, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if ( cd.self_status == ClusterStatus.ACTIVE ){ + cssSeat = "l7gui_act_style.css"; + } + else if ( cd.self_status == ClusterStatus.STANDBY ){ + cssSeat = "l7gui_sby_style.css"; + } + +%> + + + + + + + + + + + + + + + + + + Redundance + + + + + + +
+ +

Redundance

+ <% if (cd.self_status == ClusterStatus.SINGLE ){ + %> +

Cluster disabled.

+ <% + } + else { + %> +
+ Current Status + + + + + + + + + + + + + + + + + +
+ + + Self Node + + Peer Node +
+ + + <%= cd.self_status %> + + <%= cd.other_status %> +
+ + + <%= selfIp %> + + <%= otherIp %> +
+
+ + + + + <% if ( ( (cd.self_status == ClusterStatus.ACTIVE) || (cd.self_status == ClusterStatus.STANDBY) ) + && ( (cd.other_status == ClusterStatus.ACTIVE) || (cd.other_status == ClusterStatus.STANDBY) ) ){ + %> +
+

Please push the following button, if you would like to switch over.


+ +
+ <% + } + } + %> +
+ + + + diff --git a/src/WebContent/replication.jsp b/src/WebContent/replication.jsp new file mode 100644 index 0000000..c166352 --- /dev/null +++ b/src/WebContent/replication.jsp @@ -0,0 +1,315 @@ +<%@ page import="org.ultramonkey.l7.model.*, + org.ultramonkey.l7.controller.*, + org.ultramonkey.l7.view.*, java.util.*" + language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<% + + /* + * check session + */ + if (session.isNew()) { + MessageView error = new MessageView(41333, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get result message + */ + MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE); + String errorMessage = null; + int errorNumber = 0; + String category = ""; + if (message != null) { + errorMessage = message.getMessage(); + errorNumber = message.getErrno(); + category = message.getCategory(); + session.setAttribute(SessionKeys.RESULT_MESSAGE, null); + } + + + /* + * get command message + */ + MessageView commandmessage = (MessageView) session.getAttribute(SessionKeys.COMMAND_MESSAGE); + String commandMessage = null; + int commandNumber = 0; + String commandCategory = ""; + if (commandmessage != null) { + commandMessage = commandmessage.getMessage(); + commandNumber = commandmessage.getErrno(); + commandCategory = commandmessage.getCategory(); + session.setAttribute(SessionKeys.COMMAND_MESSAGE, null); + } + + // get replicationData + L7guiFramework framework = new L7guiFramework(); + ReplicationData rep = framework.getReplicationData(); + ReplicationStatus repStatus = ReplicationStatus.OUT; + if ( null == rep ){ + MessageView error = new MessageView(41334, LogCategorySet.GUI_IO, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + else { + repStatus = rep.replicationMode; + } + String printRepStatus = null; + String changeModeMessage = null; + switch (repStatus){ + case MASTER: + printRepStatus = "Master Running"; + changeModeMessage = "If you would like to stop sending Replication data, push the following button."; + break; + case SLAVE: + printRepStatus = "Slave Running"; + changeModeMessage = "If you would like to stop receiving Replication data, push the following button."; + break; + case MASTER_STOP: + printRepStatus = "Master Stopped"; + changeModeMessage = "If you would like to start sending Replication data, push the following button."; + break; + case SLAVE_STOP: + printRepStatus = "Slave Stopped"; + changeModeMessage = "If you would like to start receiving Replication data, push the following button."; + break; + case SINGLE: + printRepStatus = "Replication Invalid"; + break; + case OUT: + printRepStatus = "In Starting Replication"; + break; + default : + MessageView error = new MessageView(41335, LogCategorySet.GUI_REPLICATION, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + String selfNic = rep.nic; + String peerIp = rep.otherNode.host; + + if ( (selfNic == null) || (peerIp == null) ){ + MessageView error = new MessageView(41336, LogCategorySet.GUI_IO_FILE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + HashMap repDatainfo = rep.component; + Set keys = null; + if (repDatainfo != null){ + keys = repDatainfo.keySet(); + } + + /* + * get cluster status + */ + ClusterData cd = framework.getClusterData(); + if (cd == null) { + MessageView error = new MessageView(41337, LogCategorySet.GUI_IO_COMMAND, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if ( cd.self_status == ClusterStatus.ACTIVE ){ + cssSeat = "l7gui_act_style.css"; + } + else if ( cd.self_status == ClusterStatus.STANDBY ){ + cssSeat = "l7gui_sby_style.css"; + } + +%> + + + + + + + + + + + + + + + + + + Replication + + + + + + +
+ + +

Replication

+ <% + if ( (message != null) && (errorMessage != null) ) { + %> + +

[<%=category %> - <%=errorNumber %>]

+

<%=errorMessage %>

+ + <% + } + else if ( (commandmessage != null) && (commandMessage != null) ){ + %> +

[<%=commandCategory %> - <%=commandNumber %>]

+

<%=commandMessage %>

+ <% + } + %> + +

Replication Current Status

+ +
+
+ Replication Current Status + + + + + + + + + + + +
Replication Mode
<%=printRepStatus %>
+
+ <% if ( changeModeMessage != null){ + %> +

<%=changeModeMessage %>

+
+ <% + } + switch (repStatus){ + case MASTER: + %> + + <% + break; + case SLAVE: + %> + + <% + break; + case MASTER_STOP: + %> + + <% + break; + case SLAVE_STOP: + %> + + <% + break; + } + %> +
+ + + <% + if ( repStatus != ReplicationStatus.SINGLE ){ + %> +
+

Replication Configuration Information

+
+ Replication Configuration Information + + + + + + + + + + + + + + + + + +
Self NodePeer NodeInterval
NICIP AddressPort Number
<%=selfNic %><%=peerIp %><%=rep.otherNode.port %><%=rep.interval %> [µsec]
+
+

If you would like to modify Interval, push the following button.

+
+ +
+ + <% if (keys != null) {%> +

Replication Data Size Information

+
+ Replication Data Size Information + + + <% + for (Iterator iterator = keys.iterator(); iterator.hasNext();){ + %> + + <% + } + %> + + + <% + for (Iterator iterator = keys.iterator(); iterator.hasNext();){ + String key = (String)iterator.next(); + double size = ((Integer)repDatainfo.get(key)) * 480; + String sizeUnit = "[byte]"; + if ( (size >= 1000) && ( size < 1000000 )){ + size = size / 1000 ; + sizeUnit = "[Kbyte]"; + } + else if( size >= 1000000 ){ + size = size / 1000000 ; + sizeUnit = "[Mbyte]"; + } + out.println(""); + } + %> + +
<%=iterator.next() %>
" + size + "" + sizeUnit + "
+
+ + <% + if ( repStatus == ReplicationStatus.MASTER ){ + %> +

Immediate Replication

+
+

If you would like to execute immediate Replication, push the following button.

+
+ +
+ <% + } + } + } + %> + +
+ + diff --git a/src/WebContent/replication_executive.jsp b/src/WebContent/replication_executive.jsp new file mode 100644 index 0000000..0e94a83 --- /dev/null +++ b/src/WebContent/replication_executive.jsp @@ -0,0 +1,108 @@ +<%@ page + import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*" + language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + +<% + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41338, + LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get thread status + */ + + String threadStatus = (String) session + .getAttribute(SessionKeys.THREAD_STATUS); + if (threadStatus == null) { + MessageView error = new MessageView(41339, + LogCategorySet.GUI_REPLICATION, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } else if (threadStatus.equals(SessionKeys.THREAD_RUNNING)) { + // + } else if (threadStatus.equals(SessionKeys.THREAD_SUCCESS)) { + response.sendRedirect(RedirectPages.REPLICATION_INFO); + return; + } else if (threadStatus.equals(SessionKeys.THREAD_FAIL)) { + response.sendRedirect(RedirectPages.REPLICATION_NG); + return; + } else { + MessageView error = new MessageView(41340, + LogCategorySet.GUI_REPLICATION, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get Replication Info + */ + L7guiFramework framework = new L7guiFramework(); + ClusterData repInfo = framework.getClusterData(); + if (repInfo == null) { + MessageView error = new MessageView(41341, + LogCategorySet.GUI_REPLICATION, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + String repMaster = repInfo.self_ip; + String repSlave = repInfo.other_ip; + + if ((repMaster == null) || (repSlave == null)) { + MessageView error = new MessageView(41342, + LogCategorySet.GUI_REPLICATION, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } +%> + + + + + + + + + + + + + + + + Replicating + + + +

Replicating

+

Please wait.

+

(Master) <%=repMaster%>

+ +arrowlogo1 + +

(Slave) <%=repSlave%>

+ + + + diff --git a/src/WebContent/replication_fail.jsp b/src/WebContent/replication_fail.jsp new file mode 100644 index 0000000..98cd5bd --- /dev/null +++ b/src/WebContent/replication_fail.jsp @@ -0,0 +1,102 @@ +<%@ page + import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*" + language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + +<% + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41343, + LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get command message + */ + MessageView message = (MessageView) session + .getAttribute(SessionKeys.COMMAND_MESSAGE); + + String errorMessage = ""; + int errorNumber = 0; + String category = ""; + + if (message != null) { + errorMessage = message.getMessage(); + errorNumber = message.getErrno(); + category = message.getCategory(); + session.setAttribute(SessionKeys.COMMAND_MESSAGE, null); + } + + /* + * get cluster status + */ + L7guiFramework framework = new L7guiFramework(); + ClusterData cd = framework.getClusterData(); + if (cd == null) { + MessageView error = new MessageView(41344, + LogCategorySet.GUI_IO_COMMAND, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if (cd.self_status == ClusterStatus.ACTIVE) { + cssSeat = "l7gui_act_style.css"; + } else if (cd.self_status == ClusterStatus.STANDBY) { + cssSeat = "l7gui_sby_style.css"; + } +%> + + + + + + + + + + + + + + + + Failed To Replicate + + + + + + + +
+

Failed : Replication

+ +

Error Reason :

+<% + if (errorMessage != null) { + out.println("

[" + category + " - " + errorNumber + "]

"); + out.println("

" + errorMessage + "

"); + } +%> +
+ + + + diff --git a/src/WebContent/replication_mode_executive.jsp b/src/WebContent/replication_mode_executive.jsp new file mode 100644 index 0000000..a714278 --- /dev/null +++ b/src/WebContent/replication_mode_executive.jsp @@ -0,0 +1,124 @@ +<%@ page + import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*" + language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + +<% + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41345, + LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get thread status + */ + String threadStatus = (String) session + .getAttribute(SessionKeys.THREAD_STATUS); + if (threadStatus == null) { + MessageView error = new MessageView(41346, + LogCategorySet.GUI_REPLICATION, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } else if (threadStatus.equals(SessionKeys.THREAD_RUNNING)) { + // + } else if (threadStatus.equals(SessionKeys.THREAD_SUCCESS)) { + response.sendRedirect(RedirectPages.REPLICATION_INFO); + return; + } else if (threadStatus.equals(SessionKeys.THREAD_FAIL)) { + response.sendRedirect(RedirectPages.REPLICATION_MODE_NG); + return; + } else { + MessageView error = new MessageView(41347, + LogCategorySet.GUI_REPLICATION, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get Replication Status + */ + L7guiFramework framework = new L7guiFramework(); + ReplicationData rep = framework.getReplicationData(); + if (rep == null) { + MessageView error = new MessageView(41348, + LogCategorySet.GUI_REPLICATION, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + ReplicationStatus repStatus = rep.replicationMode; + String repChangeStatus = ""; + String repNowStatus = ""; + + switch (repStatus) { + case MASTER: + repNowStatus = "Master Run"; + repChangeStatus = "Master Stop"; + break; + case MASTER_STOP: + repNowStatus = "Master Stop"; + repChangeStatus = "Master Run"; + break; + case SLAVE: + repNowStatus = "Slave Run"; + repChangeStatus = "Slave Stop"; + break; + case SLAVE_STOP: + repNowStatus = "Slave Stop"; + repChangeStatus = "Slave Run"; + break; + default: + MessageView error = new MessageView(41349, + LogCategorySet.GUI_REPLICATION, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } +%> + + + + + + + + + + + + + + + + + Changing : Replication Mode + + +

Changing : Replication Mode

+

Please wait.

+

<%=repNowStatus%>

+ +arrowlogo1 + +

<%=repChangeStatus%>

+ + + diff --git a/src/WebContent/replication_mode_fail.jsp b/src/WebContent/replication_mode_fail.jsp new file mode 100644 index 0000000..df6eb8d --- /dev/null +++ b/src/WebContent/replication_mode_fail.jsp @@ -0,0 +1,102 @@ +<%@ page + import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*" + language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + +<% + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41350, + LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get command message + */ + MessageView message = (MessageView) session + .getAttribute(SessionKeys.COMMAND_MESSAGE); + + String errorMessage = ""; + int errorNumber = 0; + String category = ""; + + if (message != null) { + errorMessage = message.getMessage(); + errorNumber = message.getErrno(); + category = message.getCategory(); + session.setAttribute(SessionKeys.COMMAND_MESSAGE, null); + } + + /* + * get cluster status + */ + L7guiFramework framework = new L7guiFramework(); + ClusterData cd = framework.getClusterData(); + if (cd == null) { + MessageView error = new MessageView(41351, + LogCategorySet.GUI_IO_COMMAND, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if (cd.self_status == ClusterStatus.ACTIVE) { + cssSeat = "l7gui_act_style.css"; + } else if (cd.self_status == ClusterStatus.STANDBY) { + cssSeat = "l7gui_sby_style.css"; + } +%> + + + + + + + + + + + + + + + + Failed : Change Replication Mode + + + + + + + + + +
+

Failed : Change Replication Mode

+ +

Error Reason :

+<% + if (errorMessage != null) { + out.println("

[" + category + " - " + errorNumber + "]

"); + out.println("

" + errorMessage + "

"); + } +%> +
+ + diff --git a/src/WebContent/replication_modify.jsp b/src/WebContent/replication_modify.jsp new file mode 100644 index 0000000..ab8efc4 --- /dev/null +++ b/src/WebContent/replication_modify.jsp @@ -0,0 +1,168 @@ +<%@ page import="org.ultramonkey.l7.model.*, org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*,java.util.*" + language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<% + /* + * check session + */ + if (session.isNew()) { + MessageView error = new MessageView(41352, + LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get result message + */ + MessageView message = (MessageView) session + .getAttribute(SessionKeys.RESULT_MESSAGE); + String errorMessage = null; + int errorNumber = 0; + String category = null; + if (message != null) { + errorMessage = message.getMessage(); + errorNumber = message.getErrno(); + category = message.getCategory(); + session.setAttribute(SessionKeys.RESULT_MESSAGE, null); + } + + + // get ValidationError Message + String invalidMessage = null; + invalidMessage = (String) session + .getAttribute(SessionKeys.INVALID_MESSAGE); + session.setAttribute(SessionKeys.INVALID_MESSAGE, null); + + // get replicationData + L7guiFramework framework = new L7guiFramework(); + ReplicationData rep = (ReplicationData)session.getAttribute(SessionKeys.INPUT_REP); + + if (null == rep){ + rep = framework.getReplicationData(); + } + + if (null == rep) { + MessageView error = new MessageView(41353, + LogCategorySet.GUI_IO, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get cluster status + */ + ClusterData cd = framework.getClusterData(); + if (cd == null) { + MessageView error = new MessageView(41354, LogCategorySet.GUI_IO_COMMAND, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if ( cd.self_status == ClusterStatus.ACTIVE ){ + cssSeat = "l7gui_act_style.css"; + } + else if ( cd.self_status == ClusterStatus.STANDBY ){ + cssSeat = "l7gui_sby_style.css"; + } +%> + + + + + + + + + + + + + + + + + + Modify Replication Status + + + + + + +
+ + +

Modify Replication Status

+ + <% + if ( (message != null) && (errorMessage != null) ) { + %> +

[<%=category%> - <%=errorNumber%>]

+

<%=errorMessage%>

+ <% + } + %> + +
+ +
+ Replication Current Status + + + + + + +
+ + + <% + if ( ( null != invalidMessage ) && ( 0 == rep.interval ) ){ + %> + + [µsec] + <% + } + else{ + %> + + [µsec] + <% + } + if (null != invalidMessage) { + %> +

<%=invalidMessage%>

+ <% + } + %> +
+

10-10000(usec)

+
+
+ +
+ + + <% + if (cd.self_status == ClusterStatus.ACTIVE + || cd.self_status == ClusterStatus.STANDBY) { + %> + + <% + } + %> +
+
+ + diff --git a/src/WebContent/replication_modify_executive.jsp b/src/WebContent/replication_modify_executive.jsp new file mode 100644 index 0000000..c5996a5 --- /dev/null +++ b/src/WebContent/replication_modify_executive.jsp @@ -0,0 +1,99 @@ +<%@ page + import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*" + language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + +<% + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + session.invalidate(); + MessageView error = new MessageView(41355, + LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get thread status + */ + String threadStatus = (String) session + .getAttribute(SessionKeys.THREAD_STATUS); + if (threadStatus == null) { + MessageView error = new MessageView(41356, + LogCategorySet.GUI_REPLICATION, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } else if (threadStatus.equals(SessionKeys.THREAD_RUNNING)) { + // + } else if (threadStatus.equals(SessionKeys.THREAD_SUCCESS)) { + response.sendRedirect(RedirectPages.REPLICATION_INFO); + return; + } else if (threadStatus.equals(SessionKeys.THREAD_FAIL)) { + response.sendRedirect(RedirectPages.REPLICATION_MODIFY_NG); + return; + } else { + MessageView error = new MessageView(41357, + LogCategorySet.GUI_REPLICATION, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get Replication Status + */ + String repNowInterval = (String) session + .getAttribute(SessionKeys.BEFORE_REP_TIME); + String repNewInterval = (String) session + .getAttribute(SessionKeys.AFTER_REP_TIME); + + if ((repNowInterval == null) || (repNewInterval == null)) { + MessageView error = new MessageView(41358, + LogCategorySet.GUI_REPLICATION, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } +%> + + + + + + + + + + + + + + + + + Modifying : Replication Interval + + + +

Modifying : Replication Interval

+

Please wait.

+

<%=repNowInterval%> [µsec]

+ +arrowlogo1 + +

<%=repNewInterval%>[µsec]

+ + + diff --git a/src/WebContent/replication_modify_fail.jsp b/src/WebContent/replication_modify_fail.jsp new file mode 100644 index 0000000..68f7ed5 --- /dev/null +++ b/src/WebContent/replication_modify_fail.jsp @@ -0,0 +1,100 @@ +<%@ page + import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*" + language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + +<% + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41359, + LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get command message + */ + MessageView message = (MessageView) session + .getAttribute(SessionKeys.COMMAND_MESSAGE); + + String errorMessage = ""; + int errorNumber = 0; + String category = ""; + + if (message != null) { + errorMessage = message.getMessage(); + errorNumber = message.getErrno(); + category = message.getCategory(); + session.setAttribute(SessionKeys.COMMAND_MESSAGE, null); + } + + /* + * get cluster status + */ + L7guiFramework framework = new L7guiFramework(); + ClusterData cd = framework.getClusterData(); + if (cd == null) { + MessageView error = new MessageView(41360, + LogCategorySet.GUI_IO_COMMAND, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if (cd.self_status == ClusterStatus.ACTIVE) { + cssSeat = "l7gui_act_style.css"; + } else if (cd.self_status == ClusterStatus.STANDBY) { + cssSeat = "l7gui_sby_style.css"; + } +%> + + + + + + + + + + + + + + + Failed : Modify Replication Interval + + + + + + + +
+

Failed : Modify Replication Interval

+

Error Reason :

+<% + if (errorMessage != null) { + out.println("

[" + category + " - " + errorNumber + "]

"); + out.println("

" + errorMessage + "

"); + } +%> +
+ + + + diff --git a/src/WebContent/save.jsp b/src/WebContent/save.jsp new file mode 100644 index 0000000..5f49cfe --- /dev/null +++ b/src/WebContent/save.jsp @@ -0,0 +1,214 @@ +<%@ page import="org.ultramonkey.l7.model.*, + org.ultramonkey.l7.controller.*, + org.ultramonkey.l7.view.*, java.util.*, + java.io.File, java.util.Calendar, java.util.Date, java.text.*" + language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<% + + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41361, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get result message + */ + MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE); + String errorMessage = ""; + int errorNumber = 0; + String category = ""; + if (message != null) { + errorMessage = message.getMessage(); + errorNumber = message.getErrno(); + category = message.getCategory(); + session.setAttribute(SessionKeys.RESULT_MESSAGE, null); + } + + /* + * get command message + */ + MessageView commandmessage = (MessageView) session.getAttribute(SessionKeys.COMMAND_MESSAGE); + String commandMessage = ""; + int commandNumber = 0; + String commandCategory = ""; + if (commandmessage != null) { + commandMessage = commandmessage.getMessage(); + commandNumber = commandmessage.getErrno(); + commandCategory = commandmessage.getCategory(); + session.setAttribute(SessionKeys.COMMAND_MESSAGE, null); + } + + /* + * get save status + */ + String saveLogStatus = (String)session.getAttribute(SessionKeys.LOG_SAVE_STATE); + String saveVsStatus = (String)session.getAttribute(SessionKeys.VS_SAVE_STATE); + + if ((saveLogStatus == null) || (saveVsStatus == null)){ + MessageView error = new MessageView(41362, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + if (saveLogStatus.equals(SessionKeys.SAVE)){ + saveLogStatus = "Save"; + } + else if (saveLogStatus.equals(SessionKeys.NO_SAVE)){ + saveLogStatus = "No Save"; + } + + if(saveVsStatus.equals(SessionKeys.SAVE)){ + saveVsStatus = "Save"; + } + else if (saveVsStatus.equals(SessionKeys.NO_SAVE)){ + saveVsStatus = "No Save"; + } + + /* + * get save file info + */ + final String logConfName = "/etc/l7vs/l7vs.cf"; + + final String vsConfName = "/etc/ha.d/conf/l7directord.cf"; + + File logConfFile = new File(logConfName); + File vsConfFile = new File(vsConfName); + String logDisplayTime = null; + String vsDisplayTime = null; + long logConfTime = logConfFile.lastModified(); + long vsConfTime = vsConfFile.lastModified(); + + if (logConfTime == 0){ + logDisplayTime = "-"; + } + else{ + // get logConfTime + SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.JAPAN); + logDisplayTime = sdf.format(new Long(logConfTime)); +} + + if (vsConfTime == 0){ + vsDisplayTime = "-"; + } + else{ + // get vsConfTime + SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.JAPAN); + vsDisplayTime = sdf.format(new Long(vsConfTime)); + } + + + /* + * get cluster status + */ + L7guiFramework framework = new L7guiFramework(); + ClusterData cd = framework.getClusterData(); + if (cd == null) { + MessageView error = new MessageView(41363, LogCategorySet.GUI_IO_COMMAND, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if ( cd.self_status == ClusterStatus.ACTIVE ){ + cssSeat = "l7gui_act_style.css"; + } + else if ( cd.self_status == ClusterStatus.STANDBY ){ + cssSeat = "l7gui_sby_style.css"; + } +%> + + + + + + + + + + + + + + + + Save Resources + + + + + +
+ +

Save Resources

+ + <% + if (message != null) { + %> + +

[<%=category %>-<%=errorNumber %>]

+

<%=errorMessage %>

+ + <% + } + else if ((commandmessage != null) && (commandMessage != null) ){ + %> +

[<%=commandCategory %>-<%=commandNumber %>]

+

<%=commandMessage %>

+ <% + } + %> + + +
+
+ Save / No Save Info + + + + + + + + + + + + + + + + + + + + + + + + +
Save
CHECK
Save / No SaveCategoryDescriptionFile NameLast Save Time
<%= saveLogStatus %>Log Log setting
(except GUI & Sync)
<%=logConfName %><%=logDisplayTime %>
<%= saveVsStatus %>ServiceVirtualService settings<%=vsConfName %><%=vsDisplayTime %>
+
+ + + +
+ +
+ + \ No newline at end of file diff --git a/src/WebContent/save_fail.jsp b/src/WebContent/save_fail.jsp new file mode 100644 index 0000000..3d398d6 --- /dev/null +++ b/src/WebContent/save_fail.jsp @@ -0,0 +1,96 @@ +<%@ page + import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*" + language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + +<% + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41364, + LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get result message + */ + MessageView message = (MessageView) session + .getAttribute(SessionKeys.RESULT_MESSAGE); + + String errorMessage = ""; + int errorNumber = 0; + String category = ""; + + if (message != null) { + errorMessage = message.getMessage(); + errorNumber = message.getErrno(); + category = message.getCategory(); + session.setAttribute(SessionKeys.RESULT_MESSAGE, null); + } + + /* + * get cluster status + */ + L7guiFramework framework = new L7guiFramework(); + ClusterData cd = framework.getClusterData(); + if (cd == null) { + MessageView error = new MessageView(41365, + LogCategorySet.GUI_IO_COMMAND, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if (cd.self_status == ClusterStatus.ACTIVE) { + cssSeat = "l7gui_act_style.css"; + } else if (cd.self_status == ClusterStatus.STANDBY) { + cssSeat = "l7gui_sby_style.css"; + } +%> + + + + + + + + + + + + + + Failed : Save Resources + + + + + + +
+ +

Failed : Save Resources

+<% if ( (message != null) && (errorMessage != null) ){ +%> +

Error Reason :

+

[<%=category%>-<%=errorNumber%>]

+

<%=errorMessage%>

+<%} +%> +
+ + diff --git a/src/WebContent/savesync_executive.jsp b/src/WebContent/savesync_executive.jsp new file mode 100644 index 0000000..7c35800 --- /dev/null +++ b/src/WebContent/savesync_executive.jsp @@ -0,0 +1,98 @@ +<%@ page import="org.ultramonkey.l7.model.*, + org.ultramonkey.l7.controller.*, + org.ultramonkey.l7.view.*" + language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> + + +<% + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41366, LogCategorySet.GUI_USER_AUTHENTICATION, Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get sessionTrans + */ + SessionTransData sessionTrans = (SessionTransData) session.getAttribute(SessionKeys.PAGE_TRANSDATA); + if (sessionTrans == null){ + MessageView error = new MessageView(41367, LogCategorySet.GUI_SAVE_SYNC, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + String successpage = sessionTrans.destURI; + String failpage = sessionTrans.errorURI; + + /* + * get thread status + */ + String threadStatus = (String) session.getAttribute(SessionKeys.THREAD_STATUS); + if (threadStatus == null) { + MessageView error = new MessageView(41368, LogCategorySet.GUI_SAVE_SYNC, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + if((successpage == null) || (failpage == null)){ + MessageView error = new MessageView(41369, LogCategorySet.GUI_SAVE_SYNC, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + else { + if (threadStatus.equals(SessionKeys.THREAD_SUCCESS)){ + response.sendRedirect(successpage); + return; + } + else if (threadStatus.equals(SessionKeys.THREAD_RUNNING)){ + // nothing to do + } + else if (threadStatus.equals(SessionKeys.THREAD_FAIL)){ + response.sendRedirect(failpage); + return; + } + else { + MessageView error = new MessageView(41370, LogCategorySet.GUI_SAVE_SYNC, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + } +%> + + + + + + + + + + + + + + + + + Running : Save and Sync + + + + +

Running : Save and Sync

+

Please wait.

+ + + + diff --git a/src/WebContent/snmp.jsp b/src/WebContent/snmp.jsp new file mode 100644 index 0000000..dd39060 --- /dev/null +++ b/src/WebContent/snmp.jsp @@ -0,0 +1,222 @@ + +<%@ page import="org.ultramonkey.l7.model.*, + org.ultramonkey.l7.controller.*, + org.ultramonkey.l7.view.*" + language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> + +<% + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41371, LogCategorySet.GUI_USER_AUTHENTICATION, Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get result message + */ + MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE); + String errorMessage = ""; + int errorNumber = 0; + String category = ""; + if (message != null) { + errorMessage = message.getMessage(); + errorNumber = message.getErrno(); + category = message.getCategory(); + session.setAttribute(SessionKeys.RESULT_MESSAGE, null); + } + + /* + * get command message + */ + MessageView commandmessage = (MessageView) session.getAttribute(SessionKeys.COMMAND_MESSAGE); + String commandMessage = ""; + int commandNumber = 0; + String commandCategory = ""; + if (commandmessage != null) { + commandMessage = commandmessage.getMessage(); + commandNumber = commandmessage.getErrno(); + commandCategory = commandmessage.getCategory(); + session.setAttribute(SessionKeys.COMMAND_MESSAGE, null); + } + + /* + * get validation error message + */ + String invalidMessage = ""; + invalidMessage = (String)session.getAttribute(SessionKeys.INVALID_MESSAGE); + session.setAttribute(SessionKeys.INVALID_MESSAGE, null); + + /* + * get SnmpAgentData + */ + SnmpAgentData input_snmp = (SnmpAgentData)session.getAttribute(SessionKeys.INPUT_SNMP); + String unit_snmpInterval = (String)session.getAttribute(SessionKeys.INPUT_SNMP_UNIT); + SnmpAgentData snmp = new SnmpAgentData(); + L7guiFramework framework = new L7guiFramework(); + + //from session + if(input_snmp != null){ + snmp = input_snmp ; + } + //from Framework + else{ + snmp = framework.getSnmpAgentData(); + if ( snmp == null ){ + MessageView error = new MessageView(41372, LogCategorySet.GUI_SNMP, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + if((snmp.interval >= 1) && (snmp.interval <= 999)){ + unit_snmpInterval = "ms"; + } + else if(snmp.interval >= 1000){ + unit_snmpInterval = "s"; + snmp.interval /= 1000; + } + else{ + unit_snmpInterval = "ms"; + } + } + session.setAttribute(SessionKeys.INPUT_SNMP, null); + session.setAttribute(SessionKeys.INPUT_SNMP_UNIT, null); + + /* + * get cluster status + */ + ClusterData cd = framework.getClusterData(); + if (cd == null) { + MessageView error = new MessageView(41373, LogCategorySet.GUI_IO_COMMAND, Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if ( cd.self_status == ClusterStatus.ACTIVE ){ + cssSeat = "l7gui_act_style.css"; + } + else if ( cd.self_status == ClusterStatus.STANDBY ){ + cssSeat = "l7gui_sby_style.css"; + } + +%> + + + + + + + + + + + + + + + + + SNMP Agent + + + + + + +
+

SNMP Agent

+ + <% + if (message != null) { + %> +

[<%=category %>-<%=errorNumber %>]

+

<%=errorMessage %>

+ <% + } + %> + <% + if (commandmessage != null) { + %> +

[<%=commandCategory %>-<%=commandNumber %>]

+

<%=commandMessage %>

+ <% + } + %> + +
+ +
+ SNMP Agent Current Status + + + + + + +
+ + + <% + if((null != invalidMessage) && (snmp.interval == 1)){ + out.print(""); + } + else if(invalidMessage != null){ + out.print(""); + } + else{ + out.print(""); + } + %> + + + <% + if( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + %> +
+

1-999(msec/sec)

+
+
+ + + <% + if (cd.self_status == ClusterStatus.ACTIVE || cd.self_status == ClusterStatus.STANDBY) { + %> + + <% + } + %> + +
+ <%-- // Delete when SNMP Agent finish.--%> + <% if (snmp.status == SnmpAgentStatus.CONNECTING) { %> +

MIB Download

+

Please push the following button,if you would like to download the SNMP MIB related to the UltraMonkey-L7.

+
+ +
+ <% + } + %> + +
+ + + diff --git a/src/WebContent/snmp_modify_executive.jsp b/src/WebContent/snmp_modify_executive.jsp new file mode 100644 index 0000000..926cf7a --- /dev/null +++ b/src/WebContent/snmp_modify_executive.jsp @@ -0,0 +1,76 @@ +<%@ page + import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*" + language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + +<% + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + // session.invalidate(); + MessageView error = new MessageView(41374, + LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get thread status + */ + + String threadStatus = (String) session + .getAttribute(SessionKeys.THREAD_STATUS); + + if (threadStatus == null) { + MessageView error = new MessageView(41375, LogCategorySet.GUI_SNMP, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } else if (threadStatus.equals(SessionKeys.THREAD_RUNNING)) { + // + } else if (threadStatus.equals(SessionKeys.THREAD_SUCCESS)) { + response.sendRedirect(RedirectPages.SNMP_MODIFY); + return; + } else if (threadStatus.equals(SessionKeys.THREAD_FAIL)) { + response.sendRedirect(RedirectPages.SNMP_MODIFY_NG); + return; + } else { + MessageView error = new MessageView(41376, LogCategorySet.GUI_SNMP, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } +%> + + + + + + + + + + + + + + + + Modifying : SNMP Agent + + + +

Modifying : SNMP Agent

+

Please wait.

+ + + diff --git a/src/WebContent/snmp_modify_fail.jsp b/src/WebContent/snmp_modify_fail.jsp new file mode 100644 index 0000000..48bcb07 --- /dev/null +++ b/src/WebContent/snmp_modify_fail.jsp @@ -0,0 +1,96 @@ +<%@ page import="org.ultramonkey.l7.model.*, org.ultramonkey.l7.controller.*, org.ultramonkey.l7.view.*" + language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> + + +<% + /* + * check session + */ + if (session.isNew()) { + MessageView error = new MessageView(41377, LogCategorySet.GUI_USER_AUTHENTICATION, Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + + /* + * get command message + */ + MessageView message = (MessageView)session.getAttribute(SessionKeys.COMMAND_MESSAGE); + + String errorMessage = ""; + int errorNumber = 0; + String category = ""; + + if (message != null) { + errorMessage = message.getMessage(); + errorNumber = message.getErrno(); + category = message.getCategory(); + session.setAttribute(SessionKeys.COMMAND_MESSAGE, null); + } + + + /* + * get cluster status + */ + L7guiFramework framework = new L7guiFramework(); + ClusterData cd = framework.getClusterData(); + if (cd == null) { + MessageView error = new MessageView(41378, LogCategorySet.GUI_IO_COMMAND, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if ( cd.self_status == ClusterStatus.ACTIVE ){ + cssSeat = "l7gui_act_style.css"; + } + else if ( cd.self_status == ClusterStatus.STANDBY ){ + cssSeat = "l7gui_sby_style.css"; + } +%> + + + + + + + + + + + + + + Failed : Modify SNMP Agent + + + + + + + + + +
+

Failed : Modify SNMP Agent

+ +

Error Reason :

+<% + if (errorMessage != null) { + out.println("

[" + category + " - " + errorNumber + "]

"); + out.println("

" + errorMessage + "

"); + } +%> + +
+ + diff --git a/src/WebContent/so_executive.jsp b/src/WebContent/so_executive.jsp new file mode 100644 index 0000000..6c29edf --- /dev/null +++ b/src/WebContent/so_executive.jsp @@ -0,0 +1,74 @@ +<%@ page + import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*" + language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + +<% + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41379, + LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get thread status + */ + String threadStatus = (String) session + .getAttribute(SessionKeys.THREAD_STATUS); + if (threadStatus == null) { + MessageView error = new MessageView(41380, + LogCategorySet.GUI_REDUNDANT, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } else if (threadStatus.equals(SessionKeys.THREAD_RUNNING)) { + // nothing to do + } else if (threadStatus.equals(SessionKeys.THREAD_SUCCESS)) { + response.sendRedirect(RedirectPages.SO_OK); + return; + } else if (threadStatus.equals(SessionKeys.THREAD_FAIL)) { + response.sendRedirect(RedirectPages.SO_NG); + return; + } else { + MessageView error = new MessageView(41381, + LogCategorySet.GUI_REDUNDANT, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } +%> + + + + + + + + + + + + + + + + Running : Switch-Over + + + + +

Running : Switch-Over

+

Please wait.

+ + + diff --git a/src/WebContent/so_fail.jsp b/src/WebContent/so_fail.jsp new file mode 100644 index 0000000..4931f96 --- /dev/null +++ b/src/WebContent/so_fail.jsp @@ -0,0 +1,97 @@ +<%@ page + import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*" + language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + +<% + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41382, + LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get result message + */ + MessageView message = (MessageView) session + .getAttribute(SessionKeys.COMMAND_MESSAGE); + + String errorMessage = ""; + int errorNumber = 0; + String category = ""; + + if (message != null) { + errorMessage = message.getMessage(); + errorNumber = message.getErrno(); + category = message.getCategory(); + session.setAttribute(SessionKeys.COMMAND_MESSAGE, null); + } + + /* + * get cluster status + */ + L7guiFramework framework = new L7guiFramework(); + ClusterData cd = framework.getClusterData(); + if (cd == null) { + MessageView error = new MessageView(41383, + LogCategorySet.GUI_IO_COMMAND, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if (cd.self_status == ClusterStatus.ACTIVE) { + cssSeat = "l7gui_act_style.css"; + } else if (cd.self_status == ClusterStatus.STANDBY) { + cssSeat = "l7gui_sby_style.css"; + } +%> + + + + + + + + + + + + + + Failed : Switch-Over + + + + + + +
+

Failed : Switch-Over

+

Please try again.

+<% if ( (message != null) && (errorMessage != null) ) { +%> +

Error Reason :

+

[<%=category%>-<%=errorNumber%>]

+

<%=errorMessage%>

+<% +} +%> +
+ + diff --git a/src/WebContent/so_success.jsp b/src/WebContent/so_success.jsp new file mode 100644 index 0000000..07bc739 --- /dev/null +++ b/src/WebContent/so_success.jsp @@ -0,0 +1,125 @@ +<%@ page + import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*" + language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + +<% + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41384, + LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get VS IPaddress + */ + L7guiFramework framework = new L7guiFramework(); + ClusterData cd = framework.getClusterData(); + + String self = ""; + String other = ""; + + if (cd == null) { + MessageView error = new MessageView(41385, + LogCategorySet.GUI_IO_COMMAND, + Message.CLUSTER_DATA_ERROR); + session.setAttribute("resultMessage", error); + response.sendRedirect("index.jsp"); + return; + } else { + self = cd.self_ip; + other = cd.other_ip; + } + if ((self == null) || (other == null)) { + MessageView error = new MessageView(41386, + LogCategorySet.GUI_IO_COMMAND, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + session.setAttribute(SessionKeys.COMMAND_MESSAGE, null); + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if (cd.self_status == ClusterStatus.ACTIVE) { + cssSeat = "l7gui_act_style.css"; + } else if (cd.self_status == ClusterStatus.STANDBY) { + cssSeat = "l7gui_sby_style.css"; + } +%> + + + + + + + + + + + + + + Succeeded : Switch-Over + + + + + + +
+

Succeeded : Switch-Over

+
+Current Status + + + + + + + + + + + + + + + + +
+ + + Self Node + + Peer Node +
+ + + <%= cd.self_status %> + + <%= cd.other_status %> +
+ + + <%= cd.self_ip %> + + <%= cd.other_ip %> +
+
+
+ + diff --git a/src/WebContent/sync.jsp b/src/WebContent/sync.jsp new file mode 100644 index 0000000..3ff2331 --- /dev/null +++ b/src/WebContent/sync.jsp @@ -0,0 +1,224 @@ +<%@ page import="org.ultramonkey.l7.model.*, + org.ultramonkey.l7.controller.*, + org.ultramonkey.l7.view.*, java.util.*" + language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" +%> +<% + + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41387, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get result message + */ + MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE); + String errorMessage = ""; + int errorNumber = 0; + String category = ""; + if (message != null) { + errorMessage = message.getMessage(); + errorNumber = message.getErrno(); + category = message.getCategory(); + session.setAttribute(SessionKeys.RESULT_MESSAGE, null); + } + + /* + * get command message + */ + MessageView commandmessage = (MessageView) session.getAttribute(SessionKeys.COMMAND_MESSAGE); + String commandMessage = ""; + int commandNumber = 0; + String commandCategory = ""; + if (commandmessage != null) { + commandMessage = commandmessage.getMessage(); + commandNumber = commandmessage.getErrno(); + commandCategory = commandmessage.getCategory(); + session.setAttribute(SessionKeys.COMMAND_MESSAGE, null); + } + + /* + * get cluster status + */ + L7guiFramework framework = new L7guiFramework(); + ClusterData cd = framework.getClusterData(); + if (cd == null) { + MessageView error = new MessageView(41388, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + session.setAttribute("cd",cd); + + /* + * get sync status and get self/other IP + */ + String syncLogStatus = null; + String syncMonitorStatus = null; + String syncServiceStatus = null; + String syncRepStatus = null; + String syncSnmpStatus = null; + String syncGuiStatus = null; + String selfIp = null; + String otherIp = null; + + + if ( (cd.self_status == ClusterStatus.ACTIVE ) || (cd.self_status == ClusterStatus.STANDBY) ){ + // get sync Status + syncLogStatus = (String)session.getAttribute(SessionKeys.LOG_SYNC_STATE); + syncMonitorStatus = (String)session.getAttribute(SessionKeys.MONITOR_SYNC_STATE); + syncServiceStatus = (String)session.getAttribute(SessionKeys.VS_SYNC_STATE); + syncRepStatus = (String)session.getAttribute(SessionKeys.REP_SYNC_STATE); + syncSnmpStatus = (String)session.getAttribute(SessionKeys.SNMP_SYNC_STATE); + syncGuiStatus = (String)session.getAttribute(SessionKeys.GUI_SYNC_STATE); + if ( (syncLogStatus == null) || (syncMonitorStatus == null) || (syncServiceStatus == null) + || (syncRepStatus == null) || (syncSnmpStatus == null) || (syncGuiStatus == null) ){ + + MessageView error = new MessageView(41389, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + // get Self/Other IP + selfIp = cd.self_ip; + otherIp = cd.other_ip; + if ( (selfIp == null) || (otherIp == null) ){ + MessageView error = new MessageView(41390, LogCategorySet.GUI_IO_COMMAND, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + } + + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if ( cd.self_status == ClusterStatus.ACTIVE ){ + cssSeat = "l7gui_act_style.css"; + } + else if ( cd.self_status == ClusterStatus.STANDBY ){ + cssSeat = "l7gui_sby_style.css"; + } + + +%> + + + + + + + + + + + + + + + + Sync Resources + + + + + +
+ +

Sync Resources

+ <% if ( (cd.self_status != ClusterStatus.ACTIVE ) && (cd.self_status != ClusterStatus.STANDBY) ){ + %> +

"Sync Resources" function is effective only when cluster is applied.

+ <% + } + else { + + if (message != null) { + %> + +

[<%=category %>-<%=errorNumber %>]

+

<%=errorMessage %>

+ + <% + } + else if (commandmessage != null ){ + %> +

[<%=commandCategory %>-<%=commandNumber %>]

+

<%=commandMessage %>

+ <% + } + %> + + +
+
+ Sync Info +

<%= selfIp %> arrowlogo <%=otherIp %>

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Sync
CHECK
CategoryDescription
Log Log settings
MonitorMonitor settings
ServiceVirtualService settings
ReplicationReplication settings
SNMP AgentSNMP Agent settings
GUIGUI User Management (Users & Password)
+
+ + + +
+ <% + } + %> +
+ + \ No newline at end of file diff --git a/src/WebContent/sync_executive.jsp b/src/WebContent/sync_executive.jsp new file mode 100644 index 0000000..2d6a3ad --- /dev/null +++ b/src/WebContent/sync_executive.jsp @@ -0,0 +1,108 @@ +<%@ page + import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*" + language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + +<% + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41391, + LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get sync info (VS IPaddress) + */ + L7guiFramework framework = new L7guiFramework(); + ClusterData cd = framework.getClusterData(); + + String self = ""; + String other = ""; + + if (cd == null) { + MessageView error = new MessageView(41392, + LogCategorySet.GUI_IO_COMMAND, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } else { + self = cd.self_ip; + other = cd.other_ip; + } + + /* + * get thread status + */ + String threadStatus = (String) session + .getAttribute(SessionKeys.THREAD_STATUS); + if (threadStatus == null) { + MessageView error = new MessageView(41393, LogCategorySet.GUI_SYNC, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } else if (threadStatus == SessionKeys.THREAD_RUNNING) { + // nothing to do + } else if (threadStatus == SessionKeys.THREAD_SUCCESS) { + response.sendRedirect(RedirectPages.SYNC); + return; + } else if (threadStatus == SessionKeys.THREAD_FAIL) { + response.sendRedirect(RedirectPages.SYNC_NG); + return; + } else { + MessageView error = new MessageView(41394, LogCategorySet.GUI_SYNC, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } +%> + + + + + + + + + + + + + + + + Running : Sync Resources + + + + +

Running : Sync Resources

+

Please wait.

+ + +<% + if ((self != null) && (other != null)){ +%> +

<%=self %> (<%=cd.self_status %>) arrowlogo<%=other %> (<%=cd.other_status %>)

+ +<% + } +%> + + + + + diff --git a/src/WebContent/sync_fail.jsp b/src/WebContent/sync_fail.jsp new file mode 100644 index 0000000..b0f5911 --- /dev/null +++ b/src/WebContent/sync_fail.jsp @@ -0,0 +1,114 @@ +<%@ page + import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*" + language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + +<% + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41395, + LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get VS IPaddress + */ + L7guiFramework framework = new L7guiFramework(); + ClusterData cd = framework.getClusterData(); + + String self = ""; + String other = ""; + + if (cd == null) { + MessageView error = new MessageView(41396, + LogCategorySet.GUI_IO_COMMAND, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } else { + self = cd.self_ip; + other = cd.other_ip; + } + + if ((self == null) || (other == null)) { + MessageView error = new MessageView(41397, + LogCategorySet.GUI_IO_COMMAND, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get result message + */ + MessageView message = (MessageView) session + .getAttribute(SessionKeys.COMMAND_MESSAGE); + + String errorMessage = ""; + int errorNumber = 0; + String category = ""; + + if (message != null) { + errorMessage = message.getMessage(); + errorNumber = message.getErrno(); + category = message.getCategory(); + session.setAttribute(SessionKeys.COMMAND_MESSAGE, null); + } + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if (cd.self_status == ClusterStatus.ACTIVE) { + cssSeat = "l7gui_act_style.css"; + } else if (cd.self_status == ClusterStatus.STANDBY) { + cssSeat = "l7gui_sby_style.css"; + } +%> + + + + + + + + + + +Failed : Sync Resources + + + + + + +
+

Failed : Sync Resources

+

Sync failed.

+ +

<%=self%> (<%=cd.self_status %>) arrowlogo<%=other %> (<%=cd.other_status %>)

+ +<% if ( (message != null ) && (errorMessage != null)){ +%> +

Error Reason :

+

[<%=category%>-<%=errorNumber%>]

+

<%=errorMessage%>

+<% +} +%> +
+ + diff --git a/src/WebContent/top.jsp b/src/WebContent/top.jsp new file mode 100644 index 0000000..5e91401 --- /dev/null +++ b/src/WebContent/top.jsp @@ -0,0 +1,643 @@ +<%@ page import="org.ultramonkey.l7.model.*, org.ultramonkey.l7.controller.*, org.ultramonkey.l7.view.*, java.util.*" + language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<% + + /* + * check session + */ + if (session.isNew()) { + MessageView error = new MessageView(41398, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get result message + */ + MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE); + String errorMessage = null; + int errorNumber = 0; + String category = ""; + if ( (message != null) && (errorMessage != null) ) { + errorMessage = message.getMessage(); + errorNumber = message.getErrno(); + category = message.getCategory(); + session.setAttribute(SessionKeys.RESULT_MESSAGE, null); + } + + /* + * get l7vsadm data from L7guiFramework + */ + L7guiFramework framework = new L7guiFramework(); + L7vsAdmData admDataList = framework.getAdmData(); + if (admDataList == null) { + MessageView error = new MessageView(41399, LogCategorySet.GUI_VIRTUALSERVICE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get directord data from L7guiFramework + */ + DirectorData dd = framework.getDirectorData(); + if (dd == null){ + MessageView error = new MessageView(41400, LogCategorySet.GUI_IO_FILE, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + String checkTimeout = dd.checkTimeOut; + if ( (checkTimeout == null) || (checkTimeout.length() == 0) ) + checkTimeout = "-"; + else + checkTimeout = checkTimeout + " [sec]"; + + String negotiateTimeOut = dd.negotiateTimeOut; + if ( (negotiateTimeOut == null) || (negotiateTimeOut.length() == 0) ) + negotiateTimeOut = "-"; + else + negotiateTimeOut = negotiateTimeOut + " [sec]"; + + String checkInterval = dd.checkInterval; + if ( (checkInterval == null) || (checkInterval.length() == 0) ) + checkInterval = "-"; + else + checkInterval = checkInterval + " [sec]"; + + String checkCount = dd.checkCount; + if ( (checkCount == null) || (checkCount.length() == 0) ) + checkCount = "-"; + else + checkCount = checkCount + " [times]"; + + String callback = dd.callback; + if ( (callback == null) || (callback.length() == 0) ) + callback = "-"; + + String fallback = dd.fallback; + if ( (fallback == null) || (fallback.length() == 0) ) + fallback = "-"; + + String logFile = dd.logfile; + if ( (logFile == null) || (logFile.length() == 0) ) + logFile = "-"; + String execute = dd.execute; + if ( (execute == null) || (execute.length() == 0) ) + execute = "-"; + + String supervised = dd.supervised; + if ( (supervised == null) || (supervised.length() == 0) ) + supervised = "-"; + + String quiescent = dd.quiescent; + if ( (quiescent == null) || (quiescent.length() == 0) ) + quiescent = "-"; + + + /* + * get cluster status and fix css seat + */ + ClusterData cd = framework.getClusterData(); + if (cd == null) { + MessageView error = new MessageView(41401, LogCategorySet.GUI_IO_COMMAND, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + // IP CHECK + String selfIp = cd.self_ip; + String otherIp = cd.other_ip; + + if ( selfIp == null ) + selfIp = ""; + if (otherIp == null ) + otherIp = ""; + + + /* + * get snmpAgent Data + */ + SnmpAgentData snmp = framework.getSnmpAgentData(); + if ( snmp == null ) { + MessageView error = new MessageView(41402, LogCategorySet.GUI_IO_COMMAND, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + int query = snmp.interval; + String queryUnit = "[msec]"; + if (query > 1000){ + query = query / 1000 ; + queryUnit = "[sec]"; + } + + /* + * get replication Data + */ + ReplicationData rep = framework.getReplicationData(); + if ( rep == null ) { + MessageView error = new MessageView(41403, LogCategorySet.GUI_IO_COMMAND, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + ReplicationStatus repStatus = rep.replicationMode; + String printRepStatus = null; + switch (repStatus){ + case MASTER: + printRepStatus = "Master Running"; + break; + case SLAVE: + printRepStatus = "Slave Running"; + break; + case MASTER_STOP: + printRepStatus = "Master Stopped"; + break; + case SLAVE_STOP: + printRepStatus = "Slave Stopped"; + break; + case SINGLE: + printRepStatus = "Replication Invalid"; + break; + case OUT: + printRepStatus = "In Starting Replication"; + break; + default : + MessageView error = new MessageView(41404, LogCategorySet.GUI_IO_COMMAND, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + + + /* + * get process status + */ + String l7vsdStatus = "Out of Service"; + String l7vsdClass = "error"; + String l7direcotordStatus = "Out of Service"; + String l7directordClass = "error"; + String snmpAgentStatus = "Out of Service"; + String snmpAgentClass = "error" ; + String replicationStatus = "Out of Service"; + String replicationClass = "side_error"; + String clusterStatus = null; + String clusterClass = "error"; + + // fix l7vsd Status + if ( framework.getL7vsdProcessStatus() ){ + l7vsdStatus = "In Service"; + l7vsdClass = "ins"; + } + + // fix l7direcotord Status + if ( framework.getL7directordProcessStatus() ){ + l7direcotordStatus = "In Service"; + l7directordClass = "ins"; + } + + // fix snmpAgent Status + if ( snmp.status == SnmpAgentStatus.CONNECTING ){ + snmpAgentStatus = "In Service"; + snmpAgentClass = "ins"; + } + + // fix replication Status + if ( rep.replicationMode != ReplicationStatus.SINGLE && rep.replicationMode != ReplicationStatus.OUT ){ + replicationStatus = "In Service"; + replicationClass = "side_ins"; + } + + // fix Cluster Status + if ( (cd.self_status.equals(ClusterStatus.ACTIVE)) || (cd.self_status.equals(ClusterStatus.STANDBY)) ){ + clusterStatus = "In Service"; + if (cd.self_status.equals(ClusterStatus.ACTIVE) ) + clusterClass = "ins"; + } + + + /* + * fix css seat + */ + String cssSeat = "l7gui_single_style.css"; + if ( cd.self_status == ClusterStatus.ACTIVE ){ + cssSeat = "l7gui_act_style.css"; + } + else if ( cd.self_status == ClusterStatus.STANDBY ){ + cssSeat = "l7gui_sby_style.css"; + } + +%> + + + + + + + + + + + + + + + + GUI Console TOP + + + + + + + +
+ +

GUI Console TOP

+

UltraMonkey-L7 Service

+ +
+ UltraMoneky-L7 Service : Current status + + + <% + if (clusterStatus != null){ + %> + + + + + <% + } + %> + + + + + + <% + if (clusterStatus != null){ + %> + + <% + } + %> + + + + + + + <% if (cd.self_status == ClusterStatus.ACTIVE || cd.self_status == ClusterStatus.STANDBY){ + %> + + <% + } + %> + +
+ + + +
+ + + + + + + + + +
<%=l7vsdStatus %><%=l7direcotordStatus %><%=snmpAgentStatus %><%=replicationStatus %><%= clusterStatus %>
+
+ + +

Redundancy

+
+ Redundancy : Current Status + + + + + + + + + + + + + <% if (cd.self_status != ClusterStatus.SINGLE){ + %> + + + + + + <% } + %> +
+ + + + + +
+ Self Node + + <%= cd.self_status %> + + <%= selfIp %> +
+ Peer Node + + <%= cd.other_status %> + + <%= otherIp %> +
+
+ + +

VirtualService

+ <% if ( (cd.self_status.equals(ClusterStatus.ACTIVE)) || (cd.self_status.equals(ClusterStatus.SINGLE) )){ + %> + <% + /* + * get VirtualService data from L7guiFramework + */ + Vector vsList = new Vector(); + vsList = admDataList.virtualSettings; + ArrayList vsNameList = new ArrayList(); + vsNameList.clear(); + + String vsIp = null; + String vsPort = null; + String vsProtomod = null; + String vsOption = null; + String vsSchedule = null; + String rsIP = null; + String rsPort = null; + int rsWeight = 0; + long activeConnections = 0; + long inactiveConnections = 0; + String vsSorryFlag = null; + + if ( vsList.size() > 0 ){ + %> +
+ VirtualService : Current Status + + + + + + + + + + + + + + + + + + + <% + for (int i = 0; i < vsList.size(); i++) { + try { + VirtualSetting getVirtualSetting = vsList.get(i); + + vsIp = getVirtualSetting.virtual.host; + vsPort = getVirtualSetting.virtual.port; + vsProtomod = getVirtualSetting.protomod; + vsOption = getVirtualSetting.option; + vsSchedule = getVirtualSetting.sched; + + Vector getRsList =getVirtualSetting.real; + int rsNumber = getRsList.size(); + if ( rsNumber < 0 ){ + rsNumber = 1; + } + + boolean vsSorry = getVirtualSetting.sorryflag; + + if ( (vsIp == null) || (vsProtomod == null) || (vsOption == null) ){ + MessageView error = new MessageView(41405, LogCategorySet.GUI_VIRTUALSERVICE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + %> + + + + + + + <% + if ( rsNumber < 1 ){ + %> + + + + + + <% + } + else{ + EndPoint getRs = getRsList.get(0); + rsIP = getRs.host; + rsPort = getRs.port; + rsWeight = getRs.weight; + activeConnections = getRs.actConn; + inactiveConnections = getRs.inActConn; + %> + + + + + + <% + } + if(vsSorry == true){ + vsSorryFlag = "On"; + } + else { + vsSorryFlag = "Off"; + } + %> + + + <% + for ( int j = 1; j < rsNumber; j++ ){ + EndPoint addedGetRs = getRsList.get(j); + rsIP = addedGetRs.host; + rsPort = addedGetRs.port; + rsWeight = addedGetRs.weight; + activeConnections = addedGetRs.actConn; + inactiveConnections = addedGetRs.inActConn; + %> + + + + + + + + <% + } + %> + + <% + }catch(NullPointerException e){ + MessageView error = new MessageView(41406, LogCategorySet.GUI_VIRTUALSERVICE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + } + %> +
+ + + + + +
+ + + + + + + + + + + + + + + + + + + +
<%=vsIp%><%=vsPort%><%=vsProtomod%><%=vsOption%><%=vsSchedule%>-----<%=rsIP%><%=rsPort%><%=rsWeight%><%=activeConnections%><%=inactiveConnections%><%=vsSorryFlag %>
<%=rsIP%><%=rsPort%><%=rsWeight%><%=activeConnections%><%=inactiveConnections%>
+
+ <% + } + else { + %> +

No VirtualService List

+ <% + } + } + else{ + %> +

No VirtualService List

+ <% + } + %> + +

Monitor

+
+ Monitor : Current Status + + + + + + + + + + + + + + + +
+ + + + + + + + + +
<%=checkTimeout%><%=negotiateTimeOut%><%=checkInterval%><%=checkCount%><%=quiescent%>
+
+ + + <% + if (snmp.status == SnmpAgentStatus.CONNECTING) { + %> +

SNMP Agent

+
+ SNMP Agent : Current Status + + + + + + + +
+ +
<%=query %> <%=queryUnit %>
+
+ <% + } + %> + + <% + if ( rep.replicationMode != ReplicationStatus.SINGLE ){ + %> +

Replication

+
+ Replication : Current Status + + + + + + + + + +
+ + + +
<%=printRepStatus %><%=rep.interval %> [µsec]
+
+ <% + } + %> + +
+ + + diff --git a/src/WebContent/um7state_info.jsp b/src/WebContent/um7state_info.jsp new file mode 100644 index 0000000..6865a3b --- /dev/null +++ b/src/WebContent/um7state_info.jsp @@ -0,0 +1,351 @@ +<%@ page import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*,java.util.*" + language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<% + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41407, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + + /* + * get l7vsadm data from L7guiFramework + */ + L7guiFramework framework = new L7guiFramework(); + L7vsAdmData admDataList = framework.getAdmData(); + if (admDataList == null) { + MessageView error = new MessageView(41408, LogCategorySet.GUI_VIRTUALSERVICE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + + /* + * get l7directrod.cf data + */ + DirectorData dd = framework.getDirectorData(); + if (dd == null) { + MessageView error = new MessageView(41409, LogCategorySet.GUI_IO_FILE, + Message.DIRECTOR_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get cluster status + */ + ClusterData cd = framework.getClusterData(); + if (cd == null) { + MessageView error = new MessageView(41410, LogCategorySet.GUI_IO_COMMAND, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if ( cd.self_status == ClusterStatus.ACTIVE ){ + cssSeat = "l7gui_act_style.css"; + } + else if ( cd.self_status == ClusterStatus.STANDBY ){ + cssSeat = "l7gui_sby_style.css"; + } +%> + + + + + + + + + + + + + + + UltraMonkey-L7 Current Status + + + + +
+ +

VirtualService Current Status

+<% + if ( (cd.self_status.equals(ClusterStatus.ACTIVE)) || (cd.self_status.equals(ClusterStatus.SINGLE) )){ + + MessageView mv = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE); + String message = null; + int errno = 0; + String category = null; + + if (mv != null) { + message = mv.getMessage(); + errno = mv.getErrno(); + category = mv.getCategory(); + if ( message != null){ + out.println("

[" + category + "-" + errno + "]

" ); + out.println("

" + message + "

"); + } + session.setAttribute(SessionKeys.RESULT_MESSAGE,null); + } + %> + + + <% + MessageView mvCommand = (MessageView) session.getAttribute(SessionKeys.COMMAND_MESSAGE); + String commandMessage = null; + int commandErrno = 0; + String commandCategory = null; + if (mvCommand != null) { + commandMessage = mvCommand.getMessage(); + commandErrno = mvCommand.getErrno(); + commandCategory = mvCommand.getCategory(); + if ( commandMessage != null ){ + out.println("

[" + commandCategory + "-" + commandErrno + "]

" ); + out.println("

" + commandMessage + "

"); + } + session.setAttribute(SessionKeys.COMMAND_MESSAGE,null); + } + %> + +
+ <% + /* + * get VirtualService data from L7guiFramework + */ + Vector vsList = new Vector(); + vsList = admDataList.virtualSettings; + ArrayList vsNameList = new ArrayList(); + vsNameList.clear(); + + String vsIp = null; + String vsPort = null; + String vsProtomod = null; + String vsOption = null; + String vsSchedule = null; + String rsIP = null; + String rsPort = null; + int rsWeight = 0; + long activeConnections = 0; + long inactiveConnections = 0; + String vsSorryFlag = null; + + if (vsList.size() > 0) { + %> +
+ Virtual Service List + + + + + + + + + + + + + + + + + + + + <% + for (int i = 0; i < vsList.size(); i++) { + try { + VirtualSetting getVirtualSetting = vsList.get(i); + + vsIp = getVirtualSetting.virtual.host; + vsPort = getVirtualSetting.virtual.port; + vsProtomod = getVirtualSetting.protomod; + vsOption = getVirtualSetting.option; + vsSchedule = getVirtualSetting.sched; + + Vector getRsList =getVirtualSetting.real; + int rsNumber = getRsList.size(); + if ( rsNumber < 0 ){ + rsNumber = 1; + } + + boolean vsSorry = getVirtualSetting.sorryflag; + + if ( (vsIp == null) || (vsProtomod == null) || (vsOption == null) ){ + MessageView error = new MessageView(41411, LogCategorySet.GUI_VIRTUALSERVICE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + vsNameList.add(vsIp + ":" + vsPort + ":" + vsProtomod + ":" + vsOption); + %> + + + + + + + + + <% + if ( rsNumber < 1 ){ + %> + + + + + + <% + } + else{ + EndPoint getRs = getRsList.get(0); + rsIP = getRs.host; + rsPort = getRs.port; + rsWeight = getRs.weight; + activeConnections = getRs.actConn; + inactiveConnections = getRs.inActConn; + %> + + + + + + <% + } + if(vsSorry == true){ + vsSorryFlag = "On"; + } + else { + vsSorryFlag = "Off"; + } + %> + + + <% + for ( int j = 1; j < rsNumber; j++ ){ + EndPoint addedGetRs = getRsList.get(j); + rsIP = addedGetRs.host; + rsPort = addedGetRs.port; + rsWeight = addedGetRs.weight; + activeConnections = addedGetRs.actConn; + inactiveConnections = addedGetRs.inActConn; + %> + + + + + + + + <% + } + %> + + <% + }catch(NullPointerException e){ + MessageView error = new MessageView(41412, LogCategorySet.GUI_VIRTUALSERVICE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + } + %> +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
<%=vsIp%><%=vsPort%><%=vsProtomod%><%=vsOption%><%=vsSchedule%>-----<%=rsIP%><%=rsPort%><%=rsWeight%><%=activeConnections%><%=inactiveConnections%><%=vsSorryFlag %>
<%=rsIP%><%=rsPort%><%=rsWeight%><%=activeConnections%><%=inactiveConnections%>
+
+ <% + } + %> + +

Add a New VirtualService

+

Please push the following button, if you would like to add a new virtualService.


+ + + + <% + if (vsList.size() > 0) { + %> +

Modify a VirtualService

+

Please select and push the following button, if you would like to modify a virtualService.


+ + + +

Remove a VirtualService

+

Please select and push the following button, if you would like to remove a virtualService.


+ + + <% + if (dd.autoreload == true) { + %> + + <% + if (cd.self_status == ClusterStatus.ACTIVE || cd.self_status == ClusterStatus.STANDBY) { + %> + + <% + } + } + } + %> + + + <% + } + else{ + response.sendRedirect(RedirectPages.TOPMENU); + return; + + } + %> +
+ + + + diff --git a/src/WebContent/user_add.jsp b/src/WebContent/user_add.jsp new file mode 100644 index 0000000..6f4514b --- /dev/null +++ b/src/WebContent/user_add.jsp @@ -0,0 +1,213 @@ +<%@ page import="org.ultramonkey.l7.model.*, + org.ultramonkey.l7.controller.*, + org.ultramonkey.l7.view.*, java.util.*" + language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" +%> +<% + + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41413, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + + /* + * get result message + */ + MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE); + String errorMessage = ""; + int errorNumber = 0; + String category = ""; + if (message != null) { + errorMessage = message.getMessage(); + errorNumber = message.getErrno(); + category = message.getCategory(); + session.setAttribute(SessionKeys.RESULT_MESSAGE, null); + } + + /* + * get user info + */ + UserManager user = UserManager.getInstance(); + Vector userList; + try { + userList = user.getUserList(); + } + catch(Exception e){ + MessageView error = new MessageView(41414, LogCategorySet.GUI_IO_FILE, + Message.READ_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + if ( userList == null ){ + MessageView error = new MessageView(41415, LogCategorySet.GUI_IO_FILE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + int userCount = userList.size(); + + /* + * get Input User Data + */ + UserData inputUser = (UserData)session.getAttribute(SessionKeys.INPUT_USERDATA); + if ( inputUser != null ){ + session.setAttribute(SessionKeys.INPUT_USERDATA, null); + } + + + /* + * get cluster status + */ + L7guiFramework framework = new L7guiFramework(); + ClusterData cd = framework.getClusterData(); + if (cd == null) { + MessageView error = new MessageView(41416, LogCategorySet.GUI_IO_COMMAND, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if ( cd.self_status == ClusterStatus.ACTIVE ){ + cssSeat = "l7gui_act_style.css"; + } + else if ( cd.self_status == ClusterStatus.STANDBY ){ + cssSeat = "l7gui_sby_style.css"; + } + +%> + + + + + + + + + + + + + + + + + Add User + + + + + +
+ +

Add User

+ + <% if ( userCount >= 16){ + %> +

<%=Message.USER_MAX %>

+ <% + } + else { + if (message != null) { + %> +

[<%=category %> - <%=errorNumber %>]

+

<%=errorMessage %>

+ <% + } + %> + +
+ +
+ Add User Info + + + + + + + + + + + + + + + + + + + + + +
+ + + <% if ( (inputUser != null) && (inputUser.userName != null) ){ %> + + <%} + else {%> + + <%} %> + +

Required Field

+

Between 1 and 16 one-byte characters in English

+
+ + + <% if ( (inputUser != null) && (inputUser.description != null) ){ %> + + <% } + else{ + %> + + <% + } + %> + +

Up to 64 one-byte characters in English

+
+ + + + +

Required Field

+

Between 6 and 16 one-byte characters in English

+
+ + + + +

Required Field

+

Between 6 and 16 one-byte characters in English

+
+
+ +
+ + + +
+ <% + } + %> +
+ + diff --git a/src/WebContent/user_add_fail.jsp b/src/WebContent/user_add_fail.jsp new file mode 100644 index 0000000..02b5645 --- /dev/null +++ b/src/WebContent/user_add_fail.jsp @@ -0,0 +1,105 @@ +<%@ page + import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*" + language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + +<% + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41417, + LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get result message + */ + + MessageView message = (MessageView) session + .getAttribute(SessionKeys.RESULT_MESSAGE); + + String errorMessage = ""; + int errorNumber = 0; + String category = ""; + + if (message != null) { + errorMessage = message.getMessage(); + errorNumber = message.getErrno(); + category = message.getCategory(); + session.setAttribute(SessionKeys.RESULT_MESSAGE, null); + } + + /* + * get cluster status + */ + L7guiFramework framework = new L7guiFramework(); + ClusterData cd = framework.getClusterData(); + if (cd == null) { + MessageView error = new MessageView(41418, + LogCategorySet.GUI_IO_COMMAND, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if (cd.self_status == ClusterStatus.ACTIVE) { + cssSeat = "l7gui_act_style.css"; + } else if (cd.self_status == ClusterStatus.STANDBY) { + cssSeat = "l7gui_sby_style.css"; + } +%> + + + + + + + + + + + + + + + Failed : Add User + + + + + + + + + +
+

Failed : Add User

+ +<% + if (errorMessage != null) { + out.println("

Error Reason :

"); + out.println("

[" + category + " - " + errorNumber + "]

"); + out.println("

" + errorMessage + "

"); + } +%> +
+ + + + + diff --git a/src/WebContent/user_delete_fail.jsp b/src/WebContent/user_delete_fail.jsp new file mode 100644 index 0000000..23e986e --- /dev/null +++ b/src/WebContent/user_delete_fail.jsp @@ -0,0 +1,99 @@ +<%@ page + import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*" + language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + +<% + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41419, + LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get result message + */ + + MessageView message = (MessageView) session + .getAttribute(SessionKeys.RESULT_MESSAGE); + + String errorMessage = ""; + int errorNumber = 0; + String category = ""; + + if (message != null) { + errorMessage = message.getMessage(); + errorNumber = message.getErrno(); + category = message.getCategory(); + session.setAttribute(SessionKeys.RESULT_MESSAGE, null); + } + + /* + * get cluster status + */ + L7guiFramework framework = new L7guiFramework(); + ClusterData cd = framework.getClusterData(); + if (cd == null) { + MessageView error = new MessageView(41420, + LogCategorySet.GUI_IO_COMMAND, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if (cd.self_status == ClusterStatus.ACTIVE) { + cssSeat = "l7gui_act_style.css"; + } else if (cd.self_status == ClusterStatus.STANDBY) { + cssSeat = "l7gui_sby_style.css"; + } +%> + + + + + + + + + + + + + + + + Failed : Delete User + + + + + + +
+

Failed : Delete User

+ +<% + if (errorMessage != null) { + out.println("

Error Reason :

"); + out.println("

[" + category + " - " + errorNumber + "]

"); + out.println("

" + errorMessage + "

"); + } +%> +
+ + diff --git a/src/WebContent/user_manage.jsp b/src/WebContent/user_manage.jsp new file mode 100644 index 0000000..4bfadc9 --- /dev/null +++ b/src/WebContent/user_manage.jsp @@ -0,0 +1,198 @@ +<%@ page import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*,java.util.*" + language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" +%> +<% + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41421, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + + /* + * get self info + */ + UserData currentUser = (UserData) session.getAttribute(SessionKeys.LOGIN_SESSION); + if ( currentUser == null) { + MessageView error = new MessageView(41422, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + String currentUserName = currentUser.userName; + if (currentUserName == null){ + MessageView error = new MessageView(41423, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get user info + */ + UserManager user = UserManager.getInstance(); + Vector userList; + try { + userList = user.getUserList(); + } + catch(Exception e){ + MessageView error = new MessageView(41424, LogCategorySet.GUI_IO_FILE, + Message.READ_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + if ( userList == null ){ + MessageView error = new MessageView(41425, LogCategorySet.GUI_IO_FILE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + + /* + * get result message + */ + MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE); + String errorMessage = ""; + int errorNumber = 0; + String category = ""; + String resultClass = "success"; + + if (message != null) { + errorMessage = message.getMessage(); + errorNumber = message.getErrno(); + category = message.getCategory(); + session.setAttribute(SessionKeys.RESULT_MESSAGE, null); + } + if (errorMessage.equals(Message.USER_REMOVE_SELECT_ERROR)) { + resultClass = "error"; + } + + + /* + * get cluster status + */ + L7guiFramework framework = new L7guiFramework(); + ClusterData cd = framework.getClusterData(); + if (cd == null) { + MessageView error = new MessageView(41426, LogCategorySet.GUI_IO_COMMAND, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if ( cd.self_status == ClusterStatus.ACTIVE ){ + cssSeat = "l7gui_act_style.css"; + } + else if ( cd.self_status == ClusterStatus.STANDBY ){ + cssSeat = "l7gui_sby_style.css"; + } +%> + + + + + + + + + + + + + + + + Manage Users + + + + + +
+ +

Manage Users

+ <% + if ( (message != null) && (errorMessage != null)) { + %> +

[<%=category%> - <%=errorNumber%>]

+

<%=errorMessage%>

+ <% + } + %> + + + +
+
+ Current User list + + + + + + + <% + for ( UserData userInfo : userList){ + out.println(""); + out.println(""); + out.println(""); + } + %> + +
Delete CHECKUser IDDescription
"); + if ( !userInfo.userName.equals(currentUserName) ) + out.println(""); + out.println(""+ userInfo.userName + ""); + if (userInfo.description != null){ + out.println(userInfo.description); + } + out.println("
+
+ + <% + int userCount = userList.size(); + if (userCount < 16){ + %> +

Add a New User

+

Please push the following button, if you add a new user.


+ + <% + } + %> + +

Modify User

+

Please push the following button, if you modify your account.


+ + + <% + if (userCount > 1) { + %> +

Delete Users

+

Please select and push the following button, if you delete user.


+ + <% + } + %> +
+ +
+ + diff --git a/src/WebContent/user_modify.jsp b/src/WebContent/user_modify.jsp new file mode 100644 index 0000000..b2d9191 --- /dev/null +++ b/src/WebContent/user_modify.jsp @@ -0,0 +1,182 @@ +<%@ page import="org.ultramonkey.l7.model.*, org.ultramonkey.l7.controller.*, org.ultramonkey.l7.view.*, java.util.*" + language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<% + + /* + * check session + */ + if (session.isNew()) { + MessageView error = new MessageView(41427, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + + /* + * get result message + */ + MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE); + String errorMessage = null; + int errorNumber = 0; + String category = ""; + if (message != null) { + errorMessage = message.getMessage(); + errorNumber = message.getErrno(); + category = message.getCategory(); + session.setAttribute(SessionKeys.RESULT_MESSAGE, null); + } + + /* + * get post user data + */ + UserData user = (UserData)session.getAttribute(SessionKeys.INPUT_USERDATA); + if ( user != null ){ + session.setAttribute(SessionKeys.INPUT_USERDATA, null); + } + + if (user == null ){ + user = (UserData)session.getAttribute(SessionKeys.LOGIN_SESSION); + if (user == null){ + MessageView error = new MessageView(41428, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + } + + if (user.description == null){ + user.description = ""; + } + + /* + * get cluster status + */ + L7guiFramework framework = new L7guiFramework(); + ClusterData cd = framework.getClusterData(); + if (cd == null) { + MessageView error = new MessageView(41429, LogCategorySet.GUI_IO_COMMAND, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if ( cd.self_status == ClusterStatus.ACTIVE ){ + cssSeat = "l7gui_act_style.css"; + } + else if ( cd.self_status == ClusterStatus.STANDBY ){ + cssSeat = "l7gui_sby_style.css"; + } + + +%> + + + + + + + + + + + + + + + + Modify User + + + + + + + + +
+ +

Modify User

+ + <% + if ((message != null) || (errorMessage != null)){ + %> +

[ <%=category %> - <%=errorNumber %>]

+

<%= errorMessage %>

+ <% + } + %> + +
+ +
+ Modify User Info + + + + + + + + + + + + + + + + + + + + + +
+ + + + +

Up to 64 one-byte characters in English

+
+ + + + +

Required Field

+
+ + + + +

Required Field

+

Up to 16 one-byte characters in English

+
+ + + + +

Required Field

+

Up to 16 one-byte characters in English

+
+
+ + +
+ + + +
+ +
+ + diff --git a/src/WebContent/user_modify_fail.jsp b/src/WebContent/user_modify_fail.jsp new file mode 100644 index 0000000..9260f52 --- /dev/null +++ b/src/WebContent/user_modify_fail.jsp @@ -0,0 +1,122 @@ +<%@ page + import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*" + language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + +<% + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41430, + LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get result message + */ + + MessageView message = (MessageView) session + .getAttribute(SessionKeys.RESULT_MESSAGE); + + String errorMessage = ""; + int errorNumber = 0; + String category = ""; + + if (message != null) { + errorMessage = message.getMessage(); + errorNumber = message.getErrno(); + category = message.getCategory(); + session.setAttribute(SessionKeys.RESULT_MESSAGE, null); + } + + /* + * get cluster status + */ + L7guiFramework framework = new L7guiFramework(); + ClusterData cd = framework.getClusterData(); + if (cd == null) { + MessageView error = new MessageView(41431, + LogCategorySet.GUI_IO_COMMAND, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if (cd.self_status == ClusterStatus.ACTIVE) { + cssSeat = "l7gui_act_style.css"; + } else if (cd.self_status == ClusterStatus.STANDBY) { + cssSeat = "l7gui_sby_style.css"; + } +%> + + + + + + + + + + + + + + + Failed : Modify User + + + + + + +
+

Failed : Modify User

+<% + /* + * get user id + */ + UserData user = (UserData) session.getAttribute(SessionKeys.LOGIN_SESSION); + String username = ""; + if (user != null) { + username = user.userName; + } else { + MessageView message_userid = new MessageView(41432, + LogCategorySet.GUI_USER_AUTHENTICATION, + Message.UNEXPECTED_ERROR); + session + .setAttribute(SessionKeys.RESULT_MESSAGE, + message_userid); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + if ((username != null) && (errorMessage != null)) { + out.println("

Failed To Modify " + username + + "'s User Info.

"); + out.println("

Please try agein.


"); + out.println("

Error Reason :

"); + out.println("

[" + category + " - " + errorNumber + "]

"); + out.println("

" + errorMessage + "

"); + } else { + out.println("

Failed To Modify User Info.

"); + out.println("

Please try agein.


"); + } +%> +
+ + + + diff --git a/src/WebContent/user_modify_success.jsp b/src/WebContent/user_modify_success.jsp new file mode 100644 index 0000000..fa9c4cb --- /dev/null +++ b/src/WebContent/user_modify_success.jsp @@ -0,0 +1,119 @@ +<%@ page + import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*" + language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + +<% + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41433, + LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get result message + */ + MessageView message = (MessageView) session + .getAttribute(SessionKeys.RESULT_MESSAGE); + + String errorMessage = ""; + int errorNumber = 0; + String category = ""; + + if (message != null) { + errorMessage = message.getMessage(); + errorNumber = message.getErrno(); + category = message.getCategory(); + session.setAttribute(SessionKeys.RESULT_MESSAGE, null); + } + + /* + * get cluster status + */ + L7guiFramework framework = new L7guiFramework(); + ClusterData cd = framework.getClusterData(); + if (cd == null) { + MessageView error = new MessageView(41434, + LogCategorySet.GUI_IO_COMMAND, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if (cd.self_status == ClusterStatus.ACTIVE) { + cssSeat = "l7gui_act_style.css"; + } else if (cd.self_status == ClusterStatus.STANDBY) { + cssSeat = "l7gui_sby_style.css"; + } +%> + + + + + + + + + + + + + + + + Succeeded : Modify User + + + + + + +
+

Succeeded : Modify User

+ +<% + /* + * get user id + */ + UserData user = new UserData(); + user = (UserData) session.getAttribute(SessionKeys.LOGIN_SESSION); + String username = ""; + + if (user != null) { + username = user.userName; + } else { + MessageView message_userid = new MessageView(41435, + LogCategorySet.GUI_USER_AUTHENTICATION, + Message.UNEXPECTED_ERROR); + session + .setAttribute(SessionKeys.RESULT_MESSAGE, + message_userid); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + if (username != null) { + out.println("

Succeeded to modify " + username + + "'s User Info.

"); + } else { + out.println("

Succeeded to modify User Info.

"); + } +%> +
+ + diff --git a/src/WebContent/vs_add.jsp b/src/WebContent/vs_add.jsp new file mode 100644 index 0000000..20f8b89 --- /dev/null +++ b/src/WebContent/vs_add.jsp @@ -0,0 +1,1290 @@ +<%@ page import="org.ultramonkey.l7.model.*, + org.ultramonkey.l7.controller.*, + org.ultramonkey.l7.view.*, java.util.*" + language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> + +<% + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41436, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + + /* + * get result message + */ + MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE); + String errorMessage = ""; + int errorNumber = 0; + String category = ""; + if (message != null) { + errorMessage = message.getMessage(); + errorNumber = message.getErrno(); + category = message.getCategory(); + session.setAttribute(SessionKeys.RESULT_MESSAGE, null); + } + + /* + * get validation error message + */ + HashMap errMessage = (HashMap) session.getAttribute(SessionKeys.INVALID_MESSAGE); + session.setAttribute(SessionKeys.INVALID_MESSAGE,null); + + /* + * get previous input value + */ + L7guiFramework framework = new L7guiFramework(); + VirtualSetting vs = (VirtualSetting) session.getAttribute(SessionKeys.INPUT_VS); + if (vs != null) { + session.setAttribute(SessionKeys.INPUT_VS, null); + } + + /* + * get l7directrod.cf data + */ + DirectorData dd = framework.getDirectorData(); + if (dd == null) { + MessageView error = new MessageView(41437, LogCategorySet.GUI_IO_FILE, + Message.DIRECTOR_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + + /* + * get cluster status + */ + ClusterData cd = framework.getClusterData(); + if (cd == null) { + MessageView error = new MessageView(41438, LogCategorySet.GUI_IO_COMMAND, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if ( cd.self_status == ClusterStatus.ACTIVE ){ + cssSeat = "l7gui_act_style.css"; + } + else if ( cd.self_status == ClusterStatus.STANDBY ){ + cssSeat = "l7gui_sby_style.css"; + } + +%> + + + + + + + + + + + + + + + + + + Add VirtualService + + + + +
+

Add a VirtualService

+<% +if ( (cd.self_status.equals(ClusterStatus.ACTIVE)) || (cd.self_status.equals(ClusterStatus.SINGLE) )){ + + if ( (message != null) && (errorMessage != null)) { +%> + +

[<%=category %> - <%=errorNumber %>]

+

<%=errorMessage %>

+ +<% + } +%> + +

VirtualService Info

+
+ + +
+ Basic Settings + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + <% + if ( null != errMessage ){ + String invalidMessage = errMessage.get("vip"); + if( null != invalidMessage ){ + out.println("

" + invalidMessage + "

"); + } + } + %> +
+

Required Field

+

[0-255].[0-255].[0-255].[0-255]

+
+ + + <% + { + String invalidMessage = null; + if ( null != errMessage ) { + invalidMessage = errMessage.get("port"); + } + + if ( (vs == null) || (vs.virtual.port == null) ){ + + out.println(""); + } + else{ + out.println(""); + } + if( null != invalidMessage ){ + out.println("

" + invalidMessage + "

"); + } + } + %> +
+

Required Field

+

1-65535, service name

+
+ + + + <% + if ( null != errMessage ){ + String invalidMessage = errMessage.get("protomod"); + if( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

Required Field

+
+ + + + <% + if ( null != errMessage ){ + String invalidMessage = errMessage.get("option"); + if( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

Up to 127 one-byte characters in English

+
+ + + + <% + if ( null != errMessage ){ + String invalidMessage = errMessage.get("sched"); + if( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

+
+
+
+ Advanced Settings + + + + + + + + + + + + + + + + +
+ + + <% { + String invalidMessage = null; + int unit_s = 0; + if ( null != errMessage ) { + invalidMessage = errMessage.get("qos_service"); + } + if ( (vs == null) || ( ( 0 == vs.qosservice ) && ( null != invalidMessage ) ) ){ + out.println(""); + } + else{ + if ( null == invalidMessage ){ + while ( (vs != null) && (vs.qosservice >= 1000) ) { + vs.qosservice /= 1000; + unit_s++; + } + } + out.println(""); + } + %> + + <% + if( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

0-999(bps/Kbps/Mbps/Gbps)

+
+ + + <% { + String invalidMessage = null; + int unit_c = 0; + if ( null != errMessage ) { + invalidMessage = errMessage.get("qos_conn"); + } + if ( (vs == null) || ( ( 0 == vs.qosclient ) && ( null != invalidMessage ) ) ){ + out.print(""); + } + else{ + if ( null == invalidMessage ){ + while ( (vs != null) && (vs.qosclient >= 1000) ) { + vs.qosclient /= 1000; + unit_c++; + } + } + out.print(""); + } + %> + + <% + if( null != invalidMessage ){ + out.println("

" + invalidMessage + "

"); + } + } + %> +
+

0-999(bps/Kbps/Mbps/Gbps)

+
+ + + <% + { + String invalidMessage = null; + if ( null != errMessage ) { + invalidMessage = errMessage.get("max_conn"); + } + if ( (vs == null) || ( ( 0 == vs.maxconn ) && ( null != invalidMessage ) ) ){ + out.println(""); + } + else{ + out.println(""); + } + if( null != invalidMessage ){ + out.println("

" + invalidMessage + "

"); + } + } + %> +
+

0-100000
Note : "0" means "Unlimited"

+
+
+ +
+ Monitor Settings +

Caution!! + Disable Area when you push "Apply" button.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + <% + { + String invalidMessage = null; + if ( null != errMessage ) { + invalidMessage = errMessage.get("timeout"); + } + if ( (vs == null) || (0 == vs.timeout) ){ + if ( dd.autoreload == true ) { + out.println(""); + } + else { + out.println(""); + } + } + else { + if ( dd.autoreload == true ) { + out.println(""); + } + else { + out.println(""); + } + } + if( null != invalidMessage ){ + out.println("

" + invalidMessage + "

"); + } + } + %> +
+

1-2147483647(sec)

+
+ + + <% + if ( dd.autoreload == true ) { + %> + + <% + } + else{ + %> + + <% + } + if ( null != errMessage ) { + String invalidMessage = errMessage.get("check_type"); + if( null != invalidMessage ){ + out.println("

" + invalidMessage + "

"); + } + } + %> +
+

Any Of The Following
negotiate, connect, ping, off, on, 0-9

+
+ + + <% if ( dd.autoreload == true ) {%> + + <%} + else + { + %> + + <% + } + if ( null != errMessage ) { + String invalidMessage = errMessage.get("check_service"); + if( null != invalidMessage ){ + out.println("

" + invalidMessage + "

"); + } + } + %> +
+

+
+ + + <%if (dd.autoreload == true) { %> + + <% + } + else + { + %> + + + <% + } + if ( null != errMessage ) { + String invalidMessage = errMessage.get("quiescent"); + if( null != invalidMessage ){ + out.println("

" + invalidMessage + "

"); + } + } + %> +
+

Default : No

+
+ + + <% + if ( dd.autoreload == true ) { + %> + + <% + } + else{ + %> + + <% + } + if ( null != errMessage ) { + String invalidMessage = errMessage.get("down_callback"); + if( null != invalidMessage ){ + out.println("

" + invalidMessage + "

"); + } + } + %> +
+

Up to 127 one-byte characters in English
Be effctive only if CheckService : HTTP, HTTPS, LDAP, MySQL, PostgreSQL, SIP, None

+
+ + + <% + if ( dd.autoreload == true ) { + %> + + <% + } + else{ + %> + + <% + } + if ( null != errMessage ) { + String invalidMessage = errMessage.get("up_callback"); + if( null != invalidMessage ){ + out.println("

" + invalidMessage + "

"); + } + } + %> +
+

Up to 127 one-byte characters in English

+
+ + + <% + { + String invalidMessage = null; + if ( null != errMessage ){ + invalidMessage = errMessage.get("check_port"); + } + if ( (vs == null) || (0 == vs.checkport) ){ + if ( dd.autoreload == true ) { + out.println(""); + } + else{ + out.println(""); + } + } + else{ + if ( dd.autoreload == true ) { + out.println(""); + } + else{ + out.println(""); + } + } + if ( null != invalidMessage ) { + out.println("

" + invalidMessage + "

"); + } + } + %> +
+

1-65535

+
+ + + <% + if ( dd.autoreload == true ) { + %> + + <% + } + else{ + %> + + <% + } + if ( null != errMessage ) { + String invalidMessage = errMessage.get("request"); + if( null != invalidMessage ){ + out.println("

" + invalidMessage + "

"); + } + } + %> +
+

Up to 127 one-byte characters in English
Be effctive only if CheckService : HTTP, HTTPS, LDAP, MySQL, PostgreSQL, SIP, None

+
+ + + <% + if ( dd.autoreload == true ) { + %> + + <% + } + else { + %> + + + <% + } + if ( null != errMessage ) { + String invalidMessage = errMessage.get("receive"); + if( null != invalidMessage ){ + out.println("

" + invalidMessage + "

"); + } + } + %> +
+

Up to 127 one-byte characters in English
Be effctive only if CheckService : HTTP, HTTPS, LDAP, FTP, DNS

+
+ + + <% if ( dd.autoreload == true ){ + %> + + <% + } + else + { + %> + + + <% + } + if ( null != errMessage ) { + String invalidMessage = errMessage.get("method"); + if( null != invalidMessage ){ + out.println("

" + invalidMessage + "

"); + } + } + %> +
+

Be effctive only if CheckService : HTTP, HTTPS

+
+ + + <% + if ( dd.autoreload == true ) { + %> + + <% + } + else{ + %> + + <% + } + if ( null != errMessage ) { + String invalidMessage = errMessage.get("virtual_host"); + if( null != invalidMessage ){ + out.println("

" + invalidMessage + "

"); + } + } + %> +
+

Up to 127 one-byte characters in English
Be effctive only if CheckService : HTTP, HTTPS

+
+ + + <% + if ( dd.autoreload == true ) { + %> + + <% + } + else{ + %> + + <% + } + if ( null != errMessage ) { + String invalidMessage = errMessage.get("login_user"); + if( null != invalidMessage ){ + out.println("

" + invalidMessage + "

"); + } + } + %> +
+

Up to 32 one-byte characters in English
Followings : Effctive only when CheckService is FTP, POP, IMAP, MySQL, PostgreSQL, and SIP

+
+ + + <% + if ( dd.autoreload == true ) { + %> + + <% + } + else{ + %> + + <% + } + if ( null != errMessage ) { + String invalidMessage = errMessage.get("login_pass"); + if( null != invalidMessage ){ + out.println("

" + invalidMessage + "

"); + } + } + %> +
+

Up to 32 one-byte characters in English
Be effctive only if CheckService : FTP, POP, IMAP, MySQL, PostgreSQL, SIP

+
+ + + <% + if ( dd.autoreload == true ) { + %> + + <% + } + else{ + %> + + <% + } + if ( null != errMessage ) { + String invalidMessage = errMessage.get("db"); + if( null != invalidMessage ){ + out.println("

" + invalidMessage + "

"); + } + } + %> +
+

Up to 32 one-byte characters in English
Be effctive only if CheckService : MySQL, PostgreSQL

+
+
+ +

RealServer Info

+ <% + if ( (vs != null) && (vs.real != null) && (vs.real.size() != 0 )) { + %> +
+ Real Servers + <% + for (int i = 0; i < vs.real.size(); i++) { + int ripNum = i + 1; + EndPoint rip = (EndPoint) vs.real.elementAt(i); + %> + + + + + + + + + + + + + + + + + +
+ + + + + + <% + if ( null != errMessage ) { + String invalidMessage = errMessage.get("rs" + ripNum + "_ip"); + if( null != invalidMessage ){ + out.println("

" + invalidMessage + "

"); + } + } + %> +
+

[0-255].[0-255].[0-255].[0-255]

+
+ + + <% + { + String invalidMessage = null; + if ( null != errMessage ) { + invalidMessage = errMessage.get("rs" + ripNum + "_port"); + } + if (null == rip.port){ + out.print(""); + } + else { + out.print(""); + } + if( null != invalidMessage ){ + out.println("

" + invalidMessage + "

"); + } + } + %> +
+

1-65535, service name

+
+ + + <% + { + String invalidMessage = null; + if ( null != errMessage ) { + invalidMessage = errMessage.get("rs" + ripNum + "_weight"); + } + if ( ( null != invalidMessage ) && ( 1 == rip.weight ) ){ + out.print(""); + } + else { + out.print(""); + } + if( null != invalidMessage ){ + out.println("

" + invalidMessage + "

"); + } + } + %> +
+

0-100
Default:1

+
+ <% + } + %> + +
+ <% + } + %> + + +
+ New Real Server + + + + + + + + + + + + + + + + +
+ + + + +

[0-255].[0-255].[0-255].[0-255]

+
+ + + + +

1-65535, service name

+
+ + + + +

0-100

+
+ +
+ +

SorryServer Info

+
+ Sorry Settings + + + + + + + + + + + + + + + + +
+ + + + <% + if ( null != errMessage ) { + String invalidMessage = errMessage.get("sorry_ip"); + if( null != invalidMessage ){ + out.println("

" + invalidMessage + "

"); + } + } + %> +
+

[0-255].[0-255].[0-255].[0-255]

+
+ + + + <% + { + String invalidMessage = null; + if ( null != errMessage ) { + invalidMessage = errMessage.get("sorry_port"); + } + + if ( (vs == null) || (null == vs.sorryserver.port) ){ + + out.println(""); + } + else{ + out.println(""); + } + if( null != invalidMessage ){ + out.println("

" + invalidMessage + "

"); + } + } + %> +
+

1-65535, service name

+
+ + + + <% + if ( null != errMessage ) { + String invalidMessage = errMessage.get("sorry_flag"); + if( null != invalidMessage ){ + out.println("

" + invalidMessage + "

"); + } + } + %> +
+

Default : Off

+
+
+ + + <% + if (dd.autoreload == true) { + %> + + <% + if (cd.self_status == ClusterStatus.ACTIVE || cd.self_status == ClusterStatus.STANDBY) { + %> + + <% + } + } + %> +
+
+<% +} +else{ + response.sendRedirect(RedirectPages.TOPMENU); + return; +} +%> + + + + \ No newline at end of file diff --git a/src/WebContent/vs_add_executive.jsp b/src/WebContent/vs_add_executive.jsp new file mode 100644 index 0000000..a9b6dbb --- /dev/null +++ b/src/WebContent/vs_add_executive.jsp @@ -0,0 +1,79 @@ +<%@ page + import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*" + language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + +<% + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41439, + LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get thread status + */ + String threadStatus = (String) session + .getAttribute(SessionKeys.THREAD_STATUS); + if (threadStatus == null) { + MessageView error = new MessageView(41440, + LogCategorySet.GUI_VIRTUALSERVICE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } else if (threadStatus.equals(SessionKeys.THREAD_RUNNING)) { + // nothing to do + } else if (threadStatus.equals(SessionKeys.THREAD_SUCCESS)) { + response.sendRedirect(RedirectPages.STATE_INFO); + return; + } else if (threadStatus.equals(SessionKeys.THREAD_FAIL)) { + response.sendRedirect(RedirectPages.VS_ADD_NG); + return; + } else { + MessageView error = new MessageView(41441, + LogCategorySet.GUI_VIRTUALSERVICE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } +%> + + + + + + + + + + + + + + + + + Running : Add VirtualService + + + + +

Running : Add VirtualService

+

Please wait.

+ + + + diff --git a/src/WebContent/vs_add_fail.jsp b/src/WebContent/vs_add_fail.jsp new file mode 100644 index 0000000..d0554ab --- /dev/null +++ b/src/WebContent/vs_add_fail.jsp @@ -0,0 +1,111 @@ +<%@ page + import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*" + language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + +<% + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41442, + LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get VS name + */ + String vsname = (String) session.getAttribute(SessionKeys.VS_NAME); + if (vsname == null) { + MessageView error = new MessageView(41443, + LogCategorySet.GUI_VIRTUALSERVICE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get result message + */ + MessageView message = (MessageView) session + .getAttribute(SessionKeys.COMMAND_MESSAGE); + + String errorMessage = ""; + int errorNumber = 0; + String category = ""; + + if (message != null) { + errorMessage = message.getMessage(); + errorNumber = message.getErrno(); + category = message.getCategory(); + session.setAttribute(SessionKeys.COMMAND_MESSAGE, null); + } + + /* + * get cluster status + */ + L7guiFramework framework = new L7guiFramework(); + ClusterData cd = framework.getClusterData(); + if (cd == null) { + MessageView error = new MessageView(41444, + LogCategorySet.GUI_IO_COMMAND, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if (cd.self_status == ClusterStatus.ACTIVE) { + cssSeat = "l7gui_act_style.css"; + } else if (cd.self_status == ClusterStatus.STANDBY) { + cssSeat = "l7gui_sby_style.css"; + } +%> + + + + + + + + + + + + + + + Failed : Add VirtualService + + + + + + +
+

Failed : Add VirtualService

+ +

Add Virtual Service :<%=vsname%>

+<% if ( (message != null) && (errorMessage != null ) ) %> +

Error Reason :

+

[<%=category%>-<%=errorNumber%>]

+

<%=errorMessage%>

+ +
+ + + diff --git a/src/WebContent/vs_modify.jsp b/src/WebContent/vs_modify.jsp new file mode 100644 index 0000000..b94adf8 --- /dev/null +++ b/src/WebContent/vs_modify.jsp @@ -0,0 +1,1313 @@ +<%@ page import="org.ultramonkey.l7.model.*, + org.ultramonkey.l7.controller.*, + org.ultramonkey.l7.view.*, java.util.*" + language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<% + + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41445, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get result message + */ + MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE); + String errorMessage = ""; + int errorNumber = 0; + String category = ""; + if (message != null) { + errorMessage = message.getMessage(); + errorNumber = message.getErrno(); + category = message.getCategory(); + session.setAttribute(SessionKeys.RESULT_MESSAGE, null); + } + + /* + * get validation error message + */ + HashMap errMessage = (HashMap) session.getAttribute(SessionKeys.INVALID_MESSAGE); + session.setAttribute(SessionKeys.INVALID_MESSAGE,null); + + + L7guiFramework framework = new L7guiFramework(); + + /* + * get cluster status + */ + ClusterData cd = framework.getClusterData(); + if (cd == null) { + MessageView error = new MessageView(41446, LogCategorySet.GUI_IO_COMMAND, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + if ( (cd.self_status != ClusterStatus.ACTIVE) && (cd.self_status != ClusterStatus.SINGLE) ){ + response.sendRedirect(RedirectPages.TOPMENU); + return; + } + + /* + * get l7directrod.cf data + */ + DirectorData dd = framework.getDirectorData(); + if (dd == null) { + MessageView error = new MessageView(41447, LogCategorySet.GUI_IO_FILE, + Message.DIRECTOR_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get previous input value + */ + VirtualSetting vs = (VirtualSetting) session.getAttribute(SessionKeys.INPUT_VS); + if (vs != null) { + session.setAttribute(SessionKeys.INPUT_VS, null); + } + else { + /* + * get post data + */ + String post = request.getParameter("vs"); // ex. "10.10.10.10:80:cinsert:--cookie-name monkey" + if (post == null) { + MessageView error = new MessageView(21101, LogCategorySet.GUI_VIRTUALSERVICE, + Message.VS_SELECT_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.STATE_INFO); + return; + } + + String params[] = post.split(":", 4); + if (params == null || params.length != 4) { + MessageView error = new MessageView(41448, LogCategorySet.GUI_VIRTUALSERVICE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get l7vsadm data from L7guiFramework + */ + L7vsAdmData admDataList = framework.getAdmData(); + if (admDataList == null) { + MessageView error = new MessageView(41449, LogCategorySet.GUI_VIRTUALSERVICE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + /* + * compare add l7vsadm data with post data + */ + for (int i = 0; i < admDataList.virtualSettings.size(); i++) { + VirtualSetting v = (VirtualSetting) admDataList.virtualSettings.elementAt(i); + if (v.virtual.host.equals(params[0]) && v.virtual.port.equals(params[1]) && + v.protomod.equals(params[2]) && v.option.equals(params[3])) { + vs = v; + break; + } + } + + for (VirtualSetting directordVs : dd.virtualSettings) { + if (directordVs.isSameService(vs)) { + vs = directordVs; + } + } + + /* + * error. no such VirtualService + */ + if (vs == null) { + MessageView error = new MessageView(41450, LogCategorySet.GUI_VIRTUALSERVICE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + } + + /* + * backup input data + */ + VirtualSetting oldVs = new VirtualSetting(vs); + session.setAttribute(SessionKeys.OLD_VS, oldVs); + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if ( cd.self_status == ClusterStatus.ACTIVE ){ + cssSeat = "l7gui_act_style.css"; + } + else if ( cd.self_status == ClusterStatus.STANDBY ){ + cssSeat = "l7gui_sby_style.css"; + } + +%> + + + + + + + + + + + + + + + + Modify VirtualService + + + + + + + +
+

Modify VirtualService (<%= vs.virtual.host %>:<%= vs.virtual.port %> <%= vs.protomod %> <%= vs.option %>)

+ +<% + if ( (message != null) && (errorMessage != null)) { +%> +

[ <%=category %> - <%=errorNumber %>]

+

<%=errorMessage %>

+<% + } +%> + +
+

VirtualService Info

+ +
+ Basic Settings + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + <% + if ( null != errMessage ){ + String invalidMessage = errMessage.get("vip"); + if( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

Required Field

+

[0-255].[0-255].[0-255].[0-255]

+
+ + + <% + { + String invalidMessage = null; + if ( null != errMessage ) { + invalidMessage = errMessage.get("port"); + } + if ( null == vs.virtual.port ){ + out.print(""); + } + else { + out.print(""); + } + if( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

Required Field

+

1-65535

+
+ + + + <% + if ( null != errMessage ){ + String invalidMessage = errMessage.get("protomod"); + if( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

Required Field

+
+ + + + <% + if ( null != errMessage ){ + String invalidMessage = errMessage.get("option"); + if( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

Up to 127 one-byte characters in English

+
+ + + + <% + if ( null != errMessage ){ + String invalidMessage = errMessage.get("sched"); + if( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

+
+
+
+ Advanced Settings + + + + + + + + + + + + + + + + +
+ + + <% + { + String invalidMessage = null; + int unit_s = 0; + if ( null != errMessage ) { + invalidMessage = errMessage.get("qos_service"); + } + if ( ( null != invalidMessage ) && ( 0 == vs.qosservice ) ){ + out.print(""); + } + else { + if ( invalidMessage == null ){ + while (vs.qosservice >= 1000) { + vs.qosservice /= 1000; + unit_s++; + } + } + out.print(""); + } + %> + + <% + if( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

0-999(bps/Kbps/Mbps/Gbps)

+
+ + + <% + { + String invalidMessage = null; + int unit_c = 0; + if ( null != errMessage ) { + invalidMessage = errMessage.get("qos_conn"); + } + if ( ( null != invalidMessage ) && ( 0 == vs.qosclient ) ){ + out.print(""); + } + else { + if ( null == invalidMessage ){ + while (vs.qosclient >= 1000) { + vs.qosclient /= 1000; + unit_c++; + } + } + out.print(""); + } + %> + + <% + if( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

0-999(bps/Kbps/Mbps/Gbps)

+
+ + + <% + { + String invalidMessage = null; + if ( null != errMessage ) { + invalidMessage = errMessage.get("max_conn"); + } + if ( ( null != invalidMessage ) && ( 0 == vs.maxconn ) ){ + out.print(""); + } + else { + out.print(""); + } + if( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

0-100000
Note : "0" means "Unlimited"

+
+
+
+ Monitor Settings +

Caution!! + Disable Area when you push "apply" button.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + <% + { + String invalidMessage = null; + if ( null != errMessage ) { + invalidMessage = errMessage.get("timeout"); + } + if ( ( vs == null ) || ( 0 == vs.timeout ) ){ + if ( dd.autoreload == true ) + out.print(""); + else + out.print(""); + } + else { + if ( dd.autoreload == true ) + out.print(""); + else + out.print(""); + + } + if( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

1-2147483647(sec)

+
+ + + <% + if ( dd.autoreload == true ) + { + %> + + <% + } + else + { + %> + + <% + } + if ( null != errMessage ) { + String invalidMessage = errMessage.get("check_type"); + if( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

Any Of The Following
negotiate, connect, ping, off, on, 0-9

+
+ + + <% if (dd.autoreload ==true ){ + %> + + <% + } + else + { + %> + + <% + } + if ( null != errMessage ) { + String invalidMessage = errMessage.get("check_service"); + if( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

+
+ + + <%if (dd.autoreload== true) { + %> + + <% + } + else + { + %> + + + <% + } + if ( null != errMessage ) { + String invalidMessage = errMessage.get("quiescent"); + if( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

Default : No

+
+ + + <% + if ( dd.autoreload == true ) + { + %> + + <% + } + else + { + %> + + <% + } + if ( null != errMessage ) { + String invalidMessage = errMessage.get("down_callback"); + if( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

Up to 127 one-byte characters in English
Be effctive only if CheckService : HTTP, HTTPS, LDAP, MySQL, PostgreSQL, SIP, None

+
+ + + <% + if ( dd.autoreload == true ) + { + %> + + <% + } + else + { + %> + + <% + } + if ( null != errMessage ) { + String invalidMessage = errMessage.get("up_callback"); + if( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

Up to 127 one-byte characters in English

+
+ + + <% + { + String invalidMessage = null; + if ( null != errMessage ) { + invalidMessage = errMessage.get("check_port"); + } + if ( ( vs == null ) || ( 0 == vs.checkport ) ){ + if (dd.autoreload == true) + out.print(""); + else + out.print(""); + } + else { + if (dd.autoreload == true) + out.print(""); + else + out.print(""); + } + if( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

1-65535

+
+ + + <% + if ( dd.autoreload == true ) + { + %> + + <% + } + else + { + %> + + <% + } + if ( null != errMessage ) { + String invalidMessage = errMessage.get("request"); + if( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

Up to one-byte characters in English
Be effctive only if CheckService : HTTP, HTTPS, LDAP, MySQL, PostgreSQL, SIP, None

+
+ + + <% + if ( dd.autoreload == true ) + { + %> + + <% + } + else + { + %> + + + <% + } + if ( null != errMessage ) { + String invalidMessage = errMessage.get("receive"); + if( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

Up to 127 one-byte characters in English
Be effctive only if CheckService : HTTP, HTTPS, LDAP, FTP, DNS

+
+ + + <% if (dd.autoreload ==true ){ + %> + + <% + } + else + { + %> + + + <% + } + if ( null != errMessage ) { + String invalidMessage = errMessage.get("method"); + if( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

Be effctive only if CheckService : HTTP, HTTPS

+
+ + + <% + if ( dd.autoreload == true ) + { + %> + + <% + } + else + { + %> + + <% + } + if ( null != errMessage ) { + String invalidMessage = errMessage.get("virtual_host"); + if( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

Up to 127 one-byte characters in English
Be effctive only if CheckService : HTTP, HTTPS

+
+ + + <% + if ( dd.autoreload == true ) + { + %> + + <% + } + else + { + %> + + <% + } + if ( null != errMessage ) { + String invalidMessage = errMessage.get("login_user"); + if( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

Up to 32 one-byte characters in English
Followings : Effctive only when CheckService is FTP, POP, IMAP, MySQL, PostgreSQL, and SIP

+
+ + + <% + if ( dd.autoreload == true ) + { + %> + + <% + } + else + { + %> + + <% + } + if ( null != errMessage ) { + String invalidMessage = errMessage.get("login_pass"); + if( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

Up to 32 one-byte characters in English
Be effctive only if CheckService : FTP, POP, IMAP, MySQL, PostgreSQL, SIP

+
+ + + <% + if ( dd.autoreload == true ) + { + %> + + <% + } + else + { + %> + + <% + } + if ( null != errMessage ) { + String invalidMessage = errMessage.get("db"); + if( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

Up to 32 one-byte characters in English
Be effctive only if CheckService : MySQL, PostgreSQL

+
+
+ +

RealServer Info

+ <% + if ( (vs.real != null) && (vs.real.size() != 0)) { + %> +
+ Real Servers + <% + for (int i = 0; i < vs.real.size(); i++) { + int ripNum = i + 1; + EndPoint rip = (EndPoint) vs.real.elementAt(i); + %> + + + + + + + + + + + + + + + + + +
+ + + + + + <% + if ( null != errMessage ) { + String invalidMessage = errMessage.get("rs" + ripNum + "_ip"); + if( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

[0-255].[0-255].[0-255].[0-255]

+
+ + + <% + { + String invalidMessage = null; + if ( null != errMessage ) { + invalidMessage = errMessage.get("rs" + ripNum + "_port"); + } + if ( null == rip.port ){ + out.print(""); + } + else { + out.print(""); + } + if( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

1-65535

+
+ + + <% + { + String invalidMessage = null; + if ( null != errMessage ) { + invalidMessage = errMessage.get("rs" + ripNum + "_weight"); + } + if ( ( null != invalidMessage ) && ( 1 == rip.weight ) ){ + out.print(""); + } + else { + out.print(""); + } + if( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

0-100
Default:1

+
+ <% + } + %> + +
+ <% + } + %> + +
+ New Real Server + + + + + + + + + + + + + + + + +
+ + + + +

[0-255].[0-255].[0-255].[0-255]

+
+ + + + +

1-65535

+
+ + + + +

0-100

+
+ +
+ +

SorryServer Info

+
+ Sorry Settings + + + + + + + + + + + + + + + + +
+ + + + <% + if ( null != errMessage ) { + String invalidMessage = errMessage.get("sorry_ip"); + if( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

[0-255].[0-255].[0-255].[0-255]

+
+ + + <% + { + String invalidMessage = null; + if ( null != errMessage ) { + invalidMessage = errMessage.get("sorry_port"); + } + if ( null == vs.sorryserver.port ) { + out.print(""); + } + else { + out.print(""); + } + if( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

1-65535

+
+ + + + <% + if ( null != errMessage ) { + String invalidMessage = errMessage.get("sorry_flag"); + if( null != invalidMessage ){ + out.print("

" + invalidMessage + "

"); + } + } + %> +
+

Default : Off

+
+
+ + <% + if (dd.autoreload == true) { + %> + + <% + if (cd.self_status == ClusterStatus.ACTIVE || cd.self_status == ClusterStatus.STANDBY) { + %> + + <% + } + } + %> +
+ +
+ + diff --git a/src/WebContent/vs_modify_executive.jsp b/src/WebContent/vs_modify_executive.jsp new file mode 100644 index 0000000..18c59f0 --- /dev/null +++ b/src/WebContent/vs_modify_executive.jsp @@ -0,0 +1,77 @@ +<%@ page + import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*" + language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + +<% + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41451, + LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get thread status + */ + String threadStatus = (String) session + .getAttribute(SessionKeys.THREAD_STATUS); + if (threadStatus == null) { + MessageView error = new MessageView(41452, + LogCategorySet.GUI_VIRTUALSERVICE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } else if (threadStatus.equals(SessionKeys.THREAD_RUNNING)) { + // nothing to do + } else if (threadStatus.equals(SessionKeys.THREAD_SUCCESS)) { + response.sendRedirect(RedirectPages.STATE_INFO); + return; + } else if (threadStatus.equals(SessionKeys.THREAD_FAIL)) { + response.sendRedirect(RedirectPages.VS_MODIFY_NG); + return; + } else { + MessageView error = new MessageView(41453, + LogCategorySet.GUI_VIRTUALSERVICE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } +%> + + + + + + + + + + + + + + + + Running : Modify VirtualService + + + + +

Running : Modify VirtualService

+

Please wait.

+ + + diff --git a/src/WebContent/vs_modify_fail.jsp b/src/WebContent/vs_modify_fail.jsp new file mode 100644 index 0000000..b710433 --- /dev/null +++ b/src/WebContent/vs_modify_fail.jsp @@ -0,0 +1,107 @@ +<%@ page + import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*" + language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + +<% + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41454, + LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get VS name + */ + String vsname = (String) session.getAttribute(SessionKeys.VS_NAME); + if (vsname == null) { + MessageView error = new MessageView(41455, + LogCategorySet.GUI_VIRTUALSERVICE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get result message + */ + MessageView message = (MessageView) session + .getAttribute(SessionKeys.COMMAND_MESSAGE); + + String errorMessage = ""; + int errorNumber = 0; + String category = ""; + + if (message != null) { + errorMessage = message.getMessage(); + errorNumber = message.getErrno(); + category = message.getCategory(); + session.setAttribute(SessionKeys.COMMAND_MESSAGE, null); + } + + /* + * get cluster status + */ + L7guiFramework framework = new L7guiFramework(); + ClusterData cd = framework.getClusterData(); + if (cd == null) { + MessageView error = new MessageView(41456, + LogCategorySet.GUI_IO_COMMAND, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if (cd.self_status == ClusterStatus.ACTIVE) { + cssSeat = "l7gui_act_style.css"; + } else if (cd.self_status == ClusterStatus.STANDBY) { + cssSeat = "l7gui_sby_style.css"; + } +%> + + + + + + + + + + + + + + Failed : Modify VirtualService + + + + + + +
+

Failed : Modify VirtualService

+ +

Modify Virtual Service :<%=vsname%>

+

Error Reason :

+

[<%=category%>-<%=errorNumber%>]

+

<%=errorMessage%>

+ +
+ + diff --git a/src/WebContent/vs_remove.jsp b/src/WebContent/vs_remove.jsp new file mode 100644 index 0000000..796ad10 --- /dev/null +++ b/src/WebContent/vs_remove.jsp @@ -0,0 +1,98 @@ +<%@ page import="org.ultramonkey.l7.model.*, + org.ultramonkey.l7.controller.*, + org.ultramonkey.l7.view.*" + language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> + + +<% + /* + * check session + */ + if (session.isNew()) { + MessageView error = new MessageView(41457, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get VS name + */ + String vsname = (String)session.getAttribute(SessionKeys.VS_NAME); + + if(vsname == null){ + MessageView error = new MessageView(41458, LogCategorySet.GUI_VIRTUALSERVICE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get result message + */ + MessageView message = (MessageView) session + .getAttribute(SessionKeys.COMMAND_MESSAGE); + + if (message != null) { + session.setAttribute(SessionKeys.COMMAND_MESSAGE, null); + } + + /* + * get cluster status + */ + L7guiFramework framework = new L7guiFramework(); + ClusterData cd = framework.getClusterData(); + if (cd == null) { + MessageView error = new MessageView(41459, + LogCategorySet.GUI_IO_COMMAND, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if (cd.self_status == ClusterStatus.ACTIVE) { + cssSeat = "l7gui_act_style.css"; + } else if (cd.self_status == ClusterStatus.STANDBY) { + cssSeat = "l7gui_sby_style.css"; + } + +%> + + + + + + + + + + + + + + + Succeeded : Remove VirtualService + + + + + + +
+

Succeeded : Remove VirtualService

+ +

Remove Virtual Service :
<%= vsname %>

+
+ + + diff --git a/src/WebContent/vs_remove_executive.jsp b/src/WebContent/vs_remove_executive.jsp new file mode 100644 index 0000000..8922120 --- /dev/null +++ b/src/WebContent/vs_remove_executive.jsp @@ -0,0 +1,78 @@ +<%@ page + import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*" + language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + +<% + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41460, + LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get thread status + */ + String threadStatus = (String) session + .getAttribute(SessionKeys.THREAD_STATUS); + if (threadStatus == null) { + MessageView error = new MessageView(41461, + LogCategorySet.GUI_VIRTUALSERVICE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } else if (threadStatus.equals(SessionKeys.THREAD_RUNNING)) { + // nothing to do + } else if (threadStatus.equals(SessionKeys.THREAD_SUCCESS)) { + response.sendRedirect(RedirectPages.VS_REMOVE_SUCCESS); + return; + } else if (threadStatus.equals(SessionKeys.THREAD_FAIL)) { + response.sendRedirect(RedirectPages.VS_REMOVE_NG); + return; + } else { + MessageView error = new MessageView(41462, + LogCategorySet.GUI_VIRTUALSERVICE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } +%> + + + + + + + + + + + + + + + + + Running : Remove VirtualService + + + + +

Running : Remove VirtualService

+

Please wait.

+ + + diff --git a/src/WebContent/vs_remove_fail.jsp b/src/WebContent/vs_remove_fail.jsp new file mode 100644 index 0000000..67328f9 --- /dev/null +++ b/src/WebContent/vs_remove_fail.jsp @@ -0,0 +1,123 @@ +<%@ page + import="org.ultramonkey.l7.model.*,org.ultramonkey.l7.controller.*,org.ultramonkey.l7.view.*" + language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + +<% + /* + * check session + */ + L7guiServletBase base = new L7guiServletBase(); + if (session.isNew() || base.checkSession(session) == false) { + MessageView error = new MessageView(41463, + LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get VS name + */ + String vsname = (String) session.getAttribute(SessionKeys.VS_NAME); + if (vsname == null) { + MessageView error = new MessageView(41464, + LogCategorySet.GUI_VIRTUALSERVICE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * get command message & result message + */ + MessageView message = (MessageView) session + .getAttribute(SessionKeys.COMMAND_MESSAGE); + + MessageView resultMessage = (MessageView) session + .getAttribute(SessionKeys.RESULT_MESSAGE); + + String errorMessage = ""; + int errorNumber = 0; + String category = ""; + + if (message != null) { + errorMessage = message.getMessage(); + errorNumber = message.getErrno(); + category = message.getCategory(); + session.setAttribute(SessionKeys.COMMAND_MESSAGE, null); + } + + else if (resultMessage != null) { + errorMessage = resultMessage.getMessage(); + errorNumber = resultMessage.getErrno(); + category = resultMessage.getCategory(); + session.setAttribute(SessionKeys.RESULT_MESSAGE, null); + } + + + /* + * get cluster status + */ + L7guiFramework framework = new L7guiFramework(); + ClusterData cd = framework.getClusterData(); + if (cd == null) { + MessageView error = new MessageView(41465, + LogCategorySet.GUI_IO_COMMAND, + Message.CLUSTER_DATA_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + return; + } + + /* + * fix style seat + */ + String cssSeat = "l7gui_single_style.css"; + if (cd.self_status == ClusterStatus.ACTIVE) { + cssSeat = "l7gui_act_style.css"; + } else if (cd.self_status == ClusterStatus.STANDBY) { + cssSeat = "l7gui_sby_style.css"; + } +%> + + + + + + + + + + + + + + + Failed : Remove VirtualService + + + + + + +
+

Failed : Remove VirtualService

+ +

Remove Virtual Service :<%=vsname%>

+<% if ( ( (message != null) || (resultMessage != null) ) && (errorMessage != null) ){ +%> +

Error Reason :

+

[<%=category%>-<%=errorNumber%>]

+

<%=errorMessage%>

+<% } +%> +
+ + \ No newline at end of file diff --git a/src/src/log4j.properties b/src/src/log4j.properties new file mode 100644 index 0000000..0d6776a --- /dev/null +++ b/src/src/log4j.properties @@ -0,0 +1,47 @@ +# root logger +#log4j.rootLogger=INFO, root +#log4j.appender.root = org.apache.log4j.ConsoleAppender +#log4j.appender.root.layout = org.apache.log4j.PatternLayout +#log4j.appender.root.layout.ConversionPattern=%d{yyyy/MM/dd HH:mm:ss} [%-5p] %c %m at %C{1}.java:%L%n +#log4j.appender.root.threshold = INFO + +# l7gui logger +log4j.category.l7gui_StartStop = INFO, gui +log4j.category.l7gui_UserAuthentication = INFO, gui +log4j.category.l7gui_VirtualService = INFO, gui +log4j.category.l7gui_Monitor = INFO, gui +log4j.category.l7gui_SnmpAgent = INFO, gui +log4j.category.l7gui_Replication = INFO, gui +log4j.category.l7gui_Log = INFO, gui +log4j.category.l7gui_UserManage = INFO, gui +log4j.category.l7gui_Redundant = INFO, gui +log4j.category.l7gui_Save = INFO, gui +log4j.category.l7gui_Sync = INFO, gui +log4j.category.l7gui_SaveSync = INFO, gui +log4j.category.l7gui_I/O = INFO, gui +log4j.category.l7gui_I/O.File = INFO +log4j.category.l7gui_I/O.Command = INFO +log4j.appender.gui = org.apache.log4j.RollingFileAppender +log4j.appender.gui.File=/var/log/l7vs/l7gui.log +log4j.appender.gui.Append=true +log4j.appender.gui.MaxFileSize=10MB +log4j.appender.gui.MaxBackupIndex=9 +log4j.appender.gui.layout = org.apache.log4j.PatternLayout +log4j.appender.gui.layout.ConversionPattern=%d{yyyy/MM/dd HH:mm:ss} [%-5p] %c %m at %C{1}.java:%L%n +log4j.appender.gui.threshold = INFO + +# l7sync logger +log4j.category.l7sync_StartStop = INFO, sync +log4j.category.l7sync_Connection = INFO, sync +log4j.category.l7sync_Sync = INFO, sync +log4j.category.l7sync_Sync.DirectorData = INFO +log4j.category.l7sync_Sync.L7vsdConfData = INFO +log4j.category.l7sync_Sync.UserData = INFO +log4j.appender.sync = org.apache.log4j.RollingFileAppender +log4j.appender.sync.File=/var/log/l7vs/l7sync.log +log4j.appender.sync.Append=true +log4j.appender.sync.MaxFileSize=10MB +log4j.appender.sync.MaxBackupIndex=9 +log4j.appender.sync.layout = org.apache.log4j.PatternLayout +log4j.appender.sync.layout.ConversionPattern=%d{yyyy/MM/dd HH:mm:ss} [%-5p] %c %m at %C{1}.java:%L%n +log4j.appender.sync.threshold = INFO diff --git a/src/src/org/ultramonkey/l7/controller/ClusterController.java b/src/src/org/ultramonkey/l7/controller/ClusterController.java new file mode 100644 index 0000000..b858fc1 --- /dev/null +++ b/src/src/org/ultramonkey/l7/controller/ClusterController.java @@ -0,0 +1,373 @@ +package org.ultramonkey.l7.controller; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.*; +import java.util.regex.*; + +import org.apache.log4j.Logger; +import org.ultramonkey.l7.model.LogCategorySet; + +/** + * + *

+ * class ClusterController + *

+ *

+ * Copyright(c) NTT COMWARE 2008 + *

+ * + * @author tanuma + */ +public class ClusterController { + + /* + * TODO This class is only for Heartbeat cluster now. We have to be + * refactoring for any cluster software using JNDI later. + */ + + private Logger ioCommandLogger = Logger.getLogger(LogCategorySet.GUI_IO_COMMAND); + + protected static ClusterData data = null; + + private static final String CRM_MON = "/usr/sbin/crm_mon"; + + private static final String CRM_STANDBY = "/usr/sbin/crm_standby"; + + private static final int CHECK_TIMEOUT = 10; + + private static String HB_LOG = "/var/log/ha-log"; + + /** + * + *

+ * getData method + *

+ * + * @return cluster data + */ + public ClusterData getData() { + // --- debug log (in method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11558 ClusterController::getData() in"); + } + // --- debug log (in method) --- + + synchronized (this) { + String command = CRM_MON + " -1"; + String result = runProcess(command); + + ClusterData data = new ClusterData(); + data.self_status = ClusterStatus.SINGLE; + data.logFileName = HB_LOG; + + try { + InetAddress local = InetAddress.getLocalHost(); + String host = local.getHostName(); + data.self_ip = local.getHostAddress(); + + if (result != null) { + Pattern p = Pattern.compile("^Node: ([^ ]+)[^:]+: (\\w+)$", + Pattern.MULTILINE); + Matcher m = p.matcher(result); + while (m.find()) { + if (host.equals(m.group(1))) { + data.self_hostname = m.group(1); + data.self_ip = local.getHostAddress(); + if ("OFFLINE".equals(m.group(2))) + data.self_status = ClusterStatus.OUT_OF_SERVICE; + else if ("online".equals(m.group(2))) + data.self_status = ClusterStatus.STANDBY; + else if ("standby".equals(m.group(2))) + data.self_status = ClusterStatus.OUT_OF_SERVICE; + else + data.self_status = ClusterStatus.SINGLE; + } else { + data.other_hostname = m.group(1); + try { + data.other_ip = InetAddress.getByName(m.group(1)) + .getHostAddress(); + } catch (UnknownHostException e) { + ioCommandLogger.info("21100 name resolution failed: " + m.group(1)); + data.other_ip = null; + } + if ("OFFLINE".equals(m.group(2))) + data.other_status = ClusterStatus.OUT_OF_SERVICE; + else if ("online".equals(m.group(2))) + data.other_status = ClusterStatus.STANDBY; + else if ("standby".equals(m.group(2))) + data.other_status = ClusterStatus.OUT_OF_SERVICE; + else + data.other_status = ClusterStatus.SINGLE; + } + } + p = Pattern.compile("Started ([-\\.\\w]+)$", Pattern.MULTILINE); + m = p.matcher(result); + while (m.find()) { + if (m.group(1).equals(data.self_hostname) + && data.self_status == ClusterStatus.STANDBY) + data.self_status = ClusterStatus.ACTIVE; + else if (m.group(1).equals(data.other_hostname) + && data.other_status == ClusterStatus.STANDBY) + data.other_status = ClusterStatus.ACTIVE; + } + } + } catch (Exception e) { + ioCommandLogger.error("41242 Exception occured: " + e.getMessage()); + data = null; + } + + // --- debug log (in method) --- + if (ioCommandLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("ClusterController::getData() out "); + buf.append("return=(" + data + ")"); + ioCommandLogger.debug("11559 " + buf.toString()); + } + // --- debug log (in method) --- + return data; + } + } + + /** + * + *

+ * setData method + *

+ * + * @param cd + */ + public void setData(ClusterData cd) { + // --- debug log (in method) --- + if (ioCommandLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("ClusterController::setData(ClusterData cd) in "); + buf.append("cd=(" + cd + ")"); + ioCommandLogger.debug("11560 " + buf.toString()); + } + // --- debug log (in method) --- + + synchronized (this) { + data = cd; + } + + // --- debug log (in method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11561 ClusterController::setData(ClusterData cd) out"); + } + // --- debug log (in method) --- + } + + /** + * + *

+ * changeClusterMode method + *

+ * + * @return result of switch over. + */ + public boolean changeClusterMode() { + // --- debug log (in method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11562 ClusterController::changeClusterMode() in"); + } + // --- debug log (in method) --- + + synchronized (this) { + // get current status + ClusterData data = this.getData(); + String command = null; + boolean self_flag = true; + + if (data != null && data.self_status == ClusterStatus.ACTIVE + && data.other_status == ClusterStatus.STANDBY) { + self_flag = true; + command = CRM_STANDBY + " -U " + data.self_hostname + " -v on"; + } else if (data != null && data.other_status == ClusterStatus.ACTIVE + && data.self_status == ClusterStatus.STANDBY) { + self_flag = false; + command = CRM_STANDBY + " -U " + data.other_hostname + " -v on"; + } else { + ioCommandLogger.error("41243 Invalid status: " + data); + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11563 ClusterController::changeClusterMode() out return=false"); + } + // --- debug log (out method) --- + return false; + } + + // run crm_standby command + String result = runProcess(command); + if (result == null || result.length() != 0) { + ioCommandLogger.error("41244 Command error: command=" + command); + ioCommandLogger.error("41245 Command error: result=" + result); + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11564 ClusterController::changeClusterMode() out return=false"); + } + // --- debug log (out method) --- + return false; + } + + int timeout = CHECK_TIMEOUT; + + while (true) { + // reload current status + data = this.getData(); + + if (data == null) { + ioCommandLogger.error("41246 Invalid status: " + data); + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11565 ClusterController::changeClusterMode() out return=false"); + } + // --- debug log (out method) --- + return false; + } else if (self_flag) { + if (data.self_status == ClusterStatus.OUT_OF_SERVICE + && data.other_status == ClusterStatus.ACTIVE) { + command = CRM_STANDBY + " -U " + data.self_hostname + + " -v off"; + break; + } + } else { + if (data.other_status == ClusterStatus.OUT_OF_SERVICE + && data.self_status == ClusterStatus.ACTIVE) { + command = CRM_STANDBY + " -U " + data.other_hostname + + " -v off"; + break; + } + } + + timeout--; + if (timeout <= 0) { + ioCommandLogger.error("41247 Switch-Over timeout(" + CHECK_TIMEOUT + "sec)"); + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11566 ClusterController::changeClusterMode() out return=false"); + } + // --- debug log (out method) --- + return false; + } + + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + ioCommandLogger.error("41248 Exception occured: " + e.getMessage()); + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11567 ClusterController::changeClusterMode() out return=false"); + } + // --- debug log (out method) --- + return false; + } + } + + // run crm_standby command + result = runProcess(command); + if (result == null || result.length() != 0) { + ioCommandLogger.error("41249 Command error: command=" + command); + ioCommandLogger.error("41250 Command error: result=" + result); + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11568 ClusterController::changeClusterMode() out return=false"); + } + // --- debug log (out method) --- + return false; + } + + // reload current status + data = this.getData(); + + if (data == null) { + ioCommandLogger.error("41251 Invalid status: null"); + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11569 ClusterController::changeClusterMode() out return=false"); + } + // --- debug log (out method) --- + return false; + } else if (self_flag) { + if (data.self_status != ClusterStatus.STANDBY + || data.other_status != ClusterStatus.ACTIVE) { + ioCommandLogger.error("41252 Invalid status: " + data); + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11570 ClusterController::changeClusterMode() out return=false"); + } + // --- debug log (out method) --- + return false; + } + } else { + if (data.other_status != ClusterStatus.STANDBY + || data.self_status != ClusterStatus.ACTIVE) { + ioCommandLogger.error("41253 Invalid status: " + data); + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11571 ClusterController::changeClusterMode() out return=false"); + } + // --- debug log (out method) --- + return false; + } + } + + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11572 ClusterController::changeClusterMode() out return=true"); + } + // --- debug log (out method) --- + return true; + } + } + + /** + * + *

+ * runProcess method + *

+ * + * @param command + * @return result string of command execution + */ + protected String runProcess(String command) { + // --- debug log (in method) --- + if (ioCommandLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("ClusterController::runProcess(String command) in "); + buf.append("command=\"" + command + "\""); + ioCommandLogger.debug("11573 " + buf.toString()); + } + // --- debug log (in method) --- + synchronized (this) { + StringBuffer result = new StringBuffer(); + + try { + // TODO using sudo command temporally + Process p = Runtime.getRuntime().exec("sudo " + command); + InputStream stderr = p.getErrorStream(); + BufferedReader br = new BufferedReader(new InputStreamReader(stderr)); + String line = null; + while ((line = br.readLine()) != null) { + result.append(line + "\n"); + } + InputStream is = p.getInputStream(); + br = new BufferedReader(new InputStreamReader(is)); + while ((line = br.readLine()) != null) { + result.append(line + "\n"); + } + } catch (Exception e) { + ioCommandLogger.error("41254 Exception occured: " + e.getMessage()); + result = null; + } + + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11574 ClusterController::runProcess(String command) out return=" + result); + } + // --- debug log (out method) --- + return (result == null) ? null : result.toString(); + } + } +} diff --git a/src/src/org/ultramonkey/l7/controller/ClusterData.java b/src/src/org/ultramonkey/l7/controller/ClusterData.java new file mode 100644 index 0000000..c30002d --- /dev/null +++ b/src/src/org/ultramonkey/l7/controller/ClusterData.java @@ -0,0 +1,83 @@ +package org.ultramonkey.l7.controller; +import java.io.Serializable; + +import org.apache.log4j.Logger; +import org.ultramonkey.l7.model.LogCategorySet; + +/** + *

class ClusterData

+ *

Copyright(c) NTT COMWARE 2008

+ * @author nakai + */ +public class ClusterData implements Serializable { + static final long serialVersionUID = 1; + + /** + * cluster status (self node) + */ + public ClusterStatus self_status; + + /** + * cluster status (other node) + */ + public ClusterStatus other_status; + + /** + * self IP address + */ + public String self_ip; + + /** + * self Hostname + */ + public String self_hostname; + + /** + * other IP address + */ + public String other_ip; + + /** + * other Hostname + */ + public String other_hostname; + + public String logFileName; + + /** + * + * Constructor + * + */ + public ClusterData() { + // --- debug log (constructor) --- + Logger redundantLogger = Logger.getLogger(LogCategorySet.GUI_REDUNDANT); + if (redundantLogger.isDebugEnabled()) { + redundantLogger.debug("11557 class ClusterData created."); + } + // --- debug log (constructor) --- + + this.self_status = ClusterStatus.NONE; + this.other_status = ClusterStatus.NONE; + this.self_ip = null; + this.self_hostname = null; + this.other_ip = null; + this.other_hostname = null; + this.logFileName = null; + } + + /** + * + * {@inheritDoc} + */ + public String toString() { + return + "self_status=" + this.self_status + ", " + + "self_ip=\"" + this.self_ip + "\", " + + "self_hostname=\"" + this.self_hostname + "\", " + + "other_status=" + this.other_status + ", " + + "other_ip=\"" + this.other_ip + "\", " + + "other_hostname=\"" + this.other_hostname + "\", " + + "logFileName=\"" + this.logFileName + "\""; + } +} diff --git a/src/src/org/ultramonkey/l7/controller/ClusterStatus.java b/src/src/org/ultramonkey/l7/controller/ClusterStatus.java new file mode 100644 index 0000000..d2f6ed5 --- /dev/null +++ b/src/src/org/ultramonkey/l7/controller/ClusterStatus.java @@ -0,0 +1,29 @@ +package org.ultramonkey.l7.controller; + +/** + *

class ControlerStatus

+ *

Copyright(c) NTT COMWARE 2008

+ * @author nakai + */ +public enum ClusterStatus { + /** + * cluster is active (running cluster process and having resources) + */ + ACTIVE, + /** + * cluster is standby (running cluster process and having no resources) + */ + STANDBY, + /** + * cluster is out of service ( + */ + OUT_OF_SERVICE, + /** + * cluster is single + */ + SINGLE, + /** + * cluster initial status + */ + NONE +} diff --git a/src/src/org/ultramonkey/l7/controller/DirectorController.java b/src/src/org/ultramonkey/l7/controller/DirectorController.java new file mode 100644 index 0000000..e00d275 --- /dev/null +++ b/src/src/org/ultramonkey/l7/controller/DirectorController.java @@ -0,0 +1,973 @@ +package org.ultramonkey.l7.controller; + +import java.io.*; +import java.util.*; + +import org.apache.log4j.Logger; +import org.ultramonkey.l7.model.LogCategorySet; + +/** + * /usr/sbin/l7directored control class + * + * @author nakai + * @versin 1.0 + * + */ +public class DirectorController implements Serializable { + static final long serialVersionUID = 1L; + + private final String l7directord = "/usr/sbin/l7directord"; + + protected String filename = ""; + + protected String CHECKTIMEOUT_KEY = "checktimeout"; + + protected String CHECKINTERVAL_KEY = "checkinterval"; + + protected String CHECKCOUNT_KEY = "checkcount"; + + protected String FALLBACK_KEY = "fallback"; + + protected String AUTORELOAD_KEY = "autoreload"; + + protected String EXECUTE_KEY = "execute"; + + protected String LOGFILE_KEY = "logfile"; + + protected String QUIESCENT_KEY = "quiescent"; + + protected String CALLBACK_KEY = "callback"; + + protected String NEGOTIATE_TIMEOUT_KEY = "negotiatetimeout"; + + protected String SUPERVISED_KEY = "supervised"; + + protected String VIRTUAL_KEY = "virtual"; + + protected String CHECKTYPE_KEY = "checktype"; + + protected String CHECKPORT_KEY = "checkport"; + + protected String MAXCONN_KEY = "maxconn"; + + protected String MODULE_KEY = "module"; + + protected String PROTOCOL_KEY = "protocol"; + + protected String QOSCLIENTS_KEY = "qosclients"; + + protected String QOSSERVICE_KEY = "qosservice"; + + protected String RECEIVE_KEY = "receive"; + + protected String SERVICE_KEY = "service"; + + protected String REAL_KEY = "real"; + + protected String REQUEST_KEY = "request"; + + protected String SCHEDULER_KEY = "scheduler"; + + protected String SORRYSERVER_KEY = "sorryserver"; + + protected String HTTPMETHOD_KEY = "httpmethod"; + + protected String VIRTUALHOST_KEY = "virtualhost"; + + protected String PASSWORD_KEY = "passwd"; + + protected String LOGIN_KEY = "login"; + + protected String DATABASE_KEY = "database"; + + protected String REALDOWNCALLBACK_KEY = "realdowncallback"; + + protected String REALRECOVERCALLBACK_KEY = "realrecovercallback"; + + /** + * pair class + *

+ * class pair + *

+ *

+ * Copyright(c) NTT COMWARE 2008 + *

+ * + * @author kubota + */ + protected class Pair { + protected E elementFirst; + + protected N elementSecond; + + public Pair(E firstIn, N secondIn) { + elementFirst = firstIn; + elementSecond = secondIn; + } + + public void set(E firstIn, N secondIn) { + elementFirst = firstIn; + elementSecond = secondIn; + } + + public E first() { + return elementFirst; + } + + public N second() { + return elementSecond; + } + } + + protected Pair paseKey(String inLine) { + if (inLine == null) + return null; + int pos = inLine.indexOf("="); + if (pos == -1) + return new Pair(inLine, ""); + String first = inLine.substring(0, pos); + String second = inLine.substring(pos + 1, inLine.length()); + if (first.indexOf('#') != -1) + return new Pair("", ""); + if (second.indexOf('#') != -1) { + pos = second.indexOf('#'); + second = second.substring(0, pos); + } + first = first.trim(); + second = second.trim(); + Pair pair = new Pair(first, second); + return pair; + } + + protected boolean serchfile() { + // sengenbasyo kentou yousu + final String confname = "l7directord.cf"; + final String confdir1 = "/etc/ha.d/"; + final String confdir2 = "/etc/ha.d/conf/"; + String conf = confdir1 + confname; + File objFile = new File(conf); + if (!objFile.exists()) { + conf = confdir2 + confname; + objFile = new File(conf); + if (!objFile.exists()) { + return false; + } + } + if (!objFile.isFile()) { + return false; + } + filename = objFile.getPath(); + return true; + } + + private static String trimQuote(String s) { + if (s != null && s.matches("^\".*\"$")) { + s = s.substring(1, s.length() - 1); + } + return s; + } + + protected DirectorData loadFromFile() + throws org.ultramonkey.l7.model.FileNotReadException { + DirectorData data; + try { + java.io.FileReader file = new java.io.FileReader(filename); + java.io.BufferedReader reader = new java.io.BufferedReader(file); + String buffer; + data = new DirectorData(); + Stack stack = new Stack(); + int position = 0; + while ((buffer = reader.readLine()) != null) { + buffer = buffer.replaceAll("\\s+$", ""); + buffer = buffer.replaceAll("\\t", " "); + if (buffer.length() == 0 || buffer.matches("^\\s*#.*")) + continue; + if (buffer.indexOf(VIRTUAL_KEY) == 0) + position++; + stack.push(buffer); + } + String tmpGlobalLogFile = ""; + String tmpGlobalExecute = ""; + boolean tmpGlobalAutoreaload = false; + String tmpGlobalCallback = ""; + String tmpGlobalFallback = ""; + String tmpGlobalCheckInterval = ""; + String tmpGlobalCheckTimeOut = ""; + String tmpGlobalCheckCount = ""; + String tmpGlobalNegotiateTimeOut = ""; + String tmpGlobalQuiescent = ""; + String tmpGlobalSupervised = "no"; + String tmpCheckTimeOut = ""; + String tmpCheckCount = ""; + String tmpNegotiateTimeOut = ""; + String tmpQuiescent = ""; + String tmpQosClients = ""; + String tmpQosService = ""; + String tmpSorryServer = ""; + String tmpMaxConn = ""; + String tmpProtocol = ""; + String tmpScheduler = ""; + String tmpReceive = ""; + String tmpRequest = ""; + String tmpService = ""; + String tmpModule = ""; + Vector tmpReal = new Vector(); + String tmpCheckType = ""; + String tmpCheckport = ""; + String tmpHttpMethod = ""; + String tmpVirtualHost = ""; + String tmpPassword = ""; + String tmpLogin = ""; + String tmpDatabase = ""; + String tmpRealDownCallback = ""; + String tmpRealRecoverCallback = ""; + while (!stack.empty()) { + buffer = stack.pop(); + if (buffer.indexOf(AUTORELOAD_KEY) == 0) { + Pair pair = paseKey(buffer); + if (pair.second().indexOf("yes") != -1) + tmpGlobalAutoreaload = true; + else + tmpGlobalAutoreaload = false; + } + if (buffer.indexOf(CALLBACK_KEY) == 0) { + Pair pair = paseKey(buffer); + tmpGlobalCallback = trimQuote(pair.second()); + } else if (buffer.indexOf(CHECKTIMEOUT_KEY) == 0) { + Pair pair = paseKey(buffer); + tmpGlobalCheckTimeOut = pair.second(); + } else if (buffer.indexOf(CHECKINTERVAL_KEY) == 0) { + Pair pair = paseKey(buffer); + tmpGlobalCheckInterval = pair.second(); + } else if (buffer.indexOf(CHECKCOUNT_KEY) == 0) { + Pair pair = paseKey(buffer); + tmpGlobalCheckCount = pair.second(); + } else if (buffer.indexOf(FALLBACK_KEY) == 0) { + Pair pair = paseKey(buffer); + tmpGlobalFallback = pair.second(); + } else if (buffer.indexOf(EXECUTE_KEY) == 0) { + Pair pair = paseKey(buffer); + tmpGlobalExecute = trimQuote(pair.second()); + } else if (buffer.indexOf(LOGFILE_KEY) == 0) { + Pair pair = paseKey(buffer); + tmpGlobalLogFile = trimQuote(pair.second()); + } else if (buffer.indexOf(NEGOTIATE_TIMEOUT_KEY) == 0) { + Pair pair = paseKey(buffer); + tmpGlobalNegotiateTimeOut = pair.second(); + } else if (buffer.indexOf(QUIESCENT_KEY) == 0) { + Pair pair = paseKey(buffer); + tmpGlobalQuiescent = pair.second(); + } else if (buffer.indexOf(SUPERVISED_KEY) == 0) { + tmpGlobalSupervised = "yes"; + } else if (buffer.indexOf(CHECKTIMEOUT_KEY) >= 4) { + Pair pair = paseKey(buffer); + tmpCheckTimeOut = pair.second(); + } else if (buffer.indexOf(CHECKCOUNT_KEY) >= 4) { + Pair pair = paseKey(buffer); + tmpCheckCount = pair.second(); + } else if (buffer.indexOf(NEGOTIATE_TIMEOUT_KEY) >= 4) { + Pair pair = paseKey(buffer); + tmpNegotiateTimeOut = pair.second(); + } else if (buffer.indexOf(QUIESCENT_KEY) >= 4) { + Pair pair = paseKey(buffer); + tmpQuiescent = pair.second(); + } else if (buffer.indexOf(CHECKTYPE_KEY) >= 4) { + Pair pair = paseKey(buffer); + tmpCheckType = pair.second(); + } else if (buffer.indexOf(CHECKPORT_KEY) >= 4) { + Pair pair = paseKey(buffer); + tmpCheckport = pair.second(); + } else if (buffer.indexOf(MAXCONN_KEY) >= 4) { + Pair pair = paseKey(buffer); + tmpMaxConn = pair.second(); + } else if (buffer.indexOf(MODULE_KEY) >= 4) { + Pair pair = paseKey(buffer); + tmpModule = pair.second(); + } else if (buffer.indexOf(PROTOCOL_KEY) >= 4) { + Pair pair = paseKey(buffer); + tmpProtocol = pair.second(); + } else if (buffer.indexOf(QOSCLIENTS_KEY) >= 4) { + Pair pair = paseKey(buffer); + tmpQosClients = pair.second(); + } else if (buffer.indexOf(QOSSERVICE_KEY) >= 4) { + Pair pair = paseKey(buffer); + tmpQosService = pair.second(); + } else if (buffer.indexOf(REAL_KEY) >= 4 + && buffer.indexOf(REALRECOVERCALLBACK_KEY) == -1 + && buffer.indexOf(REALDOWNCALLBACK_KEY) == -1) { + Pair pair = paseKey(buffer); + String real = pair.second(); + tmpReal.add(real); + } else if (buffer.indexOf(RECEIVE_KEY) >= 4) { + Pair pair = paseKey(buffer); + tmpReceive = trimQuote(pair.second()); + } else if (buffer.indexOf(REQUEST_KEY) >= 4) { + Pair pair = paseKey(buffer); + tmpRequest = trimQuote(pair.second()); + } else if (buffer.indexOf(SCHEDULER_KEY) >= 4) { + Pair pair = paseKey(buffer); + tmpScheduler = pair.second(); + } else if (buffer.indexOf(SERVICE_KEY) >= 4) { + Pair pair = paseKey(buffer); + tmpService = trimQuote(pair.second()); + } else if (buffer.indexOf(HTTPMETHOD_KEY) >= 4) { + Pair pair = paseKey(buffer); + tmpHttpMethod = pair.second(); + } else if (buffer.indexOf(VIRTUALHOST_KEY) >= 4) { + Pair pair = paseKey(buffer); + tmpVirtualHost = trimQuote(pair.second()); + } else if (buffer.indexOf(PASSWORD_KEY) >= 4) { + Pair pair = paseKey(buffer); + tmpPassword = trimQuote(pair.second()); + } else if (buffer.indexOf(LOGIN_KEY) >= 4) { + Pair pair = paseKey(buffer); + tmpLogin = trimQuote(pair.second()); + } else if (buffer.indexOf(DATABASE_KEY) >= 4) { + Pair pair = paseKey(buffer); + tmpDatabase = trimQuote(pair.second()); + } else if (buffer.indexOf(SORRYSERVER_KEY) >= 4) { + Pair pair = paseKey(buffer); + tmpSorryServer = pair.second(); + } else if (buffer.indexOf(REALDOWNCALLBACK_KEY) >= 4) { + Pair pair = paseKey(buffer); + tmpRealDownCallback = trimQuote(pair.second()); + } else if (buffer.indexOf(REALRECOVERCALLBACK_KEY) >= 4) { + Pair pair = paseKey(buffer); + tmpRealRecoverCallback = trimQuote(pair.second()); + } else if (buffer.indexOf(VIRTUAL_KEY) == 0) { + Pair pair = paseKey(buffer); + VirtualSetting vs = new VirtualSetting(); + int pos = pair.second().indexOf(":"); + vs.virtual.host = pair.second().substring(0, pos); + vs.virtual.port = pair.second().substring(pos + 1, + pair.second().length()); + if (! vs.virtual.port.matches("^\\d+$")) + vs.virtual.port = GetServ.byName(vs.virtual.port, "tcp"); + for (Iterator itr = tmpReal.iterator(); itr + .hasNext();) { + String realstr = itr.next(); + pos = realstr.indexOf(":"); + EndPoint ed = new EndPoint(); + ed.host = realstr.substring(0, pos); + int spacepos = realstr.lastIndexOf(" "); + String tmpWeight = ""; + if (spacepos == -1) { + ed.port = realstr.substring(pos + 1, realstr + .length()); + } else { + ed.port = realstr.substring(pos + 1, spacepos).replaceAll(" masq", ""); + tmpWeight = realstr.substring(spacepos + 1, realstr + .length()); + } + if (! ed.port.matches("^\\d+$")) + ed.port = GetServ.byName(ed.port, "tcp"); + + if (tmpWeight.length() != 0) { + try { + ed.weight = Integer.parseInt(tmpWeight); + } catch (java.lang.NumberFormatException e) { + ed.weight = 1; + } + } + vs.real.add(ed); + } + vs.checktype = tmpCheckType; + if (tmpMaxConn.length() != 0) + vs.maxconn = Integer.parseInt(tmpMaxConn); + pos = tmpModule.indexOf(" "); + if (pos != -1) { + vs.protomod = tmpModule.substring(0, pos); + vs.option = tmpModule + .substring(pos + 1, tmpModule.length()); + } else { + vs.protomod = tmpModule; + vs.option = ""; + } + vs.protocol = tmpProtocol; + if (tmpQosClients.length() != 0) { + if ((pos = tmpQosClients.indexOf('k')) != -1 + || (pos = tmpQosClients.indexOf('K')) != -1) { + vs.qosclient = Long.parseLong(tmpQosClients + .substring(0, pos)); + vs.qosclient = vs.qosclient * 1000; + } else if ((pos = tmpQosClients.indexOf('M')) != -1 + || (pos = tmpQosClients.indexOf('m')) != -1) { + vs.qosclient = Long.parseLong(tmpQosClients + .substring(0, pos)); + vs.qosclient = vs.qosclient * 1000000; + } else { + vs.qosclient = Long.parseLong(tmpQosClients); + } + } + // QoSService + if (tmpQosService.length() != 0) { + if ((pos = tmpQosService.indexOf('K')) != -1 + || (pos = tmpQosService.indexOf('k')) != -1) { + vs.qosservice = Long.parseLong(tmpQosService + .substring(0, pos)); + vs.qosservice = vs.qosservice * 1000; + } else if ((pos = tmpQosService.indexOf('M')) != -1 + || (pos = tmpQosService.indexOf('m')) != -1) { + vs.qosservice = Long.parseLong(tmpQosService + .substring(0, pos)); + vs.qosservice = vs.qosservice * 1000000; + } else { + vs.qosservice = Long.parseLong(tmpQosService); + } + } + vs.receive = tmpReceive; + vs.service = tmpService; + vs.request = tmpRequest; + vs.sched = tmpScheduler; + pos = tmpSorryServer.indexOf(":"); + if (pos != -1) { + vs.sorryserver.host = tmpSorryServer.substring(0, pos); + vs.sorryserver.port = tmpSorryServer.substring(pos + 1, + tmpSorryServer.length()); + if (! vs.sorryserver.port.matches("^\\d+$")) + vs.sorryserver.port = GetServ.byName(vs.sorryserver.port, "tcp"); + } + vs.quiescent = tmpQuiescent; + vs.upcallback = tmpRealRecoverCallback; + vs.downcallback = tmpRealDownCallback; + if (tmpCheckport.length() != 0) + vs.checkport = Integer.parseInt(tmpCheckport); + vs.httpmethod = tmpHttpMethod; + vs.virtualhost = tmpVirtualHost; + vs.login = tmpLogin; + vs.database = tmpDatabase; + vs.passwd = tmpPassword; + if (tmpCheckType != null && + ((tmpCheckType.equals("connect") || tmpCheckType.equals("ping")) || + ((tmpCheckType.equals("negotiate") || tmpCheckType.matches("^\\d$")) && + tmpService != null && (tmpService.equals("dns") || tmpService.equals("sip")) + ) + ) + ) { + if (tmpCheckTimeOut.matches("^\\d+$")) + vs.timeout = Integer.parseInt(tmpCheckTimeOut); + } + else { + if (tmpNegotiateTimeOut.matches("^\\d+$")) + vs.timeout = Integer.parseInt(tmpNegotiateTimeOut); + } + if (tmpCheckCount.matches("^\\d+$")) + vs.checkcount = Integer.parseInt(tmpCheckCount); + vs.cfPosition = position; + position--; + data.virtualSettings.add(vs); + tmpCheckTimeOut = ""; + tmpCheckCount = ""; + tmpNegotiateTimeOut = ""; + tmpQuiescent = ""; + tmpQosClients = ""; + tmpQosService = ""; + tmpSorryServer = ""; + tmpMaxConn = ""; + tmpProtocol = ""; + tmpScheduler = ""; + tmpReceive = ""; + tmpRequest = ""; + tmpService = ""; + tmpModule = ""; + tmpReal = new Vector(); + tmpCheckType = ""; + tmpCheckport = ""; + tmpHttpMethod = ""; + tmpVirtualHost = ""; + tmpPassword = ""; + tmpLogin = ""; + tmpDatabase = ""; + tmpRealDownCallback = ""; + tmpRealRecoverCallback = ""; + }// keyif if + }// while(stack) + data.autoreload = tmpGlobalAutoreaload; + data.callback = tmpGlobalCallback; + data.checkCount = tmpGlobalCheckCount; + data.checkInterval = tmpGlobalCheckInterval; + data.checkTimeOut = tmpGlobalCheckTimeOut; + data.fallback = tmpGlobalFallback; + data.logfile = tmpGlobalLogFile; + data.execute = tmpGlobalExecute; + data.negotiateTimeOut = tmpGlobalNegotiateTimeOut; + data.quiescent = tmpGlobalQuiescent; + data.supervised = tmpGlobalSupervised; + } catch (Exception e) { + org.ultramonkey.l7.model.FileNotReadException ex = new org.ultramonkey.l7.model.FileNotReadException(); + throw ex; + } + + return data; + } + + /** + * + *

+ * buildNewConf method + *

+ * + * @param in + * @return new configuration lines + * @throws org.ultramonkey.l7.model.FileNotWriteException + */ + protected LinkedList buildNewConf(DirectorData in) + throws org.ultramonkey.l7.model.FileNotWriteException { + LinkedList datas = new LinkedList(); + try { + java.io.FileReader file = new java.io.FileReader(filename); + java.io.BufferedReader reader = new java.io.BufferedReader(file); + String buffer; + while ((buffer = reader.readLine()) != null) { + datas.addLast(buffer); + } + } catch (Exception e) { + org.ultramonkey.l7.model.FileNotWriteException ex = new org.ultramonkey.l7.model.FileNotWriteException(); + ex.setErrMessage("Cannot open file : " + filename); + throw ex; + } + + try { + HashMap map = new HashMap(); + map.put(CHECKTIMEOUT_KEY, in.checkTimeOut); + map.put(CHECKINTERVAL_KEY, in.checkInterval); + map.put(CHECKCOUNT_KEY, in.checkCount); + map.put(FALLBACK_KEY, in.fallback); + if (in.autoreload) + map.put(AUTORELOAD_KEY, "yes"); + else + map.put(AUTORELOAD_KEY, "no"); + if (in.logfile != null && in.logfile.length() > 0) + map.put(LOGFILE_KEY, "\"" + in.logfile + "\""); + else + map.put(LOGFILE_KEY, null); + if (in.execute != null && in.execute.length() > 0) + map.put(EXECUTE_KEY, "\"" + in.execute + "\""); + else + map.put(EXECUTE_KEY, null); + map.put(QUIESCENT_KEY, in.quiescent); + if (in.callback != null && in.callback.length() > 0) + map.put(CALLBACK_KEY, "\"" + in.callback + "\""); + else + map.put(CALLBACK_KEY, null); + map.put(NEGOTIATE_TIMEOUT_KEY, in.negotiateTimeOut); + if (in.supervised != null && in.supervised.equals("yes")) + map.put(SUPERVISED_KEY, in.supervised); + else + map.put(SUPERVISED_KEY, null); + + // global datas + for (Iterator itr = map.keySet().iterator(); itr.hasNext();) { + String key = itr.next(); + String value = map.get(key); + int commentLines = 0; + boolean inserted = false; + for (int i = 0; i < datas.size(); ++i) { + String line = datas.get(i); + String buffer = line.replaceAll("\\s+$", ""); + if (buffer.length() == 0 || buffer.matches("^\\s*#.*")) { + commentLines++; + continue; + } + else if (buffer.indexOf(VIRTUAL_KEY) == 0) { + if (value != null && value.length() > 0) { + StringBuffer buf = new StringBuffer(key); + if (! key.equals(SUPERVISED_KEY)) { + buf.append("="); + buf.append(value); + } + datas.add(i - commentLines, buf.toString()); + } + inserted = true; + break; + } + commentLines = 0; + Pair pair = paseKey(buffer); + if (pair.first().equals(key)) { + if (value == null || ! pair.second().equals(value)) { + StringBuffer buf = new StringBuffer("#"); + buf.append(buffer); + datas.set(i, buf.toString()); + if (value != null && value.length() > 0) { + buf = new StringBuffer(); + buf.append(key); + if (! key.equals(SUPERVISED_KEY)) { + buf.append("="); + buf.append(value); + } + datas.add(i, buf.toString()); + } + } + inserted = true; + break; + } + } + if (inserted == false) { + if (value != null && value.length() > 0) { + StringBuffer buf = new StringBuffer(key); + if (! key.equals(SUPERVISED_KEY)) { + buf.append("="); + buf.append(value); + } + datas.add(buf.toString()); + } + } + } + // virtual settings + DirectorData currentData = null; + currentData = this.loadFromFile(); + LinkedList delVsPosition = new LinkedList(); + LinkedList addVs = new LinkedList(); + for (Iterator itr = in.virtualSettings + .iterator(); itr.hasNext();) { + VirtualSetting vs = itr.next(); + boolean sameFlag = false; + for (Iterator curItr = currentData.virtualSettings + .iterator(); curItr.hasNext();) { + VirtualSetting curVs = curItr.next(); + if (curVs.equals(vs)) { + sameFlag = true; + curVs.cfPosition = 0; + break; + } + } + if (sameFlag == false) { + addVs.add(vs); + } + } + for (Iterator curItr = currentData.virtualSettings + .iterator(); curItr.hasNext();) { + VirtualSetting curVs = curItr.next(); + if (curVs.cfPosition != 0) + delVsPosition.add(curVs.cfPosition); + } + + int position = 0; + int commentLines = 0; + for (int i = 0; i < datas.size(); ++i) { + String buffer = datas.get(i); + String line = buffer.replaceAll("\\s+$", ""); + if (line.length() == 0 || line.matches("^\\s*#.*")) { + continue; + } + else if (buffer.indexOf(VIRTUAL_KEY) == 0) { + position++; + if (delVsPosition.contains(position)) { + int vsStartLine = i; + for (; i < datas.size(); ++i) { + buffer = datas.get(i); + line = buffer.replaceAll("\\s+$", ""); + if (line.length() == 0 || line.matches("^\\s*#.*")) { + commentLines++; + continue; + } + if (buffer.indexOf(VIRTUAL_KEY) == 0 && i != vsStartLine) { + i -= 1 + commentLines; + commentLines = 0; + break; + } + commentLines = 0; + StringBuffer buf = new StringBuffer("#"); + buf.append(datas.get(i)); + datas.set(i, buf.toString()); + } + } + } + } + for (VirtualSetting vs : addVs) { + datas.add(VIRTUAL_KEY + "=" + vs.virtual.host + + ":" + vs.virtual.port); + if (vs.real.size() != 0) { + for (java.util.Iterator realitr = vs.real + .iterator(); realitr.hasNext();) { + EndPoint endpoint = realitr.next(); + datas.add("\t" + REAL_KEY + "=" + endpoint.host + + ":" + endpoint.port + " masq " + + String.valueOf(endpoint.weight)); + } + } + if (vs.checktype.length() != 0) + datas.add("\t" + CHECKTYPE_KEY + "=" + vs.checktype); + if (vs.checkport != 0) + datas.add("\t" + CHECKPORT_KEY + "=" + vs.checkport); + if (vs.maxconn != 0) + datas.add("\t" + MAXCONN_KEY + "=" + + String.valueOf(vs.maxconn)); + if (vs.protomod.length() != 0) + datas.add("\t" + MODULE_KEY + "=" + vs.protomod + " " + + vs.option); + if (vs.qosclient != 0) { + StringBuffer buf = new StringBuffer(); + if (vs.qosclient > 1000000) { + buf.append(vs.qosclient / 1000000); + buf.append('M'); + } else if (vs.qosclient > 1000) { + buf.append(vs.qosclient / 1000); + buf.append('K'); + } else + buf.append(vs.qosclient); + datas.add("\t" + QOSCLIENTS_KEY + "=" + + buf.toString()); + } + if (vs.qosservice != 0) { + StringBuffer buf = new StringBuffer(); + if (vs.qosservice > 1000000) { + buf.append(vs.qosservice / 1000000); + buf.append('M'); + } else if (vs.qosservice > 1000) { + buf.append(vs.qosservice / 1000); + buf.append('K'); + } else + buf.append(vs.qosservice); + datas.add("\t" + QOSSERVICE_KEY + "=" + + buf.toString()); + } + if (vs.receive.length() != 0) + datas.add("\t" + RECEIVE_KEY + "=\"" + vs.receive + "\""); + if (vs.service.length() != 0) + datas.add("\t" + SERVICE_KEY + "=\"" + vs.service + "\""); + if (vs.request.length() != 0) + datas.add("\t" + REQUEST_KEY + "=\"" + vs.request + "\""); + if (vs.sched.length() != 0) + datas.add("\t" + SCHEDULER_KEY + "=" + vs.sched); + if (vs.sorryserver.host.length() != 0) + datas.add("\t" + SORRYSERVER_KEY + "=" + + vs.sorryserver.host + ":" + vs.sorryserver.port); + if (vs.httpmethod.length() != 0) + datas.add("\t" + HTTPMETHOD_KEY + "=" + vs.httpmethod); + if (vs.virtualhost.length() != 0) + datas.add("\t" + VIRTUALHOST_KEY + "=\"" + vs.virtualhost + "\""); + if (vs.passwd.length() != 0) + datas.add("\t" + PASSWORD_KEY + "=\"" + vs.passwd + "\""); + if (vs.login.length() != 0) + datas.add("\t" + LOGIN_KEY + "=\"" + vs.login + "\""); + if (vs.database.length() != 0) + datas.add("\t" + DATABASE_KEY + "=\"" + vs.database + "\""); + if (vs.downcallback.length() != 0) + datas.add("\t" + REALDOWNCALLBACK_KEY + "=\"" + + vs.downcallback + "\""); + if (vs.upcallback.length() != 0) + datas.add("\t" + REALRECOVERCALLBACK_KEY + "=\"" + + vs.upcallback + "\""); +// if (vs.checkcount != 0) +// datas.add("\t" + CHECKCOUNT_KEY + "=" + vs.checkcount); + if (vs.timeout != 0) { + if (vs.checktype != null && + ((vs.checktype.equals("connect") || vs.checktype.equals("ping")) || + ((vs.checktype.equals("negotiate") || vs.checktype.matches("^\\d$")) && + vs.service != null && (vs.service.equals("dns") || vs.service.equals("sip")) + ) + ) + ) { + datas.add("\t" + CHECKTIMEOUT_KEY + "=" + vs.timeout); + } + else { + datas.add("\t" + NEGOTIATE_TIMEOUT_KEY + "=" + vs.timeout); + } + } + if (vs.quiescent.length() != 0) + datas.add("\t" + QUIESCENT_KEY + "=" + vs.quiescent); + if (vs.protocol.length() != 0) + datas.add("\t" + PROTOCOL_KEY + "=" + vs.protocol); + datas.add(""); + } + } catch (Exception e) { + org.ultramonkey.l7.model.FileNotWriteException ex = new org.ultramonkey.l7.model.FileNotWriteException(); + ex.setErrMessage("Cannot open file : " + filename + + "BaseException : " + e.getMessage()); + throw ex; + } + + return datas; + } + + /** + * + *

+ * saveToFile method + *

+ * + * @param in + * @throws org.ultramonkey.l7.model.FileNotWriteException + */ + protected void saveToFile(DirectorData in) + throws org.ultramonkey.l7.model.FileNotWriteException { + LinkedList datas = this.buildNewConf(in); + try { + java.io.File file = new java.io.File(filename); + if (file.exists()) { + Date date = new Date(); + java.io.File backfile = new java.io.File(filename + ".bak." + + String.valueOf(date.getTime())); + file.renameTo(backfile); + file = new java.io.File(filename); + } + java.io.FileWriter writer = new java.io.FileWriter(file); + for (Iterator itr = datas.iterator(); itr + .hasNext();) { + StringBuffer buf = new StringBuffer(itr.next()); + buf.append('\n'); + writer.write(buf.toString()); + } + writer.flush(); + writer.close(); + } catch (Exception e) { + org.ultramonkey.l7.model.FileNotWriteException ex = new org.ultramonkey.l7.model.FileNotWriteException(); + ex.setErrMessage("Cannot write file : " + filename); + throw ex; + } + } + + /** + * + *

+ * syntaxCheck method + *

+ * + * @param in + * @throws org.ultramonkey.l7.model.FileNotWriteException + */ + protected String syntaxCheck(DirectorData in) + throws org.ultramonkey.l7.model.FileNotWriteException { + StringBuffer result = new StringBuffer(); + LinkedList datas = this.buildNewConf(in); + try { + Date date = new Date(); + String tmpFile = filename + "." + String.valueOf(date.getTime()); + File file = new java.io.File(tmpFile); + FileWriter writer = new FileWriter(file); + for (Iterator itr = datas.iterator(); itr + .hasNext();) { + StringBuffer buf = new StringBuffer(itr.next()); + buf.append('\n'); + writer.write(buf.toString()); + } + writer.flush(); + writer.close(); + + // TODO sudo + String command = "sudo " + l7directord + " -t " + tmpFile; + Process p = Runtime.getRuntime().exec(command); + InputStream stderr = p.getErrorStream(); + BufferedReader br = new BufferedReader(new InputStreamReader(stderr)); + String line = null; + while ((line = br.readLine()) != null) { + result.append(line + "\n"); + } + InputStream is = p.getInputStream(); + br = new BufferedReader(new InputStreamReader(is)); + while ((line = br.readLine()) != null) { + result.append(line + "\n"); + } + + file.delete(); + } catch (Exception e) { + org.ultramonkey.l7.model.FileNotWriteException ex = new org.ultramonkey.l7.model.FileNotWriteException(); + ex.setErrMessage("Cannot write file : " + filename); + throw ex; + } + + return result.toString(); + } + + /** + * get DirectorData from l7directord.cf + *

+ * getDirectorData method + *

+ * + * @return DirectorData l7directord.cf datas + * @throws org.ultramonkey.l7.model.FileNotReadException + */ + public DirectorData getDirectorData() + throws org.ultramonkey.l7.model.FileNotReadException { + // --- debug log (in method) --- + Logger ioFileLogger = Logger.getLogger(LogCategorySet.GUI_IO_FILE); + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11575 DirectorController::getDirectorData() in"); + } + // --- debug log (in method) --- + + DirectorData data = null; + synchronized (this) { + if (serchfile()) { + data = loadFromFile(); + } + } + + // --- debug log (out method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11576 DirectorController::getDirectorData() out return=(" + data + ")"); + } + // --- debug log (out method) --- + return data; + } + + /** + * set DirectorData to l7directord.cf + *

+ * setDirectorData method + *

+ * + * @param in + */ + public void setDirectorData(DirectorData in) + throws org.ultramonkey.l7.model.FileNotWriteException { + // --- debug log (in method) --- + Logger ioFileLogger = Logger.getLogger(LogCategorySet.GUI_IO_FILE); + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11577 DirectorController::setDirectorData(DirectorData in) in in=(" + in + ")"); + } + // --- debug log (in method) --- + + synchronized (this) { + if (in != null && serchfile()) { + saveToFile(in); + } + } + + // --- debug log (out method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11578 DirectorController::setDirectorData(DirectorData in) out"); + } + // --- debug log (out method) --- + } + + /** + * check new l7directord.cf + *

+ * checkDirectorData method + *

+ * + * @param in + */ + public String checkDirectorData(DirectorData in) + throws org.ultramonkey.l7.model.FileNotWriteException { + // --- debug log (in method) --- + Logger ioFileLogger = Logger.getLogger(LogCategorySet.GUI_IO_FILE); + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11579 DirectorController::checkDirectorData(DirectorData in) in in=(" + in + ")"); + } + // --- debug log (in method) --- + + synchronized (this) { + if (in != null && serchfile()) { + String ret = this.syntaxCheck(in); + + // --- debug log (out method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11580 DirectorController::checkDirectorData(DirectorData in) out return=\"" + ret + "\""); + } + // --- debug log (out method) --- + return ret; + } + + // --- debug log (out method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11581 DirectorController::checkDirectorData(DirectorData in) out return=null"); + } + // --- debug log (out method) --- + return null; + } + } +} diff --git a/src/src/org/ultramonkey/l7/controller/DirectorData.java b/src/src/org/ultramonkey/l7/controller/DirectorData.java new file mode 100644 index 0000000..a959165 --- /dev/null +++ b/src/src/org/ultramonkey/l7/controller/DirectorData.java @@ -0,0 +1,109 @@ +package org.ultramonkey.l7.controller; + +import java.io.Serializable; +import java.util.Vector; + +import org.apache.log4j.Logger; +import org.ultramonkey.l7.model.LogCategorySet; + +public class DirectorData implements Serializable { + static final long serialVersionUID = 1; + + public String checkTimeOut; + + public String negotiateTimeOut; + + public String checkInterval; + + public String checkCount; + + public boolean autoreload; + + public String callback; + + public String fallback; + + public String logfile; + + public String execute; + + public String supervised; + + public String quiescent; + + public Vector virtualSettings; + + public DirectorData() { + // --- debug log (constructor) --- + Logger ioFileLogger = Logger.getLogger(LogCategorySet.GUI_IO_FILE); + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11582 class DirectorData created."); + } + // --- debug log (constructor) --- + this.autoreload = false; + this.callback = ""; + this.checkCount = ""; + this.checkInterval = ""; + this.checkTimeOut = ""; + this.execute = ""; + this.fallback = ""; + this.logfile = ""; + this.negotiateTimeOut = ""; + this.quiescent = ""; + this.supervised = ""; + this.virtualSettings = new Vector(); + } + + public DirectorData( DirectorData inData ){ + // --- debug log (constructor) --- + Logger ioFileLogger = Logger.getLogger(LogCategorySet.GUI_IO_FILE); + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11583 class DirectorData created."); + } + // --- debug log (constructor) --- + this.autoreload = inData.autoreload; + this.callback = inData.callback; + this.checkCount = inData.checkCount; + this.checkInterval = inData.checkInterval; + this.checkTimeOut = inData.checkTimeOut; + this.execute = inData.execute; + this.fallback = inData.fallback; + this.logfile = inData.logfile; + this.negotiateTimeOut = inData.negotiateTimeOut; + this.quiescent = inData.quiescent; + this.supervised = inData.supervised; + this.virtualSettings = inData.virtualSettings; + } + + public boolean equals(DirectorData in) { + if( this.autoreload == in.autoreload && + this.callback.equals(in.callback) && + this.checkCount.equals(in.checkCount) && + this.checkInterval.equals(in.checkInterval) && + this.checkTimeOut.equals(in.checkTimeOut) && + this.fallback.equals(in.fallback) && + this.logfile.equals(in.logfile) && + this.negotiateTimeOut.equals(in.negotiateTimeOut) && + this.supervised.equals(in.supervised) && + this.virtualSettings.equals(in.virtualSettings)){ + return true; + } + return false; + } + + public String toString() { + return + "checkTimeOut=\"" + this.checkTimeOut + "\", " + + "negotiateTimeOut=\"" + this.negotiateTimeOut + "\", " + + "checkInterval=\"" + this.checkInterval + "\", " + + "checkCount=\"" + this.checkCount + "\", " + + "autoreload=" + this.autoreload + ", " + + "callback=\"" + this.callback + "\", " + + "fallback=\"" + this.fallback + "\", " + + "logfile=\"" + this.logfile + "\", " + + "execute=\"" + this.execute + "\", " + + "supervised=\"" + this.supervised + "\", " + + "quiescent=\"" + this.quiescent + "\", " + + "virtualSettings=(" + this.virtualSettings + ")"; + } +} diff --git a/src/src/org/ultramonkey/l7/controller/EndPoint.java b/src/src/org/ultramonkey/l7/controller/EndPoint.java new file mode 100644 index 0000000..ccea3da --- /dev/null +++ b/src/src/org/ultramonkey/l7/controller/EndPoint.java @@ -0,0 +1,204 @@ +package org.ultramonkey.l7.controller; + +import java.io.Serializable; + +import org.apache.log4j.Logger; +import org.ultramonkey.l7.model.LogCategorySet; + +/** + * + *

+ * class EndPoint + *

+ *

+ * Copyright(c) NTT COMWARE 2008 + *

+ * + * @author tanuma + */ +public class EndPoint implements Serializable { + static final long serialVersionUID = 1L; + + /** + * IP address + */ + public String host; + + /** + * Port number + */ + public String port; + + /** + * Weight + */ + public int weight; + + /** + * Active connections + */ + public long actConn; + + /** + * Inactive connections + */ + public long inActConn; + + /** + * + * Constructor + * + */ + public EndPoint() { + // --- debug log (constructor) --- + Logger vsLogger = Logger.getLogger(LogCategorySet.GUI_VIRTUALSERVICE); + if (vsLogger.isDebugEnabled()) { + vsLogger.debug("11513 class EndPoint created."); + } + // --- debug log (constructor) --- + + host = ""; + port = ""; + weight = 0; + actConn = 0; + inActConn = 0; + } + + /** + * + * Constructor for real server + * + * @param host + * @param port + * @param weight + * @param actConn + * @param inActConn + */ + public EndPoint(String host, String port, int weight, long actConn, + long inActConn) { + // --- debug log (constructor) --- + Logger vsLogger = Logger.getLogger(LogCategorySet.GUI_VIRTUALSERVICE); + if (vsLogger.isDebugEnabled()) { + vsLogger.debug("11514 class EndPoint created."); + } + // --- debug log (constructor) --- + + if (host == null) + this.host = ""; + else + this.host = new String(host); + if (port == null) + this.port = ""; + else + this.port = new String(port); + this.weight = weight; + this.actConn = actConn; + this.inActConn = inActConn; + } + + /** + * + * Constructor for virtual service, sorry server + * + * @param host + * @param port + */ + public EndPoint(String host, String port) { + // --- debug log (constructor) --- + Logger vsLogger = Logger.getLogger(LogCategorySet.GUI_VIRTUALSERVICE); + if (vsLogger.isDebugEnabled()) { + vsLogger.debug("11515 class EndPoint created."); + } + // --- debug log (constructor) --- + + if (host == null) + this.host = ""; + else + this.host = new String(host); + if (port == null) + this.port = ""; + else + this.port = new String(port); + this.weight = 0; + this.actConn = 0; + this.inActConn = 0; + } + + /** + * + * Copy Constructor + * + * @param e + */ + public EndPoint(EndPoint e) { + // --- debug log (constructor) --- + Logger vsLogger = Logger.getLogger(LogCategorySet.GUI_VIRTUALSERVICE); + if (vsLogger.isDebugEnabled()) { + vsLogger.debug("11516 class EndPoint created."); + } + // --- debug log (constructor) --- + + if (e == null) { + host = ""; + port = ""; + weight = 0; + actConn = 0; + inActConn = 0; + } else { + if (e.host != null) + this.host = new String(e.host); + if (e.port != null) + this.port = new String(e.port); + this.weight = e.weight; + this.actConn = e.actConn; + this.inActConn = e.inActConn; + } + } + + /** + * + *

+ * equals method + *

+ * + * @param e + * @return + */ + public boolean equals(EndPoint e) { + // --- debug log (in method) --- + Logger vsLogger = Logger.getLogger(LogCategorySet.GUI_VIRTUALSERVICE); + if (vsLogger.isDebugEnabled()) { + vsLogger.debug("11517 EndPoint::equals(EndPoint e) in e=(" + e + ")"); + } + // --- debug log (in method) --- + + if (e != null && this.host.equals(e.host) && this.port.equals(e.port)) { + // --- debug log (out method) --- + if (vsLogger.isDebugEnabled()) { + vsLogger.debug("11518 EndPoint::equals(EndPoint e) out return=true"); + } + // --- debug log (out method) --- + return true; + } + + // --- debug log (out method) --- + if (vsLogger.isDebugEnabled()) { + vsLogger.debug("11519 EndPoint::equals(EndPoint e) out return=false"); + } + // --- debug log (out method) --- + return false; + } + + /** + * + * {@inheritDoc} + */ + public String toString() { + return + "host=\"" + host + "\", " + + "port=\"" + port + "\", " + + "weight=" + weight + ", " + + "actConn=" + actConn + ", " + + "inActConn=" + inActConn; + } +} diff --git a/src/src/org/ultramonkey/l7/controller/GetServ.java b/src/src/org/ultramonkey/l7/controller/GetServ.java new file mode 100644 index 0000000..67306a3 --- /dev/null +++ b/src/src/org/ultramonkey/l7/controller/GetServ.java @@ -0,0 +1,113 @@ +package org.ultramonkey.l7.controller; + +import java.util.regex.*; +import java.io.*; + +import org.apache.log4j.Logger; +import org.ultramonkey.l7.model.LogCategorySet; + +/** + * + *

+ * class GetServ + *

+ *

+ * Copyright(c) NTT COMWARE 2008 + *

+ * + * @author tanuma + */ +public class GetServ { + + /** + * services filename + */ + private static final String SERVICE_FILENAME = "/etc/services"; + + /** + * + *

+ * byName method + *

+ * + * @param name + * service name + * @param proto + * protocol name + * @return + */ + public static String byName(String name, String proto) { + // --- debug log (in method) --- + Logger ioFileLogger = Logger.getLogger(LogCategorySet.GUI_IO_FILE); + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger + .debug("11584 GetServ::byName(String name, String proto) in name=\"" + + name + "\", proto=\"" + proto + "\""); + } + // --- debug log (in method) --- + + if (name == null || proto == null) { + // --- debug log (out method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger + .debug("11585 GetServ::byName(String name, String proto) out return=null"); + } + // --- debug log (out method) --- + return null; + } + + try { + String port = null; + String line; + + String regex = "^([-_a-zA-Z0-9]+)\\s+(\\d+)/([-_a-zA-Z0-9]+)([-_a-zA-Z0-9\\s]+)*$"; + Pattern p = Pattern.compile(regex); + + BufferedReader br = new BufferedReader(new InputStreamReader( + new FileInputStream(SERVICE_FILENAME))); + + while ((line = br.readLine()) != null && port == null) { + line = line.replaceAll("#.*", ""); + if (line.length() != 0) { + Matcher m = p.matcher(line.trim()); + if (m.matches() && m.group(3).equals(proto)) { + if (m.group(1).equals(name)) { + port = m.group(2); + } else if (m.group(4) != null) { + String[] aliases = m.group(4).split("\\s"); + for (String alias : aliases) { + if (alias.equals(name)) { + port = m.group(2); + break; + } + } + } + } + } + } + br.close(); + if (port != null) { + // --- debug log (out method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11586 GetServ::byName(String name, String proto) out return=\"" + port + "\""); + } + // --- debug log (out method) --- + return port; + } else { + // --- debug log (out method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11587 GetServ::byName(String name, String proto) out return=\"" + name + "\""); + } + // --- debug log (out method) --- + return name; + } + } catch (IOException ioe) { + // --- debug log (out method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11588 GetServ::byName(String name, String proto) out return=null"); + } + // --- debug log (out method) --- + return null; + } + } +} diff --git a/src/src/org/ultramonkey/l7/controller/L7vsAdmController.java b/src/src/org/ultramonkey/l7/controller/L7vsAdmController.java new file mode 100644 index 0000000..c6fcef7 --- /dev/null +++ b/src/src/org/ultramonkey/l7/controller/L7vsAdmController.java @@ -0,0 +1,1247 @@ +package org.ultramonkey.l7.controller; + +import org.apache.log4j.Logger; +import org.ultramonkey.l7.model.*; +import java.util.regex.*; +import java.util.*; +import java.io.*; + +/** + * + *

+ * class L7vsAdmController + *

+ *

+ * Copyright(c) NTT COMWARE 2008 + *

+ * + * @author tanuma + */ +public class L7vsAdmController { + private static final String l7vsadm = "/usr/sbin/l7vsadm"; + + private Logger ioCommandLogger = Logger.getLogger(LogCategorySet.GUI_IO_COMMAND); + + /** + * + *

+ * addVirtualService method + *

+ * + * @param vs + * @return result of l7vsadm add virtual service command. + */ + public boolean addVirtualService(VirtualSetting vs) { + // --- debug log (in method) --- + if (ioCommandLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("L7vsAdmController::addVirtualService(VirtualSetting vs) in "); + buf.append("vs=(" + vs + ")"); + ioCommandLogger.debug("11524 " + buf.toString()); + } + // --- debug log (in method) --- + + synchronized (this) { + if (vs == null || vs.virtual == null) { + ioCommandLogger.warn("31003 Invalid null argument."); + // --- debug log (in method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11525 L7vsAdmController::addVirtualService(VirtualSetting vs) out return=false"); + } + // --- debug log (in method) --- + return false; + } + + StringBuffer command = new StringBuffer(l7vsadm + " -A -t " + + vs.virtual.host + ":" + vs.virtual.port + " -m " + + vs.protomod + " " + vs.option + " -s " + vs.sched); + if (vs.maxconn > 0) { + command.append(" -u " + vs.maxconn); + } + if (vs.sorryserver != null && vs.sorryserver.host.length() > 0 && vs.sorryserver.port.length() > 0) { + command.append(" -b " + vs.sorryserver.host + ":" + + vs.sorryserver.port); + } + if (vs.sorryflag == true) { + command.append(" -f 1"); + } + if (vs.qosservice > 0) { + if (vs.qosservice >= 1000000000L) { + long qoss = vs.qosservice / 1000000000L; + command.append(" -Q " + qoss + "G"); + } + else if (vs.qosservice >= 1000000L) { + long qoss = vs.qosservice / 1000000L; + command.append(" -Q " + qoss + "M"); + } + else if (vs.qosservice >= 1000L) { + long qoss = vs.qosservice / 1000L; + command.append(" -Q " + qoss + "K"); + } + else { + command.append(" -Q " + vs.qosservice); + } + } + if (vs.qosclient > 0) { + if (vs.qosclient >= 1000000000L) { + long qosc = vs.qosclient / 1000000000L; + command.append(" -q " + qosc + "G"); + } + else if (vs.qosclient >= 1000000L) { + long qosc = vs.qosclient / 1000000L; + command.append(" -q " + qosc + "M"); + } + else if (vs.qosclient >= 1000L) { + long qosc = vs.qosclient / 1000L; + command.append(" -q " + qosc + "K"); + } + else { + command.append(" -q " + vs.qosclient); + } + } + + String result = runProcess(command.toString()); + if (result == null || result.length() != 0) { + ioCommandLogger.error("41220 Command error: command=" + command); + ioCommandLogger.error("41221 Command error: result=" + result); + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11526 L7vsAdmController::addVirtualService(VirtualSetting vs) out return=false"); + } + // --- debug log (out method) --- + return false; + } + + if (vs.real != null) { + for (int i = 0; i < vs.real.size(); i++) { + EndPoint real = vs.real.elementAt(i); + String realCommand = l7vsadm + " -a -t " + vs.virtual.host + ":" + vs.virtual.port + " -m " + + vs.protomod + " " + vs.option + " -r " + real.host + ":" + real.port + " -w " + real.weight; + result = runProcess(realCommand); + + if (result == null || result.length() != 0) { + ioCommandLogger.error("41222 Command error: command=" + command); + ioCommandLogger.error("41223 Command error: result=" + result); + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11527 L7vsAdmController::addVirtualService(VirtualSetting vs) out return=false"); + } + // --- debug log (out method) --- + return false; + } + } + } + + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11528 L7vsAdmController::addVirtualService(VirtualSetting vs) out return=true"); + } + // --- debug log (out method) --- + return true; + } + } + + /** + * + *

+ * delVirtualService method + *

+ * + * @param vs + * @return result of l7vsadm delete virtual service command. + */ + public boolean delVirtualService(VirtualSetting vs) { + // --- debug log (in method) --- + if (ioCommandLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("L7vsAdmController::delVirtualService(VirtualSetting vs) in "); + buf.append("vs=(" + vs + ")"); + ioCommandLogger.debug("11529 " + buf.toString()); + } + // --- debug log (in method) --- + + synchronized (this) { + if (vs == null || vs.virtual == null) { + ioCommandLogger.warn("31004 Invalid null argument."); + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11530 L7vsAdmController::delVirtualService(VirtualSetting vs) out return=false"); + } + // --- debug log (out method) --- + return false; + } + String command = l7vsadm + " -D -t " + vs.virtual.host + ":" + + vs.virtual.port + " -m " + vs.protomod + " " + vs.option; + + String result = runProcess(command); + if (result == null || result.length() != 0) { + ioCommandLogger.error("41224 Command error: command=" + command); + ioCommandLogger.error("41225 Command error: result=" + result); + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11531 L7vsAdmController::delVirtualService(VirtualSetting vs) out return=false"); + } + // --- debug log (out method) --- + return false; + } + + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11532 L7vsAdmController::delVirtualService(VirtualSetting vs) out return=true"); + } + // --- debug log (out method) --- + return true; + } + } + + /** + * + *

+ * getData method + *

+ * + * @return result of l7vsadm list command, including virtual service + * setting. + */ + public L7vsAdmData getData() { + // --- debug log (in method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11533 L7vsAdmController::getData() in"); + } + // --- debug log (in method) --- + + synchronized (this) { + L7vsAdmData admData = new L7vsAdmData(); + + String command = l7vsadm + " -V -n"; + String result = runProcess(command); + + if (result == null) { + ioCommandLogger.error("41226 Command error: command=" + command); + ioCommandLogger.error("41227 Command error: result=null"); + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11534 L7vsAdmController::getData() out return=null"); + } + // --- debug log (out method) --- + return null; + } + + // l7vsd log level regex + Pattern l7vsdLogLevel = Pattern.compile( + "^(l7vsd_[\\w\\.]+)\\s+(debug|info|warn|error|fatal)$", + Pattern.MULTILINE); + Matcher l7vsdLog = l7vsdLogLevel.matcher(result); + while (l7vsdLog.find()) { + LogData.LogLevel level; + if (l7vsdLog.group(2).equals("debug")) + level = LogData.LogLevel.DEBUG; + else if (l7vsdLog.group(2).equals("info")) + level = LogData.LogLevel.INFO; + else if (l7vsdLog.group(2).equals("warn")) + level = LogData.LogLevel.WARN; + else if (l7vsdLog.group(2).equals("error")) + level = LogData.LogLevel.ERROR; + else if (l7vsdLog.group(2).equals("fatal")) + level = LogData.LogLevel.FATAL; + else { + ioCommandLogger.info("21092 Unknown log level: " + l7vsdLog.group(2)); + continue; + } + + if (l7vsdLog.group(1).equals("l7vsd_network")) + admData.l7vsdLogLevel.put(LogData.LogCategory.L7VSD_NETWORK, + level); + else if (l7vsdLog.group(1).equals("l7vsd_network.bandwidth")) + admData.l7vsdLogLevel.put( + LogData.LogCategory.L7VSD_NETWORK_BANDWIDTH, level); + else if (l7vsdLog.group(1).equals("l7vsd_network.num_connection")) + admData.l7vsdLogLevel + .put(LogData.LogCategory.L7VSD_NETWORK_NUM_CONNECTION, + level); + else if (l7vsdLog.group(1).equals("l7vsd_network.qos")) + admData.l7vsdLogLevel.put( + LogData.LogCategory.L7VSD_NETWORK_QOS, level); + else if (l7vsdLog.group(1).equals("l7vsd_virtual_service")) + admData.l7vsdLogLevel.put( + LogData.LogCategory.L7VSD_VIRTUAL_SERVICE, level); + else if (l7vsdLog.group(1).equals("l7vsd_real_server")) + admData.l7vsdLogLevel.put( + LogData.LogCategory.L7VSD_REAL_SERVER, level); + else if (l7vsdLog.group(1).equals("l7vsd_sorry_server")) + admData.l7vsdLogLevel.put( + LogData.LogCategory.L7VSD_SORRY_SERVER, level); + else if (l7vsdLog.group(1).equals("l7vsd_real_server.balancing")) + admData.l7vsdLogLevel.put( + LogData.LogCategory.L7VSD_REAL_SERVER_BALANCING, level); + else if (l7vsdLog.group(1).equals("l7vsd_replication")) + admData.l7vsdLogLevel.put( + LogData.LogCategory.L7VSD_REPLICATION, level); + else if (l7vsdLog.group(1).equals("l7vsd_start_stop")) + admData.l7vsdLogLevel.put(LogData.LogCategory.L7VSD_START_STOP, + level); + else if (l7vsdLog.group(1).equals("l7vsd_system")) + admData.l7vsdLogLevel.put(LogData.LogCategory.L7VSD_SYSTEM, + level); + else if (l7vsdLog.group(1).equals("l7vsd_system.memory")) + admData.l7vsdLogLevel.put( + LogData.LogCategory.L7VSD_SYSTEM_MEMORY, level); + else if (l7vsdLog.group(1).equals("l7vsd_system.socket")) + admData.l7vsdLogLevel.put( + LogData.LogCategory.L7VSD_SYSTEM_SOCKET, level); + else if (l7vsdLog.group(1).equals("l7vsd_system.signal")) + admData.l7vsdLogLevel.put( + LogData.LogCategory.L7VSD_SYSTEM_SIGNAL, level); + else if (l7vsdLog.group(1).equals("l7vsd_environment")) + admData.l7vsdLogLevel.put( + LogData.LogCategory.L7VSD_ENVIRONMENT, level); + else if (l7vsdLog.group(1).equals("l7vsd_environment.parameter")) + admData.l7vsdLogLevel.put( + LogData.LogCategory.L7VSD_ENVIRONMENT_PARAMETER, level); + else if (l7vsdLog.group(1).equals("l7vsd_logger")) + admData.l7vsdLogLevel.put(LogData.LogCategory.L7VSD_LOGGER, + level); + else if (l7vsdLog.group(1).equals("l7vsd_parameter")) + admData.l7vsdLogLevel.put(LogData.LogCategory.L7VSD_PARAMETER, + level); + else if (l7vsdLog.group(1).equals("l7vsd_event")) + admData.l7vsdLogLevel.put(LogData.LogCategory.L7VSD_EVENT, + level); + else if (l7vsdLog.group(1).equals("l7vsd_schedule")) + admData.l7vsdLogLevel.put(LogData.LogCategory.L7VSD_SCHEDULE, + level); + else if (l7vsdLog.group(1).equals("l7vsd_program")) + admData.l7vsdLogLevel.put(LogData.LogCategory.L7VSD_PROGRAM, + level); + else if (l7vsdLog.group(1).equals("l7vsd_protocol")) + admData.l7vsdLogLevel.put(LogData.LogCategory.L7VSD_PROTOCOL, + level); + else if (l7vsdLog.group(1).equals("l7vsd_module")) + admData.l7vsdLogLevel.put(LogData.LogCategory.L7VSD_MODULE, + level); + else if (l7vsdLog.group(1).equals("l7vsd_all")) + admData.l7vsdLogLevel.put(LogData.LogCategory.L7VSD_ALL, level); + else { + ioCommandLogger.info("21093 Unknown log category: " + l7vsdLog.group(1)); + continue; + } + } + + // SNMP Agent log level regex + Pattern snmpLogLevel = Pattern.compile( + "^(snmpagent_\\w+)\\s+(debug|info|warn|error|fatal)$", + Pattern.MULTILINE); + Matcher snmpLog = snmpLogLevel.matcher(result); + while (snmpLog.find()) { + LogData.LogLevel level; + if (snmpLog.group(2).equals("debug")) + level = LogData.LogLevel.DEBUG; + else if (snmpLog.group(2).equals("info")) + level = LogData.LogLevel.INFO; + else if (snmpLog.group(2).equals("warn")) + level = LogData.LogLevel.WARN; + else if (snmpLog.group(2).equals("error")) + level = LogData.LogLevel.ERROR; + else if (snmpLog.group(2).equals("fatal")) + level = LogData.LogLevel.FATAL; + else { + ioCommandLogger.info("21094 Unknown log level: " + snmpLog.group(2)); + continue; + } + + if (snmpLog.group(1).equals("snmpagent_start_stop")) + admData.snmpLogLevel.put( + LogData.LogCategory.SNMPAGENT_START_STOP, level); + else if (snmpLog.group(1).equals("snmpagent_manager_receive")) + admData.snmpLogLevel.put( + LogData.LogCategory.SNMPAGENT_MANAGER_RECEIVE, level); + else if (snmpLog.group(1).equals("snmpagent_manager_send")) + admData.snmpLogLevel.put( + LogData.LogCategory.SNMPAGENT_MANAGER_SEND, level); + else if (snmpLog.group(1).equals("snmpagent_l7vsd_receive")) + admData.snmpLogLevel.put( + LogData.LogCategory.SNMPAGENT_L7VSD_RECEIVE, level); + else if (snmpLog.group(1).equals("snmpagent_l7vsd_send")) + admData.snmpLogLevel.put( + LogData.LogCategory.SNMPAGENT_L7VSD_SEND, level); + else if (snmpLog.group(1).equals("snmpagent_logger")) + admData.snmpLogLevel.put(LogData.LogCategory.SNMPAGENT_LOGGER, + level); + else if (snmpLog.group(1).equals("snmpagent_parameter")) + admData.snmpLogLevel.put( + LogData.LogCategory.SNMPAGENT_PARAMETER, level); + else if (snmpLog.group(1).equals("snmpagent_all")) + admData.snmpLogLevel.put(LogData.LogCategory.SNMPAGENT_ALL, + level); + else { + ioCommandLogger.info("21095 Unknown log level: " + snmpLog.group(1)); + continue; + } + } + + // Replication mode regex + Pattern replicationMode = Pattern.compile( + "^Replication Mode:\\s+(\\w+)", Pattern.MULTILINE); + Matcher rep = replicationMode.matcher(result); + if (rep.find()) { + if (rep.group(1).equals("MASTER")) + admData.replicationMode = ReplicationStatus.MASTER; + else if (rep.group(1).equals("MASTER_STOP")) + admData.replicationMode = ReplicationStatus.MASTER_STOP; + else if (rep.group(1).equals("SLAVE")) + admData.replicationMode = ReplicationStatus.SLAVE; + else if (rep.group(1).equals("SLAVE_STOP")) + admData.replicationMode = ReplicationStatus.SLAVE_STOP; + else if (rep.group(1).equals("SINGLE")) + admData.replicationMode = ReplicationStatus.SINGLE; + else if (rep.group(1).equals("OUT")) + admData.replicationMode = ReplicationStatus.OUT; + else { + ioCommandLogger.info("21096 Unknown replication status: " + rep.group(1)); + } + } + + // SNMP Agent connection status regex + Pattern snmpStatus = Pattern.compile( + "^SNMPAgent Connection Status:\\s+([-\\w]+)", Pattern.MULTILINE); + Matcher snmp = snmpStatus.matcher(result); + if (snmp.find()) { + if (snmp.group(1).equals("connecting")) + admData.snmpStatus = SnmpAgentStatus.CONNECTING; + else if (snmp.group(1).equals("non-connecting")) + admData.snmpStatus = SnmpAgentStatus.NON_CONNECTING; + else { + ioCommandLogger.info("21097 Unknown SNMP Agent status: " + snmp.group(1)); + } + } + + VirtualSetting vs = null; + + // Virtual service regex + String virtualLine = "TCP (\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}):(\\d{1,5}) (\\w+) " + + "(\\w+) (0|1) (.*)\\s+([^\\s]+) (\\d+) (0|1)\\s+(\\d+) (\\d+) (\\d+)\\s*"; + // Real server regex + String realLine = "\\s+-> (\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}):(\\d{1,5})\\s+Masq\\s+" + + "(\\d+)\\s+(\\d+)\\s+(\\d+)\\s*"; + + Pattern virtualService = Pattern.compile("^(?:" + virtualLine + "|" + + realLine + ")$", Pattern.MULTILINE); + Matcher virtual = virtualService.matcher(result); + while (virtual.find()) { + + if (virtual.group(1) != null) { // virtual service line found + if (vs != null) + admData.virtualSettings.add(vs); + vs = new VirtualSetting(); + + vs.virtual = new EndPoint(virtual.group(1), virtual.group(2)); + vs.protomod = virtual.group(3); + vs.sched = virtual.group(4); + vs.reschedule = virtual.group(5).equals("0") ? false : true; + vs.option = virtual.group(6); + String[] sorry = virtual.group(7).split(":"); + if (sorry.length == 2 && sorry[1] != null) { + vs.sorryserver = new EndPoint(sorry[0], sorry[1]); + } + vs.maxconn = Integer.parseInt(virtual.group(8)); + vs.sorryflag = virtual.group(9).equals("0") ? false : true; + vs.qosservice = Long.parseLong(virtual.group(10)); + vs.qosclient = Long.parseLong(virtual.group(11)); + vs.throughput = Long.parseLong(virtual.group(12)); + } else { // real server line found + if (vs.real == null) + vs.real = new Vector(); + vs.real.add(new EndPoint(virtual.group(13), virtual.group(14), Integer.parseInt(virtual + .group(15)), Long.parseLong(virtual.group(16)), Long + .parseLong(virtual.group(17)))); + } + } + if (vs != null) + admData.virtualSettings.add(vs); + + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11535 L7vsAdmController::getData() out return=" + admData); + } + // --- debug log (out method) --- + return admData; + } + } + + /** + * + *

+ * setReplicationMode method + *

+ * + * @param mode + * @return result of l7vsadm change replication mode command. + */ + public boolean setReplicationMode(ReplicationStatus mode) { + // --- debug log (in method) --- + if (ioCommandLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("L7vsAdmController::setReplicationMode(ReplicationStatus mode) in "); + buf.append("mode=" + mode); + ioCommandLogger.debug("11536 " + buf.toString()); + } + // --- debug log (in method) --- + + synchronized (this) { + if (mode == null) { + ioCommandLogger.error("41228 Invalid replication status: " + mode); + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11537 L7vsAdmController::setReplicationMode(ReplicationStatus mode) out return=false"); + } + // --- debug log (out method) --- + return false; + } + + String command = l7vsadm + " -R -s "; + switch (mode) { + case MASTER: + case SLAVE: + command += "start"; + break; + case MASTER_STOP: + case SLAVE_STOP: + command += "stop"; + break; + default: + ioCommandLogger.error("41229 Invalid replication status: " + mode); + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11538 L7vsAdmController::setReplicationMode(ReplicationStatus mode) out return=false"); + } + // --- debug log (out method) --- + return false; + } + + String result = runProcess(command); + if (result == null || result.length() != 0) { + ioCommandLogger.error("41230 Command error: command=" + command); + ioCommandLogger.error("41231 Command error: result=" + result); + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11539 L7vsAdmController::setReplicationMode(ReplicationStatus mode) out return=false"); + } + // --- debug log (out method) --- + return false; + } + + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11540 L7vsAdmController::setReplicationMode(ReplicationStatus mode) out return=true"); + } + // --- debug log (out method) --- + return true; + } + } + + /** + * + *

+ * setLogLevel method + *

+ * + * @param category + * @return result of l7vsadm set log level command. + */ + public boolean setLogLevel(HashMap category) { + // --- debug log (in method) --- + if (ioCommandLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("L7vsAdmController::setLogLevel(HashMap category) in "); + buf.append("category=" + category); + ioCommandLogger.debug("11541 " + buf.toString()); + } + // --- debug log (in method) --- + + synchronized (this) { + if (category == null) { + ioCommandLogger.error("41232 Invalid log category map: " + category); + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11542 L7vsAdmController::setLogLevel(HashMap category) out return=false"); + } + // --- debug log (out method) --- + return false; + } + + Iterator keys = category.keySet().iterator(); + while (keys.hasNext()) { + String command = l7vsadm; + LogData.LogCategory c = (LogData.LogCategory) keys.next(); + switch (c) { + case L7VSD_NETWORK: + switch (category.get(c)) { + case DEBUG: + case INFO: + case WARN: + case ERROR: + case FATAL: + command += " -L -c l7vsd_network"; + break; + default: + continue; + } + break; + case L7VSD_NETWORK_BANDWIDTH: + switch (category.get(c)) { + case DEBUG: + case INFO: + case WARN: + case ERROR: + case FATAL: + command += " -L -c l7vsd_network.bandwidth"; + break; + default: + continue; + } + break; + case L7VSD_NETWORK_NUM_CONNECTION: + switch (category.get(c)) { + case DEBUG: + case INFO: + case WARN: + case ERROR: + case FATAL: + command += " -L -c l7vsd_network.num_connection"; + break; + default: + continue; + } + break; + case L7VSD_NETWORK_QOS: + switch (category.get(c)) { + case DEBUG: + case INFO: + case WARN: + case ERROR: + case FATAL: + command += " -L -c l7vsd_network.qos"; + break; + default: + continue; + } + break; + case L7VSD_VIRTUAL_SERVICE: + switch (category.get(c)) { + case DEBUG: + case INFO: + case WARN: + case ERROR: + case FATAL: + command += " -L -c l7vsd_virtual_service"; + break; + default: + continue; + } + break; + case L7VSD_REAL_SERVER: + switch (category.get(c)) { + case DEBUG: + case INFO: + case WARN: + case ERROR: + case FATAL: + command += " -L -c l7vsd_real_server"; + break; + default: + continue; + } + break; + case L7VSD_SORRY_SERVER: + switch (category.get(c)) { + case DEBUG: + case INFO: + case WARN: + case ERROR: + case FATAL: + command += " -L -c l7vsd_sorry_server"; + break; + default: + continue; + } + break; + case L7VSD_REAL_SERVER_BALANCING: + switch (category.get(c)) { + case DEBUG: + case INFO: + case WARN: + case ERROR: + case FATAL: + command += " -L -c l7vsd_real_server.balancing"; + break; + default: + continue; + } + break; + case L7VSD_REPLICATION: + switch (category.get(c)) { + case DEBUG: + case INFO: + case WARN: + case ERROR: + case FATAL: + command += " -L -c l7vsd_replication"; + break; + default: + continue; + } + break; + case L7VSD_START_STOP: + switch (category.get(c)) { + case DEBUG: + case INFO: + case WARN: + case ERROR: + case FATAL: + command += " -L -c l7vsd_start_stop"; + break; + default: + continue; + } + break; + case L7VSD_SYSTEM: + switch (category.get(c)) { + case DEBUG: + case INFO: + case WARN: + case ERROR: + case FATAL: + command += " -L -c l7vsd_system"; + break; + default: + continue; + } + break; + case L7VSD_SYSTEM_MEMORY: + switch (category.get(c)) { + case DEBUG: + case INFO: + case WARN: + case ERROR: + case FATAL: + command += " -L -c l7vsd_system.memory"; + break; + default: + continue; + } + break; + case L7VSD_SYSTEM_SOCKET: + switch (category.get(c)) { + case DEBUG: + case INFO: + case WARN: + case ERROR: + case FATAL: + command += " -L -c l7vsd_system.socket"; + break; + default: + continue; + } + break; + case L7VSD_SYSTEM_SIGNAL: + switch (category.get(c)) { + case DEBUG: + case INFO: + case WARN: + case ERROR: + case FATAL: + command += " -L -c l7vsd_system.signal"; + break; + default: + continue; + } + break; + case L7VSD_ENVIRONMENT: + switch (category.get(c)) { + case DEBUG: + case INFO: + case WARN: + case ERROR: + case FATAL: + command += " -L -c l7vsd_environment"; + break; + default: + continue; + } + break; + case L7VSD_ENVIRONMENT_PARAMETER: + switch (category.get(c)) { + case DEBUG: + case INFO: + case WARN: + case ERROR: + case FATAL: + command += " -L -c l7vsd_environment.parameter"; + break; + default: + continue; + } + break; + case L7VSD_LOGGER: + switch (category.get(c)) { + case DEBUG: + case INFO: + case WARN: + case ERROR: + case FATAL: + command += " -L -c l7vsd_logger"; + break; + default: + continue; + } + break; + case L7VSD_PARAMETER: + switch (category.get(c)) { + case DEBUG: + case INFO: + case WARN: + case ERROR: + case FATAL: + command += " -L -c l7vsd_parameter"; + break; + default: + continue; + } + break; + case L7VSD_EVENT: + switch (category.get(c)) { + case DEBUG: + case INFO: + case WARN: + case ERROR: + case FATAL: + command += " -L -c l7vsd_event"; + break; + default: + continue; + } + break; + case L7VSD_SCHEDULE: + switch (category.get(c)) { + case DEBUG: + case INFO: + case WARN: + case ERROR: + case FATAL: + command += " -L -c l7vsd_schedule"; + break; + default: + continue; + } + break; + case L7VSD_PROGRAM: + switch (category.get(c)) { + case DEBUG: + case INFO: + case WARN: + case ERROR: + case FATAL: + command += " -L -c l7vsd_program"; + break; + default: + continue; + } + break; + case L7VSD_PROTOCOL: + switch (category.get(c)) { + case DEBUG: + case INFO: + case WARN: + case ERROR: + case FATAL: + command += " -L -c l7vsd_protocol"; + break; + default: + continue; + } + break; + case L7VSD_MODULE: + switch (category.get(c)) { + case DEBUG: + case INFO: + case WARN: + case ERROR: + case FATAL: + command += " -L -c l7vsd_module"; + break; + default: + continue; + } + break; + case L7VSD_ALL: + switch (category.get(c)) { + case DEBUG: + case INFO: + case WARN: + case ERROR: + case FATAL: + command += " -L -c all"; + break; + default: + continue; + } + break; + case SNMPAGENT_START_STOP: + switch (category.get(c)) { + case DEBUG: + case INFO: + case WARN: + case ERROR: + case FATAL: + command += " -S -c snmpagent_start_stop"; + break; + default: + continue; + } + break; + case SNMPAGENT_MANAGER_RECEIVE: + switch (category.get(c)) { + case DEBUG: + case INFO: + case WARN: + case ERROR: + case FATAL: + command += " -S -c snmpagent_manager_receive"; + break; + default: + continue; + } + break; + case SNMPAGENT_MANAGER_SEND: + switch (category.get(c)) { + case DEBUG: + case INFO: + case WARN: + case ERROR: + case FATAL: + command += " -S -c snmpagent_manager_send"; + break; + default: + continue; + } + break; + case SNMPAGENT_L7VSD_RECEIVE: + switch (category.get(c)) { + case DEBUG: + case INFO: + case WARN: + case ERROR: + case FATAL: + command += " -S -c snmpagent_l7vsd_receive"; + break; + default: + continue; + } + break; + case SNMPAGENT_L7VSD_SEND: + switch (category.get(c)) { + case DEBUG: + case INFO: + case WARN: + case ERROR: + case FATAL: + command += " -S -c snmpagent_l7vsd_send"; + break; + default: + continue; + } + break; + case SNMPAGENT_LOGGER: + switch (category.get(c)) { + case DEBUG: + case INFO: + case WARN: + case ERROR: + case FATAL: + command += " -S -c snmpagent_logger"; + break; + default: + continue; + } + break; + case SNMPAGENT_PARAMETER: + switch (category.get(c)) { + case DEBUG: + case INFO: + case WARN: + case ERROR: + case FATAL: + command += " -S -c snmpagent_parameter"; + break; + default: + continue; + } + break; + case SNMPAGENT_ALL: + switch (category.get(c)) { + case DEBUG: + case INFO: + case WARN: + case ERROR: + case FATAL: + command += " -S -c all"; + break; + default: + continue; + } + break; + default: + ioCommandLogger.info("21098 Unknown log category: " + c); + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11543 L7vsAdmController::setLogLevel(HashMap category) out return=false"); + } + // --- debug log (out method) --- + return false; + } + + switch (category.get(c)) { + case DEBUG: + command += " -l debug"; + break; + case INFO: + command += " -l info"; + break; + case WARN: + command += " -l warn"; + break; + case ERROR: + command += " -l error"; + break; + case FATAL: + command += " -l fatal"; + break; + default: + ioCommandLogger.info("21099 Unknown log level: " + category.get(c)); + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11544 L7vsAdmController::setLogLevel(HashMap category) out return=false"); + } + // --- debug log (out method) --- + return false; + } + + String result = runProcess(command); + if (result == null || result.length() != 0) { + ioCommandLogger.error("41233 Command error: command=" + command); + ioCommandLogger.error("41234 Command error: result=" + result); + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11545 L7vsAdmController::setLogLevel(HashMap category) out return=false"); + } + // --- debug log (out method) --- + return false; + } + } + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11546 L7vsAdmController::setLogLevel(HashMap category) out return=true"); + } + // --- debug log (out method) --- + return true; + } + } + + /** + * + *

+ * dumpReplicationData method + *

+ * + * @return result of l7vsadm replication dump command. + */ + public boolean dumpReplicationData() { + // --- debug log (in method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11547 L7vsAdmController::dumpReplicationData() in"); + } + // --- debug log (in method) --- + + synchronized (this) { + String command = l7vsadm + " -R -d"; + String result = runProcess(command); + if (result == null || result.length() != 0) { + ioCommandLogger.error("41235 Command error: command=" + command); + ioCommandLogger.error("41236 Command error: result=" + result); + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11548 L7vsAdmController::dumpReplicationData() out return=false"); + } + // --- debug log (out method) --- + return false; + } + + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11549 L7vsAdmController::dumpReplicationData() out return=true"); + } + // --- debug log (out method) --- + return true; + } + } + + /** + * + *

+ * reloadConf method + *

+ * + * @param c + * @return result of l7vsadm reload config command. + */ + public boolean reloadConf(L7vsConfCategory c) { + // --- debug log (in method) --- + if (ioCommandLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("L7vsAdmController::reloadConf(L7vsConfCategory c) in "); + buf.append("c=" + c); + ioCommandLogger.debug("11550 " + buf.toString()); + } + // --- debug log (in method) --- + + synchronized (this) { + if (c == null) { + ioCommandLogger.error("41237 Invalid argument: " + c); + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11551 L7vsAdmController::reloadConf(L7vsConfCategory c) out return=false"); + } + // --- debug log (out method) --- + return false; + } + + String command = l7vsadm + " -P -r "; + switch (c) { + case ALL: + command += "all"; + break; + case L7VSD: + command += "l7vsd"; + break; + case IOMUX: + command += "iomux"; + break; + case LSOCK: + command += "lsock"; + break; + case CONN: + command += "conn"; + break; + case DEST: + command += "dest"; + break; + case SERVICE: + command += "service"; + break; + case MODULE: + command += "module"; + break; + case REPLICATION: + command += "replication"; + break; + case LOGGER: + command += "logger"; + break; + case L7VSADM: + command += "l7vsadm"; + break; + case SNMPAGENT: + command += "snmpagent"; + break; + default: + ioCommandLogger.error("41238 Unknown log category: " + c); + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11552 L7vsAdmController::reloadConf(L7vsConfCategory c) out return=false"); + } + // --- debug log (out method) --- + return false; + } + + String result = runProcess(command); + if (result == null || result.length() != 0) { + ioCommandLogger.error("41239 Command error: command=" + command); + ioCommandLogger.error("41240 Command error: result=" + result); + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11553 L7vsAdmController::reloadConf(L7vsConfCategory c) out return=false"); + } + // --- debug log (out method) --- + return false; + } + + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11554 L7vsAdmController::reloadConf(L7vsConfCategory c) out return=true"); + } + // --- debug log (out method) --- + return true; + } + } + + /** + * + *

+ * runProcess method + *

+ * + * @param command + * @return result string of command execution + */ + protected String runProcess(String command) { + // --- debug log (in method) --- + if (ioCommandLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("L7vsAdmController::runProcess(String command) in "); + buf.append("command=\"" + command + "\""); + ioCommandLogger.debug("11555 " + buf.toString()); + } + // --- debug log (in method) --- + + synchronized (this) { + StringBuffer result = new StringBuffer(); + + try { + // TODO using sudo command temporally + Process ps = Runtime.getRuntime().exec("sudo " + command); + InputStream stderr = ps.getErrorStream(); + BufferedReader br = new BufferedReader(new InputStreamReader(stderr)); + String line = null; + while ((line = br.readLine()) != null) { + result.append(line + "\n"); + } + InputStream stdout = ps.getInputStream(); + br = new BufferedReader(new InputStreamReader(stdout)); + while ((line = br.readLine()) != null) { + result.append(line + "\n"); + } + + Pattern p = Pattern + .compile("^COMMON ERROR.*timeout"); + Matcher m = p.matcher(result); + if (m.find()) { + Parameter param = Parameter.getInstance(); + param.setValue(Parameter.L7VSADM_TIMEOUT_FLAG, "yes"); + } else { + Parameter param = Parameter.getInstance(); + param.setValue(Parameter.L7VSADM_TIMEOUT_FLAG, null); + } + } catch (Exception e) { + ioCommandLogger.error("41241 Exception occured: " + e.getMessage()); + result = null; + } + + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11556 L7vsAdmController::runProcess(String command) out return=" + result); + } + // --- debug log (out method) --- + return (result == null) ? null : result.toString(); + } + } +} diff --git a/src/src/org/ultramonkey/l7/controller/L7vsAdmData.java b/src/src/org/ultramonkey/l7/controller/L7vsAdmData.java new file mode 100644 index 0000000..d479a31 --- /dev/null +++ b/src/src/org/ultramonkey/l7/controller/L7vsAdmData.java @@ -0,0 +1,114 @@ +package org.ultramonkey.l7.controller; + +import java.util.*; +import java.io.Serializable; + +import org.apache.log4j.Logger; +import org.ultramonkey.l7.model.LogCategorySet; + +/** + * + *

class L7vsAdmData

+ *

Copyright(c) NTT COMWARE 2008

+ * @author tanuma + */ +public class L7vsAdmData extends VirtualSetting implements Serializable { + static final long serialVersionUID = 1L; + + /** + * Virtual service setting. + */ + public Vector virtualSettings; + + /** + * Replication status. (MASTER, MASTER_STOP, SLAVE, SLAVE_STOP, SINGLE, OUT) + */ + public ReplicationStatus replicationMode; + + /** + * SNMP Agent status. (CONNECTING, NON_CONNECTING) + */ + public SnmpAgentStatus snmpStatus; + + /** + * l7vsd log level + */ + public HashMap l7vsdLogLevel; + + /** + * SNMP Agent log level + */ + public HashMap snmpLogLevel; + + private Logger ioCommandLogger = Logger.getLogger(LogCategorySet.GUI_IO_COMMAND); + + /** + * + * Constructor + * + */ + public L7vsAdmData() { + // --- debug log (constructor) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11509 class L7vsAdmData created."); + } + // --- debug log (constructor) --- + + this.virtualSettings = new Vector(); + this.l7vsdLogLevel = new HashMap(); + this.snmpLogLevel = new HashMap(); + this.replicationMode = ReplicationStatus.OUT; + this.snmpStatus = SnmpAgentStatus.NON_CONNECTING; + } + + /** + * + *

equals method

+ * + * @param admData + * @return Compares this L7vsAdmData to the specified object. + * The result is true if and only if the argument is not null + * and is a L7vsAdmData object that represents the same field as this object. + */ + public boolean equals(L7vsAdmData admData) { + // --- debug log (in method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11510 L7vsAdmData::equals(L7vsAdmData admData) in admData=(" + admData + ")"); + } + // --- debug log (in method) --- + + if (admData != null && + this.virtualSettings.equals(admData.virtualSettings) && + this.replicationMode == admData.replicationMode && + this.snmpStatus == admData.snmpStatus && + this.l7vsdLogLevel.equals(admData.l7vsdLogLevel) && + this.snmpLogLevel.equals(admData.snmpLogLevel)) { + // --- debug log (in method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11511 L7vsAdmData::equals(L7vsAdmData admData) out return=true"); + } + // --- debug log (in method) --- + return true; + } + + // --- debug log (in method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11512 L7vsAdmData::equals(L7vsAdmData admData) out return=false"); + } + // --- debug log (in method) --- + return false; + } + + /** + * + * {@inheritDoc} + */ + public String toString() { + return + "virtualSettings=" + this.virtualSettings + ", " + + "replicationMode=" + this.replicationMode + ", " + + "snmpLogLevel=" + this.snmpLogLevel + ", " + + "l7vsdLogLevel=" + this.l7vsdLogLevel + ", " + + "snmpLogLevel=" + this.snmpLogLevel; + } +} diff --git a/src/src/org/ultramonkey/l7/controller/L7vsConfCategory.java b/src/src/org/ultramonkey/l7/controller/L7vsConfCategory.java new file mode 100644 index 0000000..1cba0dd --- /dev/null +++ b/src/src/org/ultramonkey/l7/controller/L7vsConfCategory.java @@ -0,0 +1,21 @@ +package org.ultramonkey.l7.controller; + +/** + *

class L7vsConfCategory

+ *

Copyright(c) NTT COMWARE 2008

+ * @author tanuma + */ +public enum L7vsConfCategory { + ALL, + L7VSD, + IOMUX, + LSOCK, + CONN, + DEST, + SERVICE, + MODULE, + REPLICATION, + LOGGER, + L7VSADM, + SNMPAGENT +} diff --git a/src/src/org/ultramonkey/l7/controller/L7vsConfController.java b/src/src/org/ultramonkey/l7/controller/L7vsConfController.java new file mode 100644 index 0000000..adaecf6 --- /dev/null +++ b/src/src/org/ultramonkey/l7/controller/L7vsConfController.java @@ -0,0 +1,1533 @@ +package org.ultramonkey.l7.controller; + +/** + * l7vs config file controller, + * Confing file reader and writer. + *

class L7vsConfController

+ *

Copyright(c) NTT COMWARE 2008

+ * @author nakai. + */ + +public class L7vsConfController { + + /** + * l7vs config file position and name. + */ + protected static String FILENAME = "/etc/l7vs/l7vs.cf"; + + protected static String LOGGER_MASTER_KEY = "logger"; + + protected static String L7VSADM_MASTER_KEY = "l7vsadm"; + + protected static String REPLICATION_MASTER_KEY = "replication"; + + protected static String SNMPAGENT_MASTER_KEY = "snmpagent"; + + /** + * l7vsd log File Name key + */ + protected static String LB_LOG_FILENAME_KEY = "l7vsd_log_filename"; + + /** + * l7vsd log rotate key + */ + protected static String LB_LOG_ROTATION_KEY = "l7vsd_rotation"; + + /** + * l7vsd log max backup index key + */ + protected static String LB_LOG_MAXBACKUPINDEX_KEY = "l7vsd_max_backup_index"; + + /** + * l7vsd log rotate timing key + */ + protected static String LB_LOG_ROTATE_TIMING_KEY = "l7vsd_rotation_timing"; + + /** + * l7vsd log rotate timing type key + */ + protected static String LB_LOG_ROTATE_TIMING_VALUE_KEY = "l7vsd_rotation_timing_value"; + + /** + * l7vsd log file size max value key + */ + protected static String LB_LOG_MAXFILESIZE_KEY = "l7vsd_max_filesize"; + + /** + * l7vsd log level for network category key + */ + protected static String LB_LOGCATEGORY_NETWORK_KEY = "l7vsd_network"; + + /** + * l7vsd log level for network.bandwidth category key + */ + protected static String LB_LOGCATEGORY_NETWORK_BANDWIDTH_KEY = "l7vsd_network.bandwidth"; + + /** + * k7vsd log level for network.connection category key + */ + protected static String LB_LOGCATEGORY_NETWORK_NUM_CONNECTION_KEY = "l7vsd_network.num_connection"; + + /** + * l7vsd log level for network qos category key + */ + protected static String LB_LOGCATEGORY_NETWORK_QOS_KEY = "l7vsd_network.qos"; + + /** + * l7vsd log level for virtual service category key + */ + protected static String LB_LOGCATEGORY_VIRTUALSERVICE_KEY = "l7vsd_virtual_service"; + + /** + * l7vsd log level for real server category key + */ + protected static String LB_LOGCATEOGRY_REALSERVER_KEY = "l7vsd_real_server"; + + /** + * l7vsd log level for sorry server category key + */ + protected static String LB_LOGCATEOGRY_SORRYSERVER_KEY = "l7vsd_sorry_server"; + + /** + * l7vsd log level for realserver balancing category key + */ + protected static String LB_LOGCATEOGRY_REALSERVER_BALANCING_KEY = "l7vsd_real_server.balancing"; + + /** + * l7vsd log level for replication category key + */ + protected static String LB_LOGCATEOGRY_REPLICATION_KEY = "l7vsd_replication"; + + /** + * l7vsd log level for start and stop messege category key + */ + protected static String LB_LOGCATEOGRY_STARTSTOP_KEY = "l7vsd_start_stop"; + + /** + * l7vsd log level for system category key + */ + protected static String LB_LOGCATEOGRY_SYSTEM_KEY = "l7vsd_system"; + + /** + * l7vsd log level for memory in system category key + */ + protected static String LB_LOGCATEOGRY_SYSTEMMEMORY_KEY = "l7vsd_system.memory"; + + /** + * l7vsd log level for socket category key + */ + protected static String LB_LOGCATEOGRY_SYSTEMSOCKET_KEY = "l7vsd_system.socket"; + + /** + * l7vsd log level for signal category key + */ + protected static String LB_LOGCATEOGRY_SYSTEMSIGNAL_KEY = "l7vsd_system.signal"; + + /** + * l7vsd log level for environment key + */ + protected static String LB_LOGCATEOGRY_ENVIROMENT_KEY = "l7vsd_environment"; + + /** + * l7vsd log level for environment parameter category key + */ + protected static String LB_LOGCATEOGRY_ENVIROMENTPARAMTER_KEY = "l7vsd_environment.parameter"; + + /** + * l7vsd log level for logger category key + */ + protected static String LB_LOGCATEGORY_LOGGER_KEY = "l7vsd_logger"; + + /** + * l7vsd log level for parameter category key + */ + protected static String LB_LOGCATEGORY_PARAMTER = "l7vsd_parameter"; + + /** + * l7vsd log level for event category key + */ + protected static String LB_LOGCATEGORY_EVENT_KEY = "l7vsd_event"; + + /** + * l7vsd log level for schedule category key + */ + protected static String LB_LOGCATEGORY_SCHEDULE_KEY = "l7vsd_schedule"; + + /** + * l7vsd log level for program category key + */ + protected static String LB_LOGCATEGORY_PROGRAM_KEY = "l7vsd_program"; + + /** + * l7vsd log level for protocol category key + */ + protected static String LB_LOGCATEGORY_PROTOCOL_KEY = "l7vsd_protocol"; + + /** + * l7vsd log level for module category key + */ + protected static String LB_LOGCATEGORY_MODULE_KEY = "l7vsd_module"; + + /** + * l7vsadm log file name key + */ + protected static String ADM_LOG_FILENAME_KEY = "l7vsadm_log_filename"; + + /** + * l7vsadm log rotation key + */ + protected static String ADM_LOG_ROTATION_KEY = "l7vsadm_rotation"; + + /** + * l7vsadm log maxbackup indexn key + */ + protected static String ADM_LOG_MAXBACKUPINDEX_KEY = "l7vsadm_max_backup_index"; + + /** + * l7vsadm log rotate timing key + */ + protected static String ADM_LOG_ROTATE_TIMING_KEY = "l7vsadm_rotation_timing"; + + /** + * l7vsadm log rotate timing + */ + protected static String ADM_LOG_ROTATE_TIMING_VALUE_KEY = "l7vsadm_rotation_timing_value"; + + /** + * l7vsadm log maxfilesize key + */ + protected static String ADM_LOG_MAXFILESIZE_KEY = "l7vsadd_max_filesize"; + + /** + * l7vsadm log level for pase key + */ + protected static String ADM_LOGCATEGORY_PARSE_KEY = "l7vsadm_parse"; + + /** + * l7vsadm log level for operate key + */ + protected static String ADM_LOGCATEGORY_OPERATE_KEY = "l7vsadm_operate"; + + /** + * l7vsadm log level for communicate key + */ + protected static String ADM_LOGCATEGORY_COMMUNICATE_KEY = "l7vsadm_communicate"; + + /** + * l7vsadm log level for config result key + */ + protected static String ADM_LOGCATEGORY_CONFIG_RESULT_KEY = "l7vsadm_config_result"; + + /** + * l7vsadm log level for common key + */ + protected static String ADM_LOGCATEOGRY_COMMON = "l7vsadm_common"; + + /** + * l7vsadm logl level for logger key + */ + protected static String ADM_LOGCATEGORY_LOGGER = "l7vsadm_logger"; + + /** + * l7vsadm log level for parameter key + */ + protected static String ADM_LOGCATEGORY_PARAMETER = "l7vsadm_parameter"; + + /** + * l7vsadm log level for protocol key + */ + protected static String ADM_LOGCATEOGRY_PROTOCOL = "l7vsadm_protocol"; + + /** + * l7vsadm log level for module key + */ + protected static String ADM_LOGCATEOGRY_MODULE = "l7vsadm_module"; + + /** + * snmp log filename kay + */ + protected static String SNMP_LOG_FILENAME_KEY = "snmpagent_log_filename"; + + /** + * snmp log rotatetion key + */ + protected static String SNMP_LOG_ROTATION_KEY = "snmpagent_rotation"; + + /** + * snmp max backup num key + */ + protected static String SNMP_LOG_MAXBACKUPINDEX_KEY = "snmpagent_max_backup_index"; + + /** + * snmp log rotate timing key + */ + protected static String SNMP_LOG_ROTATE_TIMING_KEY = "snmpagent_rotation_timing"; + + /** + * snmp log rotate timing value key + */ + protected static String SNMP_LOG_ROTATE_TIMING_VALUE_KEY = "snmpagent_rotation_timing_value"; + + /** + * snmp log max filesize key + */ + protected static String SNMP_MAX_FILESIZE_KEY = "snmpagent_max_filesize"; + + /** + * snmp log level for start stop message category key + */ + protected static String SNMP_LOGCATEOGRY_STARTSTOP_KEY = "snmpagent_start_stop"; + + /** + * snmp log level for manager recive category key + */ + protected static String SNMP_LOGCATEGORY_MANAGER_RECEIVE_KEY = "snmpagent_manager_receive"; + + /** + * snmp log level for manager send category key + */ + protected static String SNMP_LOGCATEGORY_MANAGER_SEND_KEY = "snmpagent_manager_send"; + + /** + * snmp log level for l7vsd recive category key + */ + protected static String SNMP_LOGCATEGORY_L7VSD_RECEIVE_KEY = "snmpagent_l7vsd_receive"; + + /** + * snmp log level for l7vsd send category key + */ + protected static String SNMP_LOGCATEGORY_L7VSD_SEND_KEY = "snmpagent_l7vsd_send"; + + /** + * snmp log level for logger category key + */ + protected static String SNMP_LOGCATEGORY_LOGGER = "snmpagent_logger"; + + /** + * snmp log level for parameter category key + */ + protected static String SNMP_LOGCATEGORY_PARAMETER = "snmpagent_parameter"; + + /** + * l7vsadm command interval key + */ + protected static String ADM_CMD_INTERVAL_KEY = "cmd_interval"; + + /** + * l7vsadm command retry count key + */ + protected static String ADM_CMD_COUNT_KEY = "cmd_count"; + + /** + * l7vsadm connection retry interval timing key + */ + protected static String ADM_CON_INTERVAL_KEY = "con_interval"; + + /** + * l7vsadm connection retry count key + */ + protected static String ADM_CON_COUNT_KEY = "con_count"; + + /** + * l7vsd replication target ipaddress key + */ + protected static String REPLICATION_IPADDR_KEY = "ip_addr"; + + /** + * l7vsd replication using portno key + */ + protected static String REPLICATION_SERVICENAME_KEY = "service_name"; + + /** + * l7vsd replication using NIC kay + */ + protected static String REPLICATION_NIC_KEY = "nic"; + + /** + * l7vsd replication interval timing key + */ + protected static String REPLICATION_INTERVAL_KEY = "interval"; + + /** + * l7vsd replication interval timing key + */ + protected static String REPLICATION_COMPULSORILY_INTERVAL_KEY = "compulsorily_interval"; + + /** + * l7vsd replication component base key + */ + protected static String REPLICATION_COMPONENT_ID_BASE_KEY = "cmponent_id_"; + + /** + * l7vsd replication component size base key + */ + protected static String REPLICATION_COMPONENT_SIZE_BASE_KEY = "cmponent_size_"; + + /** + * SNMPAgent using NIC key + */ + protected static String SNMPAGENT_NIC_KEY = "nic"; + + /** + * SNMPAgent using ipaddress key + */ + protected static String SNMPAGENT_IPADDR_KEY = "ip_addr"; + + /** + * SNMPAgent using service port key + */ + protected static String SNMPAGENT_PORT_KEY = "port"; + + /** + * SNMPAgent using interval key + */ + protected static String SNMPAGENT_INTERVAL_KEY = "interval"; + + /** + * SNMPAgent using status key(this value is temp) + */ + protected static String SNMPAGENT_STATUS_KEY = "status"; + + /** + * l7vsd replication using max component num + */ + protected static int MAX_REPLICATION_COMPONENT_COUNT = 99; + + /** + * pair class + *

class pair

+ *

Copyright(c) NTT COMWARE 2008

+ * @author kubota + */ + protected class Pair { + protected E elementFirst; + + protected N elementSecond; + + public Pair(E firstIn, N secondIn) { + elementFirst = firstIn; + elementSecond = secondIn; + } + + public void set(E firstIn, N secondIn) { + elementFirst = firstIn; + elementSecond = secondIn; + } + + public E first() { + return elementFirst; + } + + public N second() { + return elementSecond; + } + } + + protected Pair paseKey(String inLine) { + if (inLine == null) + return null; + int pos = inLine.indexOf("="); + if (pos == -1) + return new Pair(inLine, ""); + String first = inLine.substring(0, pos); + String second = inLine.substring(pos + 1, inLine.length()); + if (first.indexOf('#') != -1) + return new Pair("", ""); + if (second.indexOf('#') != -1) { + pos = second.indexOf('#'); + second = second.substring(0, pos); + } + first = first.trim(); + second = second.trim(); + if (second.matches("^\".*\"$")) + second = second.substring(1, second.length() - 1); + Pair pair = new Pair(first, second); + return pair; + } + + /** + * component use set. + *

class ComponentSet

+ *

Copyright(c) NTT COMWARE 2008

+ * @author kubota + */ + protected class ComponentSet { + public Pair idPair; + + public Pair sizePair; + } + + protected static LogData.LogLevel convStringToLogLevel(String instr) + throws org.ultramonkey.l7.model.FileNotReadException { + if (instr == null) { + org.ultramonkey.l7.model.FileNotReadException exception = new org.ultramonkey.l7.model.FileNotReadException(); + exception + .setErrMessage("function L7vsConfController::convStringToLogLevel(String) param is null"); + throw exception; + } + if (instr.equals("debug")) + return LogData.LogLevel.DEBUG; + else if (instr.equals("DEBUG")) + return LogData.LogLevel.DEBUG; + else if (instr.equals("error")) + return LogData.LogLevel.ERROR; + else if (instr.equals("ERROR")) + return LogData.LogLevel.ERROR; + else if (instr.equals("fatal")) + return LogData.LogLevel.FATAL; + else if (instr.equals("FATAL")) + return LogData.LogLevel.FATAL; + else if (instr.equals("info")) + return LogData.LogLevel.INFO; + else if (instr.equals("INFO")) + return LogData.LogLevel.INFO; + else if (instr.equals("warn")) + return LogData.LogLevel.WARN; + else if (instr.endsWith("WARN")) + return LogData.LogLevel.WARN; + org.ultramonkey.l7.model.FileNotReadException exception = new org.ultramonkey.l7.model.FileNotReadException(); + exception.setErrMessage(""); + throw exception; + } + + protected static String convLogLevelToLogString(LogData.LogLevel inlevel) { + if (inlevel == LogData.LogLevel.DEBUG) + return "\"debug\""; + if (inlevel == LogData.LogLevel.ERROR) + return "\"error\""; + if (inlevel == LogData.LogLevel.FATAL) + return "\"fatal\""; + if (inlevel == LogData.LogLevel.INFO) + return "\"info\""; + if (inlevel == LogData.LogLevel.WARN) + return "\"warn\""; + return ""; + } + + // list to data for LoggerParameter. + protected void readLoggerParameter(L7vsConfData data, + java.util.LinkedList inList) + throws org.ultramonkey.l7.model.FileNotReadException { + if (data == null || inList == null) + return; + for (java.util.Iterator itr = inList.iterator(); itr.hasNext();) { + String buffer = itr.next(); + Pair pair = paseKey(buffer); + if (pair.first().equals(LB_LOG_FILENAME_KEY) ) + data.logger.lbLog.fileName = pair.second(); + else if (pair.first().equals(LB_LOG_ROTATION_KEY)) + data.logger.lbLog.rotation = pair.second(); + else if (pair.first().equals(LB_LOG_MAXBACKUPINDEX_KEY) ) { + try { + data.logger.lbLog.maxBackupIndex = Integer.parseInt(pair.second()); + } catch (java.lang.NumberFormatException e) { + data.logger.lbLog.maxBackupIndex = 0; + } + } + else if (pair.first().equals(LB_LOG_ROTATE_TIMING_KEY)) + data.logger.lbLog.rotationTiming = pair.second(); + else if (pair.first().equals(LB_LOG_ROTATE_TIMING_VALUE_KEY)) + data.logger.lbLog.rotationTimingValue = pair.second(); + else if (pair.first().equals(LB_LOG_MAXFILESIZE_KEY)) + data.logger.lbLog.maxFileSize = pair.second(); + else if (pair.first().equals(LB_LOGCATEGORY_NETWORK_KEY) ) + data.logger.lbLog.logLevel.put(LogData.LogCategory.L7VSD_NETWORK, + convStringToLogLevel(pair.second())); + else if (pair.first().equals(LB_LOGCATEGORY_NETWORK_BANDWIDTH_KEY)) + data.logger.lbLog.logLevel.put( + LogData.LogCategory.L7VSD_NETWORK_BANDWIDTH, + convStringToLogLevel(pair.second())); + else if (pair.first().equals(LB_LOGCATEGORY_NETWORK_NUM_CONNECTION_KEY)) + data.logger.lbLog.logLevel.put( + LogData.LogCategory.L7VSD_NETWORK_NUM_CONNECTION, + convStringToLogLevel(pair.second())); + else if (pair.first().equals(LB_LOGCATEGORY_NETWORK_QOS_KEY)) + data.logger.lbLog.logLevel.put(LogData.LogCategory.L7VSD_NETWORK_QOS, + convStringToLogLevel(pair.second())); + else if (pair.first().equals(LB_LOGCATEGORY_VIRTUALSERVICE_KEY)) + data.logger.lbLog.logLevel.put(LogData.LogCategory.L7VSD_VIRTUAL_SERVICE, + convStringToLogLevel(pair.second())); + else if (pair.first().equals(LB_LOGCATEOGRY_REALSERVER_KEY)) + data.logger.lbLog.logLevel.put(LogData.LogCategory.L7VSD_REAL_SERVER, + convStringToLogLevel(pair.second())); + else if (pair.first().equals(LB_LOGCATEOGRY_SORRYSERVER_KEY)) + data.logger.lbLog.logLevel.put(LogData.LogCategory.L7VSD_SORRY_SERVER, + convStringToLogLevel(pair.second())); + else if (pair.first().equals(LB_LOGCATEOGRY_REALSERVER_BALANCING_KEY)) + data.logger.lbLog.logLevel.put( + LogData.LogCategory.L7VSD_REAL_SERVER_BALANCING, + convStringToLogLevel(pair.second())); + else if (pair.first().equals(LB_LOGCATEOGRY_REPLICATION_KEY)) + data.logger.lbLog.logLevel.put(LogData.LogCategory.L7VSD_REPLICATION, + convStringToLogLevel(pair.second())); + else if (pair.first().equals(LB_LOGCATEOGRY_STARTSTOP_KEY)) + data.logger.lbLog.logLevel.put(LogData.LogCategory.L7VSD_START_STOP, + convStringToLogLevel(pair.second())); + else if (pair.first().equals(LB_LOGCATEOGRY_SYSTEM_KEY)) + data.logger.lbLog.logLevel.put(LogData.LogCategory.L7VSD_SYSTEM, + convStringToLogLevel(pair.second())); + else if (pair.first().equals(LB_LOGCATEOGRY_SYSTEMMEMORY_KEY)) + data.logger.lbLog.logLevel.put(LogData.LogCategory.L7VSD_SYSTEM_MEMORY, + convStringToLogLevel(pair.second())); + else if (pair.first().equals(LB_LOGCATEOGRY_SYSTEMSOCKET_KEY)) + data.logger.lbLog.logLevel.put(LogData.LogCategory.L7VSD_SYSTEM_SOCKET, + convStringToLogLevel(pair.second())); + else if (pair.first().equals(LB_LOGCATEOGRY_SYSTEMSIGNAL_KEY)) + data.logger.lbLog.logLevel.put(LogData.LogCategory.L7VSD_SYSTEM_SIGNAL, + convStringToLogLevel(pair.second())); + else if (pair.first().equals(LB_LOGCATEOGRY_ENVIROMENT_KEY)) + data.logger.lbLog.logLevel.put(LogData.LogCategory.L7VSD_ENVIRONMENT, + convStringToLogLevel(pair.second())); + else if (pair.first().equals(LB_LOGCATEOGRY_ENVIROMENTPARAMTER_KEY)) + data.logger.lbLog.logLevel.put( + LogData.LogCategory.L7VSD_ENVIRONMENT_PARAMETER, + convStringToLogLevel(pair.second())); + else if (pair.first().equals(LB_LOGCATEGORY_LOGGER_KEY)) + data.logger.lbLog.logLevel.put(LogData.LogCategory.L7VSD_LOGGER, + convStringToLogLevel(pair.second())); + else if (pair.first().equals(LB_LOGCATEGORY_PARAMTER)) + data.logger.lbLog.logLevel.put(LogData.LogCategory.L7VSD_PARAMETER, + convStringToLogLevel(pair.second())); + else if (pair.first().equals(LB_LOGCATEGORY_EVENT_KEY)) + data.logger.lbLog.logLevel.put(LogData.LogCategory.L7VSD_EVENT, + convStringToLogLevel(pair.second())); + else if (pair.first().equals(LB_LOGCATEGORY_SCHEDULE_KEY)) + data.logger.lbLog.logLevel.put(LogData.LogCategory.L7VSD_SCHEDULE, + convStringToLogLevel(pair.second())); + else if (pair.first().equals(LB_LOGCATEGORY_PROGRAM_KEY)) + data.logger.lbLog.logLevel.put(LogData.LogCategory.L7VSD_PROGRAM, + convStringToLogLevel(pair.second())); + else if (pair.first().equals(LB_LOGCATEGORY_PROTOCOL_KEY)) + data.logger.lbLog.logLevel.put(LogData.LogCategory.L7VSD_PROTOCOL, + convStringToLogLevel(pair.second())); + else if (pair.first().equals(LB_LOGCATEGORY_MODULE_KEY)) + data.logger.lbLog.logLevel.put(LogData.LogCategory.L7VSD_MODULE, + convStringToLogLevel(pair.second())); + else if (pair.first().equals(ADM_LOG_FILENAME_KEY)) + data.logger.admLog.fileName = pair.second(); + else if (pair.first().equals(ADM_LOG_ROTATION_KEY)) + data.logger.admLog.rotation = pair.second(); + else if (pair.first().equals(ADM_LOG_MAXBACKUPINDEX_KEY)) { + try { + data.logger.admLog.maxBackupIndex = Integer.parseInt(pair.second()); + } catch (java.lang.NumberFormatException e) { + data.logger.admLog.maxBackupIndex = 0; + } + } else if (pair.first().equals(ADM_LOG_ROTATE_TIMING_KEY)) + data.logger.admLog.rotationTiming = pair.second(); + else if (pair.first().equals(ADM_LOG_ROTATE_TIMING_VALUE_KEY)) + data.logger.admLog.rotationTimingValue = pair.second(); + else if (pair.first().equals(ADM_LOG_MAXFILESIZE_KEY)) + data.logger.admLog.maxFileSize = pair.second(); + else if (pair.first().equals(ADM_LOGCATEGORY_PARSE_KEY)) + data.logger.admLog.logLevel.put(LogData.LogCategory.L7VSADM_PARSE, + convStringToLogLevel(pair.second())); + else if (pair.first().equals(ADM_LOGCATEGORY_OPERATE_KEY)) + data.logger.admLog.logLevel.put(LogData.LogCategory.L7VSADM_OPERATE, + convStringToLogLevel(pair.second())); + else if (pair.first().equals(ADM_LOGCATEGORY_COMMUNICATE_KEY)) + data.logger.admLog.logLevel.put(LogData.LogCategory.L7VSADM_COMMUNICATE, + convStringToLogLevel(pair.second())); + else if (pair.first().equals(ADM_LOGCATEGORY_CONFIG_RESULT_KEY)) + data.logger.admLog.logLevel.put( + LogData.LogCategory.L7VSADM_CONFIG_RESULT, + convStringToLogLevel(pair.second())); + else if (pair.first().equals(ADM_LOGCATEOGRY_COMMON)) + data.logger.admLog.logLevel.put(LogData.LogCategory.L7VSADM_COMMON, + convStringToLogLevel(pair.second())); + else if (pair.first().equals(ADM_LOGCATEGORY_LOGGER)) + data.logger.admLog.logLevel.put(LogData.LogCategory.L7VSADM_LOGGER, + convStringToLogLevel(pair.second())); + else if (pair.first().equals(ADM_LOGCATEGORY_PARAMETER)) + data.logger.admLog.logLevel.put(LogData.LogCategory.L7VSADM_PARAMETER, + convStringToLogLevel(pair.second())); + else if (pair.first().equals(ADM_LOGCATEOGRY_PROTOCOL)) + data.logger.admLog.logLevel.put(LogData.LogCategory.L7VSADM_PROTOCOL, + convStringToLogLevel(pair.second())); + else if (pair.first().equals(ADM_LOGCATEOGRY_MODULE)) + data.logger.admLog.logLevel.put(LogData.LogCategory.L7VSADM_MODULE, + convStringToLogLevel(pair.second())); + else if (pair.first().equals(SNMP_LOG_FILENAME_KEY)) + data.logger.snmpLog.fileName = pair.second(); + else if (pair.first().equals(SNMP_LOG_ROTATION_KEY)) + data.logger.snmpLog.rotation = pair.second(); + else if (pair.first().equals(SNMP_LOG_MAXBACKUPINDEX_KEY)) { + try { + data.logger.snmpLog.maxBackupIndex = Integer.parseInt(pair.second()); + } catch (java.lang.NumberFormatException e) { + data.logger.snmpLog.maxBackupIndex = 0; + } + } else if (pair.first().equals(SNMP_LOG_ROTATE_TIMING_KEY)) + data.logger.snmpLog.rotationTiming = pair.second(); + else if (pair.first().equals(SNMP_LOG_ROTATE_TIMING_VALUE_KEY)) + data.logger.snmpLog.rotationTimingValue = pair.second(); + else if (pair.first().equals(SNMP_MAX_FILESIZE_KEY)) + data.logger.snmpLog.maxFileSize = pair.second(); + else if (pair.first().equals(SNMP_LOGCATEOGRY_STARTSTOP_KEY)) + data.logger.snmpLog.logLevel.put( + LogData.LogCategory.SNMPAGENT_START_STOP, + convStringToLogLevel(pair.second())); + else if (pair.first().equals(SNMP_LOGCATEGORY_MANAGER_RECEIVE_KEY)) + data.logger.snmpLog.logLevel.put( + LogData.LogCategory.SNMPAGENT_MANAGER_RECEIVE, + convStringToLogLevel(pair.second())); + else if (pair.first().equals(SNMP_LOGCATEGORY_MANAGER_SEND_KEY)) + data.logger.snmpLog.logLevel.put( + LogData.LogCategory.SNMPAGENT_MANAGER_SEND, + convStringToLogLevel(pair.second())); + else if (pair.first().equals(SNMP_LOGCATEGORY_L7VSD_RECEIVE_KEY)) + data.logger.snmpLog.logLevel.put( + LogData.LogCategory.SNMPAGENT_L7VSD_RECEIVE, + convStringToLogLevel(pair.second())); + else if (pair.first().equals(SNMP_LOGCATEGORY_L7VSD_SEND_KEY)) + data.logger.snmpLog.logLevel.put( + LogData.LogCategory.SNMPAGENT_L7VSD_SEND, + convStringToLogLevel(pair.second())); + else if (pair.first().equals(SNMP_LOGCATEGORY_LOGGER)) + data.logger.snmpLog.logLevel.put(LogData.LogCategory.SNMPAGENT_LOGGER, + convStringToLogLevel(pair.second())); + else if (pair.first().equals(SNMP_LOGCATEGORY_PARAMETER)) + data.logger.snmpLog.logLevel.put(LogData.LogCategory.SNMPAGENT_PARAMETER, + convStringToLogLevel(pair.second())); + } + } + + protected void readAdmParameter(L7vsConfData data, java.util.LinkedList inList) + throws org.ultramonkey.l7.model.FileNotReadException { + if (data == null || inList == null) + return; + for (java.util.Iterator itr = inList.iterator(); itr.hasNext();) { + String buffer = itr.next(); + Pair pair = paseKey(buffer); + if (pair.first().indexOf(ADM_CMD_INTERVAL_KEY) != -1) { + try { + data.admCmdInterval = Integer.parseInt(pair.second()); + } catch (java.lang.NumberFormatException e) { + data.admCmdInterval = 0; + } + } else if (pair.first().indexOf(ADM_CMD_COUNT_KEY) != -1) { + try { + data.admCmdCount = Integer.parseInt(pair.second()); + } catch (java.lang.NumberFormatException e) { + data.admCmdCount = 0; + } + } else if (pair.first().indexOf(ADM_CON_INTERVAL_KEY) != -1) { + try { + data.admConInterval = Integer.parseInt(pair.second()); + } catch (java.lang.NumberFormatException e) { + data.admConInterval = 0; + } + } else if (pair.first().indexOf(ADM_CON_COUNT_KEY) != -1) { + try { + data.admConCount = Integer.parseInt(pair.second()); + } catch (java.lang.NumberFormatException e) { + data.admConCount = 0; + } + } + + } + } + + protected void readSNMPAgentParameter(L7vsConfData data, + java.util.LinkedList inList) + throws org.ultramonkey.l7.model.FileNotReadException { + if (data == null || inList == null) + return; + for (java.util.Iterator itr = inList.iterator(); itr.hasNext();) { + String buffer = itr.next(); + Pair pair = paseKey(buffer); + if (pair.first().indexOf(SNMPAGENT_NIC_KEY) != -1) + data.snmpNIC = pair.second(); + else if (pair.first().indexOf(SNMPAGENT_IPADDR_KEY) != -1) + data.snmpIpAddr = pair.second(); + else if (pair.first().indexOf(SNMPAGENT_PORT_KEY) != -1) + data.snmpPort = pair.second(); + else if (pair.first().indexOf(SNMPAGENT_INTERVAL_KEY) != -1) { + try { + data.snmpInterval = Integer.parseInt(pair.second()); + } catch (java.lang.NumberFormatException e) { + data.snmpInterval = 0; + } + } + } + } + + protected void readReplicationParameter(L7vsConfData data, + java.util.LinkedList inList) + throws org.ultramonkey.l7.model.FileNotReadException { + if (data == null || inList == null) + return; + java.util.HashMap> map = new java.util.HashMap>(); + for (java.util.Iterator itr = inList.iterator(); itr.hasNext();) { + String buffer = itr.next(); + Pair pair = paseKey(buffer); + if (pair.first().indexOf(REPLICATION_IPADDR_KEY) != -1) + data.replicationOtherNode.host = pair.second(); + else if (pair.first().indexOf(REPLICATION_SERVICENAME_KEY) != -1) + data.replicationOtherNode.port = pair.second(); + else if (pair.first().indexOf(REPLICATION_NIC_KEY) != -1) + data.replicationNic = pair.second(); + else if (pair.first().indexOf(REPLICATION_INTERVAL_KEY) != -1 && + pair.first().indexOf(REPLICATION_COMPULSORILY_INTERVAL_KEY) == -1) { + try { + data.replicationInterval = Integer.parseInt(pair.second()); + } catch (java.lang.NumberFormatException e) { + data.replicationInterval = 0; + } + } else if (pair.first().indexOf(REPLICATION_COMPONENT_ID_BASE_KEY) != -1) { + String number = pair.first().substring(REPLICATION_COMPONENT_ID_BASE_KEY.length(), REPLICATION_COMPONENT_ID_BASE_KEY.length() + 2); + Pair tmpPair = map.get(number); + if( tmpPair == null ) + map.put(number, new Pair(pair.second(), "" )); + else + tmpPair.set(pair.first(), tmpPair.second()); + } else if (pair.first().indexOf(REPLICATION_COMPONENT_SIZE_BASE_KEY) != -1) { + String number = pair.first().substring(REPLICATION_COMPONENT_SIZE_BASE_KEY.length(), REPLICATION_COMPONENT_SIZE_BASE_KEY.length() + 2); + Pair tmpPair = map.get(number); + if( tmpPair == null ) + map.put(number, new Pair("", pair.second())); + else + tmpPair.set(tmpPair.first(), pair.second()); + } + } + //data puts COMPONENTID and SIZE + data.component = new java.util.HashMap(); + for (java.util.Iterator>> itr = map.entrySet().iterator(); itr + .hasNext();) { + java.util.Map.Entry> entry = itr.next(); + Pair pair = entry.getValue(); + try { + data.component.put(pair.first(), Integer.parseInt(pair.second())); + } catch (java.lang.NumberFormatException e) { + data.component.put(pair.first(), 0); + } + } + } + + /** + * l7vs.cf load function. + * @return L7vsConfData create from l7vs.cf file. + * @throws org.ultramonkey.l7/model.FileNotReadException + */ + protected L7vsConfData loadFromFile() + throws org.ultramonkey.l7.model.FileNotReadException { + + // data read on stack + java.util.Stack stack = new java.util.Stack(); + try { + java.io.FileReader file = new java.io.FileReader(FILENAME); + java.io.BufferedReader reader = new java.io.BufferedReader(file); + String buffer; + while ((buffer = reader.readLine()) != null) { + if (buffer.length() != 0 && buffer.charAt(0) != '#') { + stack.push(buffer); + } + } + } catch (Exception e) { + org.ultramonkey.l7.model.FileNotReadException ex = new org.ultramonkey.l7.model.FileNotReadException(); + ex.setErrMessage("Cannot read file : " + FILENAME + "/ base exception = " + + e.getMessage()); + throw ex; + } + //category search. + + L7vsConfData data = new L7vsConfData(); + java.util.LinkedList tmpList = new java.util.LinkedList(); + while (!stack.empty()) { + String buffer = stack.pop(); + buffer = buffer.trim(); + int pos = buffer.indexOf('#'); + if( pos == 0 ) continue; + if( pos != -1 ) buffer = buffer.substring(0, pos); + else if (buffer.charAt(0) == '[' && buffer.charAt(buffer.length()-1) == ']') { + // select service; + if (buffer.indexOf(LOGGER_MASTER_KEY) != -1) { + readLoggerParameter(data, tmpList); + tmpList.clear(); + continue; + } else if (buffer.indexOf(L7VSADM_MASTER_KEY) != -1) { + readAdmParameter(data, tmpList); + tmpList.clear(); + continue; + } else if (buffer.indexOf(REPLICATION_MASTER_KEY) != -1) { + readReplicationParameter(data, tmpList); + tmpList.clear(); + continue; + } else if (buffer.indexOf(SNMPAGENT_MASTER_KEY) != -1) { + readSNMPAgentParameter(data, tmpList); + tmpList.clear(); + continue; + } + } + tmpList.addFirst(buffer); + } + + return data; + } + + private static String trimQuote(String s) { + if (s != null && s.matches("^\".*\"$")) { + s = s.substring(1, s.length() - 1); + } + return s; + } + + protected void searchInsertData(String key, String value, + java.util.LinkedList list, int start, int end) { + for (int i = start; i < end; ++i) { + String buffer = list.get(i).trim(); + if (buffer.length() == 0) + continue; + int commentpos = buffer.indexOf("#"); + if (commentpos != -1) + buffer = buffer.substring(commentpos, buffer.length()); + Pair pair = paseKey(buffer); + if (pair.first().length() == 0) + continue; + if (pair.first().equals(key)) { + if (pair.second().equals(trimQuote(value))) + return; + StringBuffer buf = new StringBuffer(); + if (commentpos == -1) + buf.append('#'); + buf.append(list.get(i)); + list.remove(i); + list.add(i, buf.toString()); + list.add(i + 1, key + "=" + value); + return; + } + } + list.add(end + 1, key + "=" + value); + } + + /** + * + *

saveToFile method

+ * + */ + protected void saveToFile(L7vsConfData data) + throws org.ultramonkey.l7.model.FileNotWriteException { + java.util.LinkedList datas = new java.util.LinkedList(); + try { + java.io.FileReader file = new java.io.FileReader(FILENAME); + java.io.BufferedReader reader = new java.io.BufferedReader(file); + String buffer; + while ((buffer = reader.readLine()) != null) { + datas.addLast(buffer); + } + } catch (Exception e) { + org.ultramonkey.l7.model.FileNotWriteException ex = new org.ultramonkey.l7.model.FileNotWriteException(); + ex.setErrMessage("Cannot open file : " + FILENAME); + throw ex; + } + + //[logger] + int startpos = 0; + int endpos = 0; //logger value. + for (int i = 0; i < datas.size(); ++i) { + String buffer = datas.get(i).trim(); + if (buffer.length() == 0) + continue; + if (buffer.charAt(0) == '#') + continue; + int cmntpos = buffer.indexOf("#"); + if (cmntpos != -1) + buffer = buffer.substring(0, cmntpos).trim(); + if (buffer.charAt(0) == '[' && buffer.charAt(buffer.length()-1) == ']') { + if (buffer.indexOf("logger") != -1 || buffer.indexOf("LOGGER") != -1) { + startpos = i + 1; + } else { + if (startpos != 0) { + endpos = i; + break; + } + } + } + } + if( endpos == 0 ) endpos = datas.size(); + if (data.logger.lbLog.fileName != null + && data.logger.lbLog.fileName.length() != 0) + searchInsertData(LB_LOG_FILENAME_KEY, + "\"" + data.logger.lbLog.fileName + "\"", datas, startpos, + endpos); + if (data.logger.lbLog.rotation != null + && data.logger.lbLog.rotation.length() != 0) + searchInsertData(LB_LOG_ROTATION_KEY, + "\"" + data.logger.lbLog.rotation + "\"", datas, startpos, + endpos += 1); + if (data.logger.lbLog.maxBackupIndex != 0) + searchInsertData(LB_LOG_MAXBACKUPINDEX_KEY, String + .valueOf(data.logger.lbLog.maxBackupIndex), datas, startpos, + endpos += 1); + if (data.logger.lbLog.rotationTiming != null + && data.logger.lbLog.rotationTiming.length() != 0) + searchInsertData(LB_LOG_ROTATE_TIMING_KEY, "\"" + + data.logger.lbLog.rotationTiming + "\"", datas, startpos, + endpos += 1); + if (data.logger.lbLog.rotationTimingValue != null + && data.logger.lbLog.rotationTimingValue.length() != 0) + searchInsertData(LB_LOG_ROTATE_TIMING_KEY, "\"" + + data.logger.lbLog.rotationTimingValue + "\"", datas, + startpos, endpos += 1); + if (data.logger.lbLog.maxFileSize != null + && data.logger.lbLog.maxFileSize.length() != 0) + searchInsertData(LB_LOG_MAXFILESIZE_KEY, "\"" + data.logger.lbLog.maxFileSize + + "\"", datas, startpos, endpos += 1); + LogData.LogLevel level = data.logger.lbLog.logLevel + .get(LogData.LogCategory.L7VSD_NETWORK); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(LB_LOGCATEGORY_NETWORK_KEY, buf, datas, startpos, endpos += 1); + } + } + level = data.logger.lbLog.logLevel + .get(LogData.LogCategory.L7VSD_NETWORK_BANDWIDTH); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(LB_LOGCATEGORY_NETWORK_BANDWIDTH_KEY, buf, datas, startpos, + endpos += 1); + } + } + level = data.logger.lbLog.logLevel + .get(LogData.LogCategory.L7VSD_NETWORK_NUM_CONNECTION); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(LB_LOGCATEGORY_NETWORK_NUM_CONNECTION_KEY, buf, datas, + startpos, endpos += 1); + } + } + level = data.logger.lbLog.logLevel.get(LogData.LogCategory.L7VSD_NETWORK_QOS); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(LB_LOGCATEGORY_NETWORK_QOS_KEY, buf, datas, startpos, + endpos += 1); + } + } + level = data.logger.lbLog.logLevel.get(LogData.LogCategory.L7VSD_VIRTUAL_SERVICE); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(LB_LOGCATEGORY_VIRTUALSERVICE_KEY, buf, datas, startpos, + endpos += 1); + } + } + level = data.logger.lbLog.logLevel.get(LogData.LogCategory.L7VSD_REAL_SERVER); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(LB_LOGCATEOGRY_REALSERVER_KEY, buf, datas, startpos, + endpos += 1); + } + } + level = data.logger.lbLog.logLevel.get(LogData.LogCategory.L7VSD_SORRY_SERVER); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(LB_LOGCATEOGRY_SORRYSERVER_KEY, buf, datas, startpos, + endpos += 1); + } + } + level = data.logger.lbLog.logLevel + .get(LogData.LogCategory.L7VSD_REAL_SERVER_BALANCING); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(LB_LOGCATEOGRY_REALSERVER_BALANCING_KEY, buf, datas, + startpos, endpos += 1); + } + } + level = data.logger.lbLog.logLevel.get(LogData.LogCategory.L7VSD_REPLICATION); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(LB_LOGCATEOGRY_REPLICATION_KEY, buf, datas, startpos, + endpos += 1); + } + } + level = data.logger.lbLog.logLevel.get(LogData.LogCategory.L7VSD_START_STOP); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(LB_LOGCATEOGRY_STARTSTOP_KEY, buf, datas, startpos, + endpos += 1); + } + } + level = data.logger.lbLog.logLevel.get(LogData.LogCategory.L7VSD_SYSTEM); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(LB_LOGCATEOGRY_SYSTEM_KEY, buf, datas, startpos, endpos += 1); + } + } + level = data.logger.lbLog.logLevel.get(LogData.LogCategory.L7VSD_SYSTEM_MEMORY); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(LB_LOGCATEOGRY_SYSTEMMEMORY_KEY, buf, datas, startpos, + endpos += 1); + } + } + level = data.logger.lbLog.logLevel.get(LogData.LogCategory.L7VSD_SYSTEM_SOCKET); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(LB_LOGCATEOGRY_SYSTEMSOCKET_KEY, buf, datas, startpos, + endpos += 1); + } + } + level = data.logger.lbLog.logLevel.get(LogData.LogCategory.L7VSD_SYSTEM_SIGNAL); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(LB_LOGCATEOGRY_SYSTEMSIGNAL_KEY, buf, datas, startpos, + endpos += 1); + } + } + level = data.logger.lbLog.logLevel.get(LogData.LogCategory.L7VSD_ENVIRONMENT); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(LB_LOGCATEOGRY_ENVIROMENT_KEY, buf, datas, startpos, + endpos += 1); + } + } + level = data.logger.lbLog.logLevel + .get(LogData.LogCategory.L7VSD_ENVIRONMENT_PARAMETER); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(LB_LOGCATEOGRY_ENVIROMENTPARAMTER_KEY, buf, datas, startpos, + endpos += 1); + } + } + level = data.logger.lbLog.logLevel.get(LogData.LogCategory.L7VSD_LOGGER); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(LB_LOGCATEGORY_LOGGER_KEY, buf, datas, startpos, endpos += 1); + } + } + level = data.logger.lbLog.logLevel.get(LogData.LogCategory.L7VSD_PARAMETER); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(LB_LOGCATEGORY_PARAMTER, buf, datas, startpos, endpos += 1); + } + } + level = data.logger.lbLog.logLevel.get(LogData.LogCategory.L7VSD_SCHEDULE); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(LB_LOGCATEGORY_SCHEDULE_KEY, buf, datas, startpos, + endpos += 1); + } + } + level = data.logger.lbLog.logLevel.get(LogData.LogCategory.L7VSD_EVENT); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(LB_LOGCATEGORY_EVENT_KEY, buf, datas, startpos, + endpos += 1); + } + } + level = data.logger.lbLog.logLevel.get(LogData.LogCategory.L7VSD_PROGRAM); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(LB_LOGCATEGORY_PROGRAM_KEY, buf, datas, startpos, endpos += 1); + } + } + level = data.logger.lbLog.logLevel.get(LogData.LogCategory.L7VSD_PROTOCOL); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(LB_LOGCATEGORY_PROTOCOL_KEY, buf, datas, startpos, + endpos += 1); + } + } + level = data.logger.lbLog.logLevel.get(LogData.LogCategory.L7VSD_MODULE); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(LB_LOGCATEGORY_MODULE_KEY, buf, datas, startpos, endpos += 1); + } + } + if (data.logger.admLog.fileName != null + && data.logger.admLog.fileName.length() != 0) + searchInsertData(ADM_LOG_FILENAME_KEY, "\"" + data.logger.admLog.fileName + + "\"", datas, startpos, endpos += 1); + if (data.logger.admLog.rotation != null + && data.logger.admLog.rotation.length() != 0) + searchInsertData(ADM_LOG_ROTATION_KEY, "\"" + data.logger.admLog.rotation + + "\"", datas, startpos, endpos += 1); + if (data.logger.admLog.maxBackupIndex != 0) + searchInsertData(ADM_LOG_MAXBACKUPINDEX_KEY, String + .valueOf(data.logger.admLog.maxBackupIndex), datas, startpos, + endpos += 1); + if (data.logger.admLog.rotationTiming != null + && data.logger.admLog.rotationTiming.length() != 0) + searchInsertData(ADM_LOG_ROTATE_TIMING_KEY, "\"" + + data.logger.admLog.rotationTiming + "\"", datas, startpos, + endpos += 1); + if (data.logger.admLog.rotationTimingValue != null + && data.logger.admLog.rotationTimingValue.length() != 0) + searchInsertData(ADM_LOG_ROTATE_TIMING_VALUE_KEY, "\"" + + data.logger.admLog.rotationTimingValue + "\"", datas, + startpos, endpos += 1); + if (data.logger.admLog.maxFileSize != null + && data.logger.admLog.maxFileSize.length() != 0) + searchInsertData(ADM_LOG_MAXFILESIZE_KEY, "\"" + + data.logger.admLog.maxFileSize + "\"", datas, startpos, + endpos += 1); + level = data.logger.admLog.logLevel.get(LogData.LogCategory.L7VSADM_PARSE); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(ADM_LOGCATEGORY_PARSE_KEY, buf, datas, startpos, endpos += 1); + } + } + level = data.logger.admLog.logLevel.get(LogData.LogCategory.L7VSADM_OPERATE); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(ADM_LOGCATEGORY_OPERATE_KEY, buf, datas, startpos, + endpos += 1); + } + } + level = data.logger.admLog.logLevel.get(LogData.LogCategory.L7VSADM_COMMUNICATE); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(ADM_LOGCATEGORY_COMMUNICATE_KEY, buf, datas, startpos, + endpos += 1); + } + } + level = data.logger.admLog.logLevel + .get(LogData.LogCategory.L7VSADM_CONFIG_RESULT); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(ADM_LOGCATEGORY_CONFIG_RESULT_KEY, buf, datas, startpos, + endpos += 1); + } + } + level = data.logger.admLog.logLevel.get(LogData.LogCategory.L7VSADM_COMMON); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(ADM_LOGCATEOGRY_COMMON, buf, datas, startpos, endpos += 1); + } + } + level = data.logger.admLog.logLevel.get(LogData.LogCategory.L7VSADM_LOGGER); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(ADM_LOGCATEGORY_LOGGER, buf, datas, startpos, endpos += 1); + } + } + level = data.logger.admLog.logLevel.get(LogData.LogCategory.L7VSADM_PARAMETER); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(ADM_LOGCATEGORY_PARAMETER, buf, datas, startpos, endpos += 1); + } + } + level = data.logger.admLog.logLevel.get(LogData.LogCategory.L7VSADM_PROTOCOL); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(ADM_LOGCATEOGRY_PROTOCOL, buf, datas, startpos, endpos += 1); + } + } + level = data.logger.admLog.logLevel.get(LogData.LogCategory.L7VSADM_MODULE); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(ADM_LOGCATEOGRY_MODULE, buf, datas, startpos, endpos += 1); + } + } + if (data.logger.snmpLog.fileName != null + && data.logger.snmpLog.fileName.length() != 0) + searchInsertData(SNMP_LOG_FILENAME_KEY, "\"" + data.logger.snmpLog.fileName + + "\"", datas, startpos, endpos += 1); + if (data.logger.snmpLog.rotation != null + && data.logger.snmpLog.rotation.length() != 0) + searchInsertData(SNMP_LOG_ROTATION_KEY, "\"" + data.logger.snmpLog.rotation + + "\"", datas, startpos, endpos += 1); + if (data.logger.snmpLog.maxBackupIndex != 0) + searchInsertData(SNMP_LOG_MAXBACKUPINDEX_KEY, String + .valueOf(data.logger.snmpLog.maxBackupIndex), datas, + startpos, endpos += 1); + if (data.logger.snmpLog.rotationTiming != null + && data.logger.snmpLog.rotationTiming.length() != 0) + searchInsertData(SNMP_LOG_ROTATE_TIMING_KEY, "\"" + + data.logger.snmpLog.rotationTiming + "\"", datas, + startpos, endpos += 1); + if (data.logger.snmpLog.rotationTimingValue != null + && data.logger.snmpLog.rotationTimingValue.length() != 0) + searchInsertData(SNMP_LOG_ROTATE_TIMING_VALUE_KEY, "\"" + + data.logger.snmpLog.rotationTimingValue + "\"", datas, + startpos, endpos += 1); + if (data.logger.snmpLog.maxFileSize != null + && data.logger.snmpLog.maxFileSize.length() != 0) + searchInsertData(SNMP_MAX_FILESIZE_KEY, "\"" + data.logger.snmpLog.maxFileSize + + "\"", datas, startpos, endpos += 1); + level = data.logger.snmpLog.logLevel + .get(LogData.LogCategory.SNMPAGENT_START_STOP); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(SNMP_LOGCATEOGRY_STARTSTOP_KEY, buf, datas, startpos, + endpos += 1); + } + } + level = data.logger.snmpLog.logLevel + .get(LogData.LogCategory.SNMPAGENT_MANAGER_RECEIVE); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(SNMP_LOGCATEGORY_MANAGER_RECEIVE_KEY, buf, datas, startpos, + endpos += 1); + } + } + level = data.logger.snmpLog.logLevel + .get(LogData.LogCategory.SNMPAGENT_MANAGER_SEND); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(SNMP_LOGCATEGORY_MANAGER_SEND_KEY, buf, datas, startpos, + endpos += 1); + } + } + level = data.logger.snmpLog.logLevel + .get(LogData.LogCategory.SNMPAGENT_L7VSD_RECEIVE); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(SNMP_LOGCATEGORY_L7VSD_RECEIVE_KEY, buf, datas, startpos, + endpos += 1); + } + } + level = data.logger.snmpLog.logLevel + .get(LogData.LogCategory.SNMPAGENT_L7VSD_SEND); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(SNMP_LOGCATEGORY_L7VSD_SEND_KEY, buf, datas, startpos, + endpos += 1); + } + } + level = data.logger.snmpLog.logLevel.get(LogData.LogCategory.SNMPAGENT_LOGGER); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(SNMP_LOGCATEGORY_LOGGER, buf, datas, startpos, endpos += 1); + } + } + level = data.logger.snmpLog.logLevel.get(LogData.LogCategory.SNMPAGENT_PARAMETER); + if (level != null) { + String buf = convLogLevelToLogString(level); + if (buf.length() != 0) { + searchInsertData(SNMP_LOGCATEGORY_PARAMETER, buf, datas, startpos, endpos += 1); + } + } + + // + //[l7vsadm] + startpos = 0; + endpos = 0; + for (int i = 0; i < datas.size(); ++i) { + String buffer = datas.get(i).trim(); + if (buffer.length() == 0) + continue; + if (buffer.charAt(0) == '#') + continue; + int cmntpos = buffer.indexOf("#"); + if (cmntpos != -1) + buffer = buffer.substring(0, cmntpos).trim(); + if (buffer.charAt(0) == '[' && buffer.charAt(buffer.length()-1) == ']') { + if (buffer.indexOf("l7vsadm") != -1 || buffer.indexOf("L7VSADM") != -1) { + startpos = i + 1; + } else { + if (startpos != 0) { + endpos = i; + break; + } + } + } + } + if( endpos == 0 ) endpos = datas.size(); + if (data.admConInterval != 0) + searchInsertData(ADM_CMD_INTERVAL_KEY, String.valueOf(data.admCmdInterval), + datas, startpos, endpos += 1); + if (data.admCmdCount != 0) + searchInsertData(ADM_CMD_COUNT_KEY, String.valueOf(data.admCmdCount), datas, + startpos, endpos += 1); + if (data.admConInterval != 0) + searchInsertData(ADM_CON_INTERVAL_KEY, String.valueOf(data.admConInterval), + datas, startpos, endpos += 1); + if (data.admConCount != 0) + searchInsertData(ADM_CON_COUNT_KEY, String.valueOf(data.admConCount), datas, + startpos, endpos += 1); + + // + //[replication] + startpos = 0; + endpos = 0; + for (int i = 0; i < datas.size(); ++i) { + String buffer = datas.get(i).trim(); + if (buffer.length() == 0) + continue; + if (buffer.charAt(0) == '#') + continue; + int cmntpos = buffer.indexOf("#"); + if (cmntpos != -1) + buffer = buffer.substring(0, cmntpos).trim(); + if (buffer.charAt(0) == '[' && buffer.charAt(buffer.length()-1) == ']') { + if (buffer.indexOf("replication") != -1 + || buffer.indexOf("REPLICATION") != -1) { + startpos = i + 1; + } else { + if (startpos != 0) { + endpos = i; + break; + } + } + } + } + if( endpos == 0 ) endpos = datas.size(); + if (data.replicationOtherNode.host != null + && data.replicationOtherNode.host.length() != 0) + searchInsertData(REPLICATION_IPADDR_KEY, "\"" + data.replicationOtherNode.host + + "\"", datas, startpos, endpos += 1); + if (data.replicationOtherNode.port != null + && data.replicationOtherNode.port.length() != 0) + searchInsertData(REPLICATION_SERVICENAME_KEY, "\"" + + data.replicationOtherNode.port + "\"", datas, startpos, + endpos += 1); + if (data.replicationNic != null && data.replicationNic.length() != 0) + searchInsertData(REPLICATION_NIC_KEY, "\"" + data.replicationNic + "\"", + datas, startpos, endpos += 1); + if (data.replicationInterval != 0) + searchInsertData(REPLICATION_INTERVAL_KEY, String + .valueOf(data.replicationInterval), datas, startpos, + endpos += 1); + if (data.component != null) { + int cmpno = 0; + for (java.util.Iterator> itr = data.component + .entrySet().iterator(); itr.hasNext();) { + java.util.Map.Entry entry = itr.next(); + StringBuffer compIdKey = new StringBuffer(); + StringBuffer compSizeKey = new StringBuffer(); + compIdKey.append(REPLICATION_COMPONENT_ID_BASE_KEY); + compSizeKey.append(REPLICATION_COMPONENT_SIZE_BASE_KEY); + if (cmpno < 10) { + compIdKey.append("0"); + compSizeKey.append("0"); + } + compIdKey.append(cmpno); + compSizeKey.append(cmpno); + searchInsertData(compIdKey.toString(), "\"" + entry.getKey() + "\"", + datas, startpos, endpos += 1); + searchInsertData(compSizeKey.toString(), String.valueOf(entry.getValue()), + datas, startpos, endpos += 1); + ++cmpno; + } + } + + // + //[snmpagent] + // + startpos = 0; + endpos = 0; + for (int i = 0; i < datas.size(); ++i) { + String buffer = datas.get(i).trim(); + if (buffer.length() == 0) + continue; + if (buffer.charAt(0) == '#') + continue; + int cmntpos = buffer.indexOf("#"); + if (cmntpos != -1) + buffer = buffer.substring(0, cmntpos).trim(); + if (buffer.charAt(0) == '[' || buffer.charAt(buffer.length()-1) == ']') { + if (buffer.indexOf("snmpagent") != -1 + || buffer.indexOf("SNMPAGENT") != -1) { + startpos = i + 1; + } else { + if (startpos != 0) { + endpos = i; + break; + } + } + } + } + if( endpos == 0 ) endpos = datas.size(); + if (data.snmpNIC != null && data.snmpNIC.length() != 0) + searchInsertData(SNMPAGENT_NIC_KEY, "\"" + data.snmpNIC + "\"", datas, + startpos, endpos += 1); + if (data.snmpIpAddr != null && data.snmpIpAddr.length() != 0) + searchInsertData(SNMPAGENT_IPADDR_KEY, "\"" + data.snmpIpAddr + "\"", datas, + startpos, endpos += 1); + if (data.snmpPort != null && data.snmpPort.length() != 0) + searchInsertData(SNMPAGENT_PORT_KEY, "\"" + data.snmpPort + "\"", datas, + startpos, endpos += 1); + if (data.snmpInterval != 0) + searchInsertData(SNMPAGENT_INTERVAL_KEY, String.valueOf(data.snmpInterval), + datas, startpos, endpos); + + try { + java.io.File file = new java.io.File(FILENAME); + if (file.exists()) { + java.util.Date date = new java.util.Date(); + java.io.File backfile = new java.io.File(FILENAME + ".back_" + + String.valueOf(date.getTime())); + file.renameTo(backfile); + file = new java.io.File(FILENAME); + } + java.io.FileWriter writer = new java.io.FileWriter(file); + for (java.util.Iterator itr = datas.iterator(); itr.hasNext();) { + StringBuffer buf = new StringBuffer(itr.next()); + buf.append('\n'); + writer.write(buf.toString()); + } + writer.flush(); + } catch (Exception e) { + org.ultramonkey.l7.model.FileNotWriteException ex = new org.ultramonkey.l7.model.FileNotWriteException(); + ex.setErrMessage("Cannot write file : " + FILENAME); + throw ex; + } + + } + + /** + * + *

getConfData method

+ * + * @return l7vs.cf data + */ + public synchronized L7vsConfData getConfData() + throws org.ultramonkey.l7.model.FileNotReadException { + return loadFromFile(); + } + + /** + * + *

setConfData method

+ * + */ + public synchronized void setConfData(L7vsConfData cf) + throws org.ultramonkey.l7.model.FileNotWriteException { + if (cf == null) { + org.ultramonkey.l7.model.FileNotWriteException exception = new org.ultramonkey.l7.model.FileNotWriteException(); + exception.setErrMessage("L7vConfData class is null!"); + exception.setErrNo(0); + throw exception; + } + saveToFile(cf); + } + +} diff --git a/src/src/org/ultramonkey/l7/controller/L7vsConfData.java b/src/src/org/ultramonkey/l7/controller/L7vsConfData.java new file mode 100644 index 0000000..3f278c6 --- /dev/null +++ b/src/src/org/ultramonkey/l7/controller/L7vsConfData.java @@ -0,0 +1,88 @@ +package org.ultramonkey.l7.controller; + +import java.io.Serializable; +import java.util.HashMap; + +/** + *

class L7vsConfData

+ *

Copyright(c) NTT COMWARE 2008

+ * @author nakai + */ +public class L7vsConfData implements Serializable { + static final long serialVersionUID = 1L; + + /** + * l7vs.cf value of "[replication] nic" + */ + public String replicationNic; + + /** + * l7vs.cf value of "[replication] interval" + */ + public int replicationInterval; + + /** + * l7vs.cf value of "[replication] ip_addr, service_name" + */ + public EndPoint replicationOtherNode; + + /** + * l7vs.cf value of "[replication] component_xx" settings + */ + public HashMap component; + + /** + * l7vs.cf value of "[snmpagent] interval" + */ + public int snmpInterval; + + /** + * l7vs.cf value of "[snmpagent] nic" + */ + public String snmpNIC; + + /** + * l7vs.cf value of "[snmpagent] ip_addr" + */ + public String snmpIpAddr; + + /** + * l7vs.cf value of "[snmpagent] port" + */ + public String snmpPort; + + /** + * l7vs.cf value of "[logger]" category settings. + */ + public LogData logger; + + /** + * l7vs.cf value of "[l7vsadm] cmd_interval" + */ + public int admCmdInterval; + + /** + * l7vs.cf value of "[l7vsadm] cmd_count" + */ + public int admCmdCount;; + + /** + * l7vs.cf value of "[l7vsadm] con_interval" + */ + public int admConInterval; + + /** + * l7vs.cf value of "[l7vsadm] con_count" + */ + public int admConCount; + + /** + * + * Constructor + * + */ + public L7vsConfData() { + this.replicationOtherNode = new EndPoint(); + this.logger = new LogData(); + } +} diff --git a/src/src/org/ultramonkey/l7/controller/L7vsLogController.java b/src/src/org/ultramonkey/l7/controller/L7vsLogController.java new file mode 100644 index 0000000..4960fd9 --- /dev/null +++ b/src/src/org/ultramonkey/l7/controller/L7vsLogController.java @@ -0,0 +1,130 @@ +package org.ultramonkey.l7.controller; + +import java.io.File; +import java.util.Date; + +import org.apache.log4j.Logger; +import org.ultramonkey.l7.model.FileNotReadException; +import org.ultramonkey.l7.model.LogCategorySet; + +/** + * + *

class L7vsLogController

+ *

Copyright(c) NTT COMWARE 2008

+ * @author tanuma + */ +public class L7vsLogController { + + private Logger ioFileLogger = Logger.getLogger(LogCategorySet.GUI_IO_FILE); + + private static String GUI_LOG = "/var/log/l7vs/l7gui.log"; + private static String SYNC_LOG = "/var/log/l7vs/l7sync.log"; + + /** + * + *

getData method

+ * + * @return log setting data. + */ + public LogData getData() { + // --- debug log (in method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11504 L7vsLogController::getData() in"); + } + // --- debug log (in method) --- + + synchronized (this) { + L7vsConfController confController = new L7vsConfController(); + DirectorController direController = new DirectorController(); + ClusterController haController = new ClusterController(); + L7vsAdmController admController = new L7vsAdmController(); + L7vsConfData cf = null; + DirectorData dd = null; + ClusterData cd = null; + L7vsAdmData ad = null; + LogData logData = new LogData(); + try { + cf = confController.getConfData(); + dd = direController.getDirectorData(); + cd = haController.getData(); + ad = admController.getData(); + + logData.admLog = setLogfile(cf.logger.admLog); + + logData.lbLog = setLogfile(cf.logger.lbLog); + logData.lbLog.logLevel = ad.l7vsdLogLevel; + + logData.snmpLog = setLogfile(cf.logger.snmpLog); + logData.snmpLog.logLevel = ad.snmpLogLevel; + + cf.logger.directorLog.fileName = dd.logfile.replaceAll("\"", ""); + logData.directorLog = setLogfile(cf.logger.directorLog); + + cf.logger.guiLog.fileName = GUI_LOG; + logData.guiLog = setLogfile(cf.logger.guiLog); + + cf.logger.haLog.fileName = cd.logFileName; + logData.haLog = setLogfile(cf.logger.haLog); + + cf.logger.syncLog.fileName = SYNC_LOG; + logData.syncLog = setLogfile(cf.logger.syncLog); + } catch (FileNotReadException e) { + ioFileLogger.error("41216 Exception occured: " + e.getMessage()); + logData = null; + } catch (Exception e) { + ioFileLogger.error("41217 Exception occured: " + e.getMessage()); + logData = null; + } + + // --- debug log (out method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11505 L7vsLogController::getData() out return=(" + + logData + ")"); + } + // --- debug log (out method) --- + return logData; + } + } + + protected LogSet setLogfile(LogSet logSet) { + // --- debug log (in method) --- + if (ioFileLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("L7vsLogController::setLogfile(LogSet logSet) in "); + buf.append("cfLogSet=(" + logSet + ")"); + ioFileLogger.debug("11506 " + buf.toString()); + } + // --- debug log (in method) --- + + int suffix = 0; + while (true) { + String path = logSet.fileName; + if (suffix > 0) + path += "." + suffix; + + try { + File log = new File(path); + if (log.isFile()) + logSet.logFiles.add(new LogFileData(log.getName(), + log.getAbsolutePath(), log.length(), + new Date(log.lastModified()))); + else + break; + } catch (NullPointerException e) { + ioFileLogger.error("41218 Exception occured: " + e.getMessage()); + } catch (Exception e) { + ioFileLogger.error("41219 Exception occured: " + e.getMessage()); + } + + suffix++; + } + // --- debug log (out method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11507 L7vsLogController::setLogfile() out return=(" + logSet + ")"); + } + // --- debug log (out method) --- + + return logSet; + } +} diff --git a/src/src/org/ultramonkey/l7/controller/LogData.java b/src/src/org/ultramonkey/l7/controller/LogData.java new file mode 100644 index 0000000..d5bac15 --- /dev/null +++ b/src/src/org/ultramonkey/l7/controller/LogData.java @@ -0,0 +1,153 @@ +package org.ultramonkey.l7.controller; + +import java.io.Serializable; + +import org.apache.log4j.Logger; +import org.ultramonkey.l7.model.LogCategorySet; + +/** + * + *

class LogData

+ *

Copyright(c) NTT COMWARE 2008

+ * @author tanuma + */ +public class LogData extends LogSet implements Serializable{ + static final long serialVersionUID = 1; + + /** + * + *

class LogCategory

+ *

Copyright(c) NTT COMWARE 2008

+ * @author tanuma + */ + public enum LogCategory { + L7VSD_NETWORK, + L7VSD_NETWORK_BANDWIDTH, + L7VSD_NETWORK_NUM_CONNECTION, + L7VSD_NETWORK_QOS, + L7VSD_VIRTUAL_SERVICE, + L7VSD_REAL_SERVER, + L7VSD_SORRY_SERVER, + L7VSD_REAL_SERVER_BALANCING, + L7VSD_REPLICATION, + L7VSD_START_STOP, + L7VSD_SYSTEM, + L7VSD_SYSTEM_MEMORY, + L7VSD_SYSTEM_SOCKET, + L7VSD_SYSTEM_SIGNAL, + L7VSD_ENVIRONMENT, + L7VSD_ENVIRONMENT_PARAMETER, + L7VSD_LOGGER, + L7VSD_PARAMETER, + L7VSD_EVENT, + L7VSD_SCHEDULE, + L7VSD_PROGRAM, + L7VSD_PROTOCOL, + L7VSD_MODULE, + L7VSD_ALL, + SNMPAGENT_START_STOP, + SNMPAGENT_MANAGER_RECEIVE, + SNMPAGENT_MANAGER_SEND, + SNMPAGENT_L7VSD_RECEIVE, + SNMPAGENT_L7VSD_SEND, + SNMPAGENT_LOGGER, + SNMPAGENT_PARAMETER, + SNMPAGENT_ALL, + L7VSADM_PARSE, + L7VSADM_OPERATE, + L7VSADM_COMMUNICATE, + L7VSADM_CONFIG_RESULT, + L7VSADM_COMMON, + L7VSADM_LOGGER, + L7VSADM_PARAMETER, + L7VSADM_PROTOCOL, + L7VSADM_MODULE + } + + /** + * + *

class LogLevel

+ *

Copyright(c) NTT COMWARE 2008

+ * @author tanuma + */ + public enum LogLevel { + NONE, + DEBUG, + INFO, + WARN, + ERROR, + FATAL + } + + /** + * l7vsadm logging information + */ + public LogSet admLog; + + /** + * l7directord logging information + */ + public LogSet directorLog; + + /** + * l7gui logging information + */ + public LogSet guiLog; + + /** + * cluster logging information + */ + public LogSet haLog; + + /** + * l7vsd logging information + */ + public LogSet lbLog; + + /** + * l7agent logging information + */ + public LogSet snmpLog; + + /** + * l7sync logging information + */ + public LogSet syncLog; + + /** + * + * Constructor + * + */ + public LogData() { + // --- debug log (constructor) --- + Logger ioFileLogger = Logger.getLogger(LogCategorySet.GUI_IO_FILE); + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11522 class LogData created."); + } + // --- debug log (constructor) --- + + admLog = new LogSet(); + directorLog = new LogSet(); + guiLog = new LogSet(); + haLog = new LogSet(); + lbLog = new LogSet(); + snmpLog = new LogSet(); + syncLog = new LogSet(); + } + + /** + * + * {@inheritDoc} + */ + public String toString() { + return + "admLog=(" + this.admLog + "), " + + "directorLog=(" + this.directorLog + "), " + + "guiLog=(" + this.guiLog + "), " + + "haLog=(" + this.haLog + "), " + + "lbLog=(" + this.lbLog + "), " + + "snmpLog=(" + this.snmpLog + "), " + + "syncLog=(" + this.syncLog + ")"; + } +} diff --git a/src/src/org/ultramonkey/l7/controller/LogFileData.java b/src/src/org/ultramonkey/l7/controller/LogFileData.java new file mode 100644 index 0000000..b79cca7 --- /dev/null +++ b/src/src/org/ultramonkey/l7/controller/LogFileData.java @@ -0,0 +1,91 @@ +package org.ultramonkey.l7.controller; + +import java.util.Date; +import java.io.Serializable; + +import org.apache.log4j.Logger; +import org.ultramonkey.l7.model.LogCategorySet; + +/** + * + *

class LogFileData

+ *

Copyright(c) NTT COMWARE 2008

+ * @author tanuma + */ +public class LogFileData implements Serializable { + static final long serialVersionUID = 1; + + /** + * file name (ex. l7vsd.log, l7vsadm.log.2) + */ + public String fileName; + + /** + * file path include file name (ex. /var/log/l7vsd.log.4) + */ + public String filePath; + + /** + * file size + */ + public long size; + + /** + * file mdate + */ + public Date time; + + /** + * + * Constructor + * + */ + public LogFileData() { + // --- debug log (constructor) --- + Logger ioFileLogger = Logger.getLogger(LogCategorySet.GUI_IO_FILE); + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11520 class LogFileData created."); + } + // --- debug log (constructor) --- + + this.fileName = null; + this.filePath = null; + this.size = 0; + this.time = new Date(); + } + + /** + * + * Constructor + * + * @param fileName + * @param filePath + * @param size + * @param time + */ + public LogFileData(String fileName, String filePath, long size, Date time) { + // --- debug log (constructor) --- + Logger ioFileLogger = Logger.getLogger(LogCategorySet.GUI_IO_FILE); + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11521 class LogFileData created."); + } + // --- debug log (constructor) --- + + this.fileName = fileName; + this.filePath = filePath; + this.size = size; + this.time = time; + } + + /** + * + * {@inheritDoc} + */ + public String toString() { + return + "fileName=\"" + this.fileName + "\", " + + "filePath=\"" + this.filePath + "\", " + + "size=" + this.size + ", " + + "time=(" + this.time + ")"; + } +} diff --git a/src/src/org/ultramonkey/l7/controller/LogSet.java b/src/src/org/ultramonkey/l7/controller/LogSet.java new file mode 100644 index 0000000..5764909 --- /dev/null +++ b/src/src/org/ultramonkey/l7/controller/LogSet.java @@ -0,0 +1,85 @@ +package org.ultramonkey.l7.controller; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Vector; + +import org.apache.log4j.Logger; +import org.ultramonkey.l7.model.LogCategorySet; + +public class LogSet extends LogFileData implements Serializable { + static final long serialVersionUID = 1; + + /** + * log file name + */ + public String fileName = ""; + + /** + * rotate setting + */ + public String rotation = ""; + + /** + * backup file number + */ + public int maxBackupIndex = 0; + + /** + * rotate size + */ + public String maxFileSize = ""; + + /** + * rotation timing pattern + */ + public String rotationTiming = ""; + + /** + * rotation timing value + */ + public String rotationTimingValue = ""; + + /** + * log files data + */ + public Vector logFiles; + + /** + * log level data + */ + public HashMap logLevel; + + /** + * + * Constructor + * + */ + public LogSet() { + // --- debug log (constructor) --- + Logger ioFileLogger = Logger.getLogger(LogCategorySet.GUI_IO_FILE); + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11523 class LogSet created."); + } + // --- debug log (constructor) --- + + this.logFiles = new Vector(); + this.logLevel = new HashMap(); + } + + /** + * + * {@inheritDoc} + */ + public String toString() { + return + "fileName=\"" + this.fileName + "\", " + + "maxBackupIndex=" + this.maxBackupIndex + ", " + + "maxFileSize=\"" + this.maxFileSize + "\", " + + "rotation=\"" + this.rotation + "\", " + + "rotationTiming=\"" + this.rotationTiming + "\", " + + "rotationTimingValue=\"" + this.rotationTimingValue + "\", " + + "logFiles=(" + this.logFiles + "), " + + "logLevel=(" + this.logLevel + ")"; + } +} diff --git a/src/src/org/ultramonkey/l7/controller/ReplicationData.java b/src/src/org/ultramonkey/l7/controller/ReplicationData.java new file mode 100644 index 0000000..b9051df --- /dev/null +++ b/src/src/org/ultramonkey/l7/controller/ReplicationData.java @@ -0,0 +1,75 @@ +package org.ultramonkey.l7.controller; + +import java.io.Serializable; +import java.util.HashMap; + +import org.apache.log4j.Logger; +import org.ultramonkey.l7.model.LogCategorySet; + +/** + * + *

class ReplicationData

+ *

Copyright(c) NTT COMWARE 2008

+ * @author tanuma + */ +public class ReplicationData implements Serializable { + static final long serialVersionUID = 1L; + + /** + * Replication Status (MASTER, MASTER_STOP, SLAVE, SLAVE_STOP, SINGLE, OUT) + */ + public ReplicationStatus replicationMode; + + /** + * Network Interface name of using for replication + */ + public String nic; + + /** + * IP address and port number of the other node + */ + public EndPoint otherNode; + + /** + * Replication interval seconds + */ + public int interval; + + /** + * Replication component setting + */ + public HashMap component; + + /** + * + * Constructor + * + */ + public ReplicationData() { + // --- debug log (constructor) --- + Logger repLogger = Logger.getLogger(LogCategorySet.GUI_REPLICATION); + if (repLogger.isDebugEnabled()) { + repLogger.debug("11508 class ReplicationData created."); + } + // --- debug log (constructor) --- + + this.replicationMode = ReplicationStatus.MASTER_STOP; + this.nic = ""; + this.otherNode = new EndPoint(); + this.interval = 0; + this.component = new HashMap(); + } + + /** + * + * {@inheritDoc} + */ + public String toString() { + return + "replicationMode=" + this.replicationMode + ", " + + "nic=\"" + this.nic + "\", " + + "otherNode=(" + this.otherNode + "), " + + "interval=" + this.interval + ", " + + "component=(" + this.component + ")"; + } +} diff --git a/src/src/org/ultramonkey/l7/controller/ReplicationStatus.java b/src/src/org/ultramonkey/l7/controller/ReplicationStatus.java new file mode 100644 index 0000000..4df8627 --- /dev/null +++ b/src/src/org/ultramonkey/l7/controller/ReplicationStatus.java @@ -0,0 +1,33 @@ +package org.ultramonkey.l7.controller; + +/** + *

class ReplicationStatus

+ *

Copyright(c) NTT COMWARE 2008

+ * @author tanuma + */ +public enum ReplicationStatus { + /** + * master mode + */ + MASTER, + /** + * master stop mode + */ + MASTER_STOP, + /** + * slave mode + */ + SLAVE, + /** + * slave stop mode + */ + SLAVE_STOP, + /** + * single mode + */ + SINGLE, + /** + * no replication setting + */ + OUT, +} diff --git a/src/src/org/ultramonkey/l7/controller/SnmpAgentData.java b/src/src/org/ultramonkey/l7/controller/SnmpAgentData.java new file mode 100644 index 0000000..beffbdd --- /dev/null +++ b/src/src/org/ultramonkey/l7/controller/SnmpAgentData.java @@ -0,0 +1,80 @@ +package org.ultramonkey.l7.controller; + +import java.io.Serializable; + +import org.apache.log4j.Logger; +import org.ultramonkey.l7.model.LogCategorySet; + +/** + * + *

class SnmpAgentData

+ *

Copyright(c) NTT COMWARE 2008

+ * @author tanuma + */ +public class SnmpAgentData implements Serializable { + static final long serialVersionUID = 1; + + /** + * SNMP Agent interval + */ + public int interval; + + /** + * SNMP Agent status + */ + public SnmpAgentStatus status; + + /** + * + * Constructor + * + */ + public SnmpAgentData() { + // --- debug log (constructor) --- + Logger snmpLogger = Logger.getLogger(LogCategorySet.GUI_IO); + if (snmpLogger.isDebugEnabled()) { + snmpLogger.debug("11500 class SnmpAgentData created."); + } + // --- debug log (constructor) --- + + this.interval = -1; + this.status = SnmpAgentStatus.NON_CONNECTING; + } + + /** + * + *

equals method

+ * + * @param snmpData + * @return + */ + public boolean equals(SnmpAgentData snmpData) { + // --- debug log (in method) --- + Logger snmpLogger = Logger.getLogger(LogCategorySet.GUI_IO); + if (snmpLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("SnmpAgentData::equals(SnmpAgentData snmpData) in "); + buf.append("snmpData=(" + snmpData + ")"); + snmpLogger.debug("11501 " + buf.toString()); + } + // --- debug log (in method) --- + + if (snmpData != null && this.interval == snmpData.interval && + this.status == snmpData.status) { + // --- debug log (out method) --- + if (snmpLogger.isDebugEnabled()) { + snmpLogger.debug("11502 SnmpAgentData::equals(snmpData) out return=true"); + } + // --- debug log (out method) --- + return true; + } + + // --- debug log (out method) --- + if (snmpLogger.isDebugEnabled()) { + snmpLogger.debug("11503 SnmpAgentData::equals(snmpData) out return=false"); + } + // --- debug log (out method) --- + return false; + } + +} diff --git a/src/src/org/ultramonkey/l7/controller/SnmpAgentStatus.java b/src/src/org/ultramonkey/l7/controller/SnmpAgentStatus.java new file mode 100644 index 0000000..13dbebe --- /dev/null +++ b/src/src/org/ultramonkey/l7/controller/SnmpAgentStatus.java @@ -0,0 +1,17 @@ +package org.ultramonkey.l7.controller; + +/** + *

class ControlerStatus

+ *

Copyright(c) NTT COMWARE 2008

+ * @author nakai + */ +public enum SnmpAgentStatus { + /** + * connecting + */ + CONNECTING, + /** + * non-connecting + */ + NON_CONNECTING, +} diff --git a/src/src/org/ultramonkey/l7/controller/VirtualSetting.java b/src/src/org/ultramonkey/l7/controller/VirtualSetting.java new file mode 100644 index 0000000..e64dfd2 --- /dev/null +++ b/src/src/org/ultramonkey/l7/controller/VirtualSetting.java @@ -0,0 +1,491 @@ +package org.ultramonkey.l7.controller; + +import java.io.Serializable; +import java.util.Vector; +import java.util.regex.*; + +/** + * + *

+ * class VirtualSetting + *

+ *

+ * Copyright(c) NTT COMWARE 2008 + *

+ * + * @author tanuma + */ +public class VirtualSetting implements Serializable { + static final long serialVersionUID = 1; + + /** + * virtual service + */ + public EndPoint virtual; + + /** + * real server + */ + public Vector real; + + /** + * protocol module name + */ + public String protomod = ""; + + /** + * protocol module option strings + */ + public String option = ""; + + /** + * protocol module reschedule flag + */ + public boolean reschedule; + + /** + * scheduler name + */ + public String sched = ""; + + /** + * max connection setting + */ + public int maxconn; + + /** + * QoS limit per virtual service + */ + public long qosservice; + + /** + * QoS limit per client + */ + public long qosclient; + + /** + * current throughput + */ + public long throughput; + + /** + * sorry server + */ + public EndPoint sorryserver; + + /** + * sorry flag + */ + public boolean sorryflag; + + /** + * timeout of real server monitor + */ + public int timeout; + + /** + * check count of real server monitor + */ + public int checkcount; + + /** + * connection type of real server monitor + */ + public String checktype = ""; + + /** + * service type of real server monitor + */ + public String service = ""; + + /** + * quiescent flag + */ + public String quiescent = ""; + + /** + * check port of real server monitor + */ + public int checkport; + + /** + * request string of real server monitor + */ + public String request = ""; + + /** + * response string of real server monitor + */ + public String receive = ""; + + /** + * HTTP method of real server monitor + */ + public String httpmethod = ""; + + /** + * HTTP virtual host of real server monitor + */ + public String virtualhost = ""; + + /** + * login user name for real server monitor + */ + public String login = ""; + + /** + * password for real server monitor + */ + public String passwd = ""; + + /** + * database name for real server monitor + */ + public String database = ""; + + /** + * protocol name + */ + public String protocol = ""; + + /** + * real server down callback script file path + */ + public String downcallback = ""; + + /** + * real server up callback script file path + */ + public String upcallback = ""; + + /** + * virtual position in l7directord.cf + */ + int cfPosition = 0; + + /** + * + * Constructor + * + */ + public VirtualSetting() { + this.virtual = new EndPoint(); + this.real = new Vector(); + this.sorryserver = new EndPoint(); + } + + /** + * + * Copy Constructor + * + * @param v + */ + public VirtualSetting(VirtualSetting v) { + this.virtual = new EndPoint(v.virtual); + this.real = (Vector) v.real.clone(); + this.protomod = new String(v.protomod); + this.option = new String(v.option); + this.sched = new String(v.sched); + this.maxconn = v.maxconn; + this.qosservice = v.qosservice; + this.qosclient = v.qosclient; + this.sorryserver = new EndPoint(v.sorryserver); + this.sorryflag = v.sorryflag; + this.timeout = v.timeout; + this.checkcount = v.checkcount; + this.checktype = new String(v.checktype); + this.service = new String(v.service); + this.quiescent = new String(v.quiescent); + this.checkport = v.checkport; + this.request = new String(v.request); + this.receive = new String(v.receive); + this.httpmethod = new String(v.httpmethod); + this.virtualhost = new String(v.virtualhost); + this.login = new String(v.login); + this.passwd = new String(v.passwd); + this.database = new String(v.database); + this.protocol = new String(v.protocol); + this.downcallback = new String(v.downcallback); + this.upcallback = new String(v.upcallback); + } + + /** + * + *

+ * complementOption method + *

+ * + * @param vs + * @return + */ + public void complementOption() { + String fullOption = ""; + if (this.protomod == null || this.option == null) + return; + if (this.protomod.equals("cinsert")) { + Pattern p = Pattern.compile("(?:--cookie-name|-C)\\s+([^\\s]+)"); + Matcher m = p.matcher(this.option); + if (m.find()) + fullOption = "--cookie-name " + m.group(1); + else { + fullOption = "--cookie-name CookieName"; + } + p = Pattern.compile("(?:--cookie-expire|-E)\\s+(\\d+)"); + m = p.matcher(this.option); + if (m.find()) + fullOption += " --cookie-expire " + m.group(1); + else { + fullOption += " --cookie-expire 86400"; + } + p = Pattern.compile("(?:--forwarded-for|-F)"); + m = p.matcher(this.option); + if (m.find()) + fullOption += " --forwarded-for"; + p = Pattern.compile("(?:--reschedule|-R)"); + m = p.matcher(this.option); + if (m.find()) + fullOption += " --reschedule"; + p = Pattern.compile("(?:--no-reschedule|-N)"); + m = p.matcher(this.option); + if (m.find()) + fullOption += " --no-reschedule"; + } + else if (this.protomod.equals("url")) { + Pattern p = Pattern.compile("(?:--pattern-match|-P)\\s+([^\\s]+)"); + Matcher m = p.matcher(this.option); + if (m.find()) + fullOption = "--pattern-match " + m.group(1); + p = Pattern.compile("(?:--forwarded-for|-F)"); + m = p.matcher(this.option); + if (m.find()) + fullOption += " --forwarded-for"; + } + else if (this.protomod.equals("sessionless")) { + Pattern p = Pattern.compile("(?:--forwarded-for|-F)"); + Matcher m = p.matcher(this.option); + if (m.find()) + fullOption += "--forwarded-for"; + } + else if (this.protomod.equals("sslid")) { + Pattern p = Pattern.compile("(?:--timeout|-T)\\s+(\\d+)"); + Matcher m = p.matcher(this.option); + if (m.find()) + fullOption += "--timeout " + m.group(1); + else { + fullOption += "--timeout 3600"; + } + p = Pattern.compile("(?:--maxlist|-M)\\s+(\\d+)"); + m = p.matcher(this.option); + if (m.find()) + fullOption += " --maxlist " + m.group(1); + else { + fullOption += " --maxlist 1024"; + } + p = Pattern.compile("(?:--reschedule|-R)"); + m = p.matcher(this.option); + if (m.find()) + fullOption += " --reschedule"; + p = Pattern.compile("(?:--no-reschedule|-N)"); + m = p.matcher(this.option); + if (m.find()) + fullOption += " --no-reschedule"; + } + this.option = fullOption; + } + + /** + * + *

+ * isSameService method + *

+ * + * @param vs + * @return + */ + public boolean isSameService(VirtualSetting vs) { + if (this.virtual.equals(vs.virtual) && this.isSameKey(vs)) { + return true; + } + return false; + } + + /** + * + *

+ * isSameKey method + *

+ * + * @param vs + * @return + */ + public boolean isSameKey(VirtualSetting vs) { + if (this.protomod.equals(vs.protomod)) { + String key1 = this.getKey(); + String key2 = vs.getKey(); + if (key1 != null && key2 != null && key1.equals(key2)) + return true; + } + return false; + } + + /** + * + *

+ * getKey method + *

+ * + * @return + */ + public String getKey() { + if (this.protomod == null || this.option == null) + return null; + this.complementOption(); + if (this.protomod.equals("cinsert")) { + Pattern p = Pattern.compile("--cookie-name\\s+([^\\s]+)"); + Matcher m = p.matcher(this.option); + if (m.find()) + return m.group(1).replaceAll("['\"]", ""); + else + return null; + } + if (this.protomod.equals("url")) { + Pattern p = Pattern.compile("--pattern-match\\s+([^\\s]+)"); + Matcher m = p.matcher(this.option); + if (m.find()) + return m.group(1).replaceAll("['\"]", ""); + else + return null; + } + if (this.protomod.equals("sslid")) + return ""; + if (this.protomod.equals("sessionless")) + return ""; + + return null; + } + + /** + * + *

+ * equals method + *

+ * + * @param vs + * @return + */ + public boolean equals(VirtualSetting vs) { + this.complementOption(); + vs.complementOption(); + if (this.virtual.equals(vs.virtual) + && this.protomod.equals(vs.protomod) + && this.option.equals(vs.option) + && this.sched.equals(vs.sched) + && this.maxconn == vs.maxconn + && this.qosservice == vs.qosservice + && this.qosclient == vs.qosclient + && this.sorryserver.equals(vs.sorryserver) + && this.sorryflag == vs.sorryflag + && this.timeout == vs.timeout + && this.checkcount == vs.checkcount + && this.checktype.equals(vs.checktype) + && this.service.equals(vs.service) + && this.quiescent == vs.quiescent + && this.checkport == vs.checkport + && this.request.equals(vs.request) + && this.receive.equals(vs.receive) + && this.httpmethod.equals(vs.httpmethod) + && this.virtualhost.equals(vs.virtualhost) + && this.login.equals(vs.login) && this.passwd.equals(vs.passwd) + && this.database.equals(vs.database) + && this.protocol.equals(vs.protocol) + && this.downcallback.equals(vs.downcallback) + && this.upcallback.equals(vs.upcallback)) { + if (this.real == null && vs.real == null) + return true; + if (this.real.size() == vs.real.size()) { + int sameCount = 0; + for (EndPoint e1: this.real) { + for (EndPoint e2: vs.real) { + if (e1.equals(e2)) { + sameCount++; + } + } + } + if (sameCount == this.real.size()) + return true; + } + } + return false; + } + + /** + * + *

+ * equalsAdm method + *

+ * + * @param vs + * @return + */ + public boolean equalsAdm(VirtualSetting vs) { + this.complementOption(); + vs.complementOption(); + if (this.virtual.equals(vs.virtual) + && this.protomod.equals(vs.protomod) + && this.option.equals(vs.option) && this.sched.equals(vs.sched) + && this.maxconn == vs.maxconn + && this.qosservice == vs.qosservice + && this.qosclient == vs.qosclient + && this.sorryserver.equals(vs.sorryserver)) { + if (this.real == null && vs.real == null) + return true; + if (this.real.size() == vs.real.size()) { + int sameCount = 0; + for (EndPoint e1: this.real) { + for (EndPoint e2: vs.real) { + if (e1.equals(e2)) { + sameCount++; + } + } + } + if (sameCount == this.real.size()) + return true; + } + } + return false; + } + + /** + * + * {@inheritDoc} + */ + public String toString() { + return + "virtual=(" + this.virtual + "), " + + "real=(" + this.real + "), " + + "protomod=\"" + this.protomod + "\", " + + "option=\"" + this.option + "\", " + + "sched=\"" + this.sched + "\", " + + "maxconn=" + this.maxconn + ", " + + "qosservice=" + this.qosservice + ", " + + "qosclient=" + this.qosclient + ", " + + "sorryserver=(" + this.sorryserver + "), " + + "sorryflag=" + this.sorryflag + ", " + + "timeout=" + this.timeout + ", " + + "checkcount=" + this.checkcount + ", " + + "checktype=\"" + this.checktype + "\", " + + "service=\"" + this.service + "\", " + + "quiescent=\"" + this.quiescent + "\", " + + "checkport=\"" + this.checkport + "\", " + + "request=\"" + this.request + "\", " + + "receive=\"" + this.receive + "\", " + + "httpmethod=\"" + this.httpmethod + "\", " + + "virtualhost=\"" + this.virtualhost + "\", " + + "login=\"" + this.login + "\", " + + "passwd=\"" + this.passwd + "\", " + + "database=\"" + this.database + "\", " + + "protocol=\"" + this.protocol + "\", " + + "downcallback=\"" + this.downcallback + "\", " + + "upcallback=\"" + this.upcallback + "\""; + } +} diff --git a/src/src/org/ultramonkey/l7/model/ErrNo.java b/src/src/org/ultramonkey/l7/model/ErrNo.java new file mode 100644 index 0000000..1122be3 --- /dev/null +++ b/src/src/org/ultramonkey/l7/model/ErrNo.java @@ -0,0 +1,7 @@ +package org.ultramonkey.l7.model; + +public interface ErrNo { + public static final int INFONUMBER = 20000; + public static final int ERRORNUMBER = 40000; + +} diff --git a/src/src/org/ultramonkey/l7/model/ExecuteMode.java b/src/src/org/ultramonkey/l7/model/ExecuteMode.java new file mode 100644 index 0000000..e41fed2 --- /dev/null +++ b/src/src/org/ultramonkey/l7/model/ExecuteMode.java @@ -0,0 +1,44 @@ +package org.ultramonkey.l7.model; + +/** + *

class ExecuteMode

+ *

Copyright(c) NTT COMWARE 2008

+ * @author nakai + */ +public enum ExecuteMode { + DIRECTOR_SAVE, // + DIRECTOR_SAVESYNC, // + + VS_ADD_APPLY, // + VS_ADD_SAVE, // + VS_ADD_SAVESYNC, // + + VS_REMOVE_APPLY, // + VS_REMOVE_SAVE, // + VS_REMOVE_SAVESYNC, // + + VS_MODIFY_APPLY, // + VS_MODIFY_SAVE, // + VS_MODIFY_SAVESYNC, // + + CLUSTER_SWITCHORVER, // + + REP_MASTER, // + REP_MASTER_STOP, // + REP_SLAVE, // + REP_SLAVE_STOP, // + REP_INFO_SAVE, // + REP_INFO_SAVESYNC, // + REP_START, // + + LOGLEVEL_CHANGE_APPLY, // + LOGLEVEL_CHANGE_SAVE, // + LOGLEVEL_CHANGE_SAVESYNC, // + + SNMP_INFO_SAVE, // + SNMP_INFO_SAVESYNC, // + + SYNC, // + + NONE +} diff --git a/src/src/org/ultramonkey/l7/model/FileNotReadException.java b/src/src/org/ultramonkey/l7/model/FileNotReadException.java new file mode 100644 index 0000000..bcbb16d --- /dev/null +++ b/src/src/org/ultramonkey/l7/model/FileNotReadException.java @@ -0,0 +1,148 @@ +package org.ultramonkey.l7.model; + +import org.apache.log4j.Logger; + +/** + * + *

class FileNotReadException

+ *

Copyright(c) NTT COMWARE 2008

+ * @author tanuma + */ +public class FileNotReadException extends Exception { + static final long serialVersionUID = 1L; + + private Logger ioFileLogger = Logger.getLogger(LogCategorySet.GUI_IO_FILE); + + protected String fileName = ""; + + protected int errno = 0; + + protected String errMessage = ""; + + /** + * + * Constructor + * + */ + public FileNotReadException() { + // --- debug log (constructor) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11045 class FileNotReadException created."); + } + // --- debug log (constructor) --- + } + + /** + * + *

getFileName method

+ * + * @return + */ + public String getFileName() { + // --- debug log (in/out method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11046 FileNotReadException::getFileName() in"); + ioFileLogger.debug("11047 FileNotReadException::getFileName() out return=\"" + this.fileName + "\""); + } + // --- debug log (in/out method) --- + return this.fileName; + } + + /** + * + *

setFileName method

+ * + * @param fileName + */ + public void setFileName(String fileName) { + // --- debug log (in method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11048 FileNotReadException::setFileName(String fileName) in fileName=\"" + fileName + "\""); + } + // --- debug log (in method) --- + + this.fileName = fileName; + + // --- debug log (out method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11049 FileNotReadException::getFileName(String fileName) out"); + } + // --- debug log (out method) --- + } + + /** + * + *

getErrno method

+ * + * @return + */ + public int getErrno() { + // --- debug log (in/out method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11050 FileNotReadException::getErrno() in"); + ioFileLogger.debug("11051 FileNotReadException::getErrno() out return=" + this.errno); + } + // --- debug log (in/out method) --- + return errno; + } + + /** + * + *

setErrNo method

+ * + * @param errno + */ + public void setErrNo(int errno) { + // --- debug log (in method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11052 FileNotReadException::setErrno(String errno) in errno=" + errno); + } + // --- debug log (in method) --- + + this.errno = errno; + + // --- debug log (out method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11053 FileNotReadException::getErrno(String errno) out"); + } + // --- debug log (out method) --- + } + + /** + * + *

getErrMessage method

+ * + * @return + */ + public String getErrMessage() { + // --- debug log (in/out method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11054 FileNotReadException::getErrMessage() in"); + ioFileLogger.debug("11055 FileNotReadException::getErrMessage() out return=\"" + this.errMessage + "\""); + } + // --- debug log (in/out method) --- + return errMessage; + } + + /** + * + *

setErrMessage method

+ * + * @param errMessage + */ + public void setErrMessage(String errMessage) { + // --- debug log (in method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11056 FileNotReadException::setErrMessage(String errMessage) in errMessage=\"" + errMessage + "\""); + } + // --- debug log (in method) --- + + this.errMessage = errMessage; + + // --- debug log (out method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11057 FileNotReadException::setErrMessage(String errMessage) out"); + } + // --- debug log (out method) --- + } +} diff --git a/src/src/org/ultramonkey/l7/model/FileNotWriteException.java b/src/src/org/ultramonkey/l7/model/FileNotWriteException.java new file mode 100644 index 0000000..447ea4f --- /dev/null +++ b/src/src/org/ultramonkey/l7/model/FileNotWriteException.java @@ -0,0 +1,148 @@ +package org.ultramonkey.l7.model; + +import org.apache.log4j.Logger; + +/** + * + *

class FileNotWriteException

+ *

Copyright(c) NTT COMWARE 2008

+ * @author tanuma + */ +public class FileNotWriteException extends Exception { + static final long serialVersionUID = 1L; + + private Logger ioFileLogger = Logger.getLogger(LogCategorySet.GUI_IO_FILE); + + protected String fileName = ""; + + protected int errno = 0; + + protected String errMessage = ""; + + /** + * + * Constructor + * + */ + public FileNotWriteException() { + // --- debug log (constructor) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11162 class FileNotWriteException created."); + } + // --- debug log (constructor) --- + } + + /** + * + *

getFileName method

+ * + * @return + */ + public String getFileName() { + // --- debug log (in/out method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11163 FileNotWriteException::getFileName() in"); + ioFileLogger.debug("11164 FileNotWriteException::getFileName() out return=\"" + this.fileName + "\""); + } + // --- debug log (in/out method) --- + return this.fileName; + } + + /** + * + *

setFileName method

+ * + * @param fileName + */ + public void setFileName(String fileName) { + // --- debug log (in method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11165 FileNotWriteException::setFileName(String fileName) in fileName=\"" + this.fileName + "\""); + } + // --- debug log (in method) --- + + this.fileName = fileName; + + // --- debug log (out method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11166 FileNotWriteException::setFileName(String fileName) out"); + } + // --- debug log (out method) --- + } + + /** + * + *

getErrno method

+ * + * @return + */ + public int getErrno() { + // --- debug log (in/out method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11167 FileNotWriteException::getErrno() in"); + ioFileLogger.debug("11168 FileNotWriteException::getErrno() out return=" + this.errno); + } + // --- debug log (in/out method) --- + return this.errno; + } + + /** + * + *

setErrNo method

+ * + * @param errno + */ + public void setErrNo(int errno) { + // --- debug log (in method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11169 FileNotWriteException::setErrno(String errno) in errno=" + this.errno); + } + // --- debug log (in method) --- + + this.errno = errno; + + // --- debug log (out method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11170 FileNotWriteException::setErrno(String errno) out"); + } + // --- debug log (out method) --- + } + + /** + * + *

getErrMessage method

+ * + * @return + */ + public String getErrMessage() { + // --- debug log (in/out method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11171 FileNotWriteException::getErrMessage() in"); + ioFileLogger.debug("11172 FileNotWriteException::getErrMessage() out return=\"" + this.errMessage + "\""); + } + // --- debug log (in/out method) --- + return errMessage; + } + + /** + * + *

setErrMessage method

+ * + * @param errMessage + */ + public void setErrMessage(String errMessage) { + // --- debug log (in method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11173 FileNotWriteException::setErrMessage(String errMessage) in errMessage=\"" + this.errMessage + "\""); + } + // --- debug log (in method) --- + + this.errMessage = errMessage; + + // --- debug log (out method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11174 FileNotWriteException::setErrMessage(String errMessage) out"); + } + // --- debug log (out method) --- + } +} diff --git a/src/src/org/ultramonkey/l7/model/L7SyncCommand.java b/src/src/org/ultramonkey/l7/model/L7SyncCommand.java new file mode 100644 index 0000000..3808167 --- /dev/null +++ b/src/src/org/ultramonkey/l7/model/L7SyncCommand.java @@ -0,0 +1,326 @@ +package org.ultramonkey.l7.model; + +import java.util.HashSet; + +import org.apache.log4j.Logger; + +/** + *

class L7SyncCommand

+ *

Copyright(c) NTT COMWARE 2008

+ * @author momose + */ +public class L7SyncCommand { + protected static Logger debugLogger = Logger.getLogger(LogCategorySet.SYNC_SYNC); + + protected HashSet categorySet; + + protected int serverMode = 0; + + private static final int ACT_MODE = 1; + + private static final int SBY_MODE = 2; + + private static final int MODE_ERROR = 3; + + private static final int UNDESIGNED_MODE = 0; + + private int MODE_LOCATION = 0; + + private int CATEGORY_START_LOCATION = MODE_LOCATION + 1; + + protected Logger logger = Logger.getLogger(LogCategorySet.SYNC_SYNC); + + /** + * Constructor + * + * @param args + */ + public L7SyncCommand(String[] args) { + // debug log(constructor) + if (debugLogger.isDebugEnabled()) { + debugLogger.debug("11232 class L7SyncCommand created."); + } + + categorySet = new HashSet(); + try { + this.checkArgument(args); + } catch (MessageView m) { + System.out.println(Message.SYNC_INVALID_ARGUMENT + " L7SyncCommand."); + logger.info("21032 " + Message.SYNC_INVALID_ARGUMENT + " L7SyncCommand."); + } + } + + /** + *

checks arguments

+ * + * @param args argument value from command line + * @throws MessageView + */ + protected void checkArgument(String[] args) throws MessageView { + // debug log(in method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("L7SyncCommand::checkArgument(String[] args) throws MessageView in args= "); + if (0 != args.length) { + for (int i = 0; i < args.length; i++) { + if (args.length - 1 == i) { + buf.append(args[i].toString()); + break; + } + buf.append(args[i].toString() + ","); + } + } else { + buf.append("null"); + } + debugLogger.debug("11233 " + buf.toString()); + } + + if (0 == args.length) { + setServerMode(UNDESIGNED_MODE); + } else if (args[MODE_LOCATION].equals("-a")) { + setServerMode(ACT_MODE); + if (args.length <= CATEGORY_START_LOCATION) { + throw new MessageView(40024, LogCategorySet.SYNC_SYNC, + Message.SYNC_INVALID_ARGUMENT + " checkArgument."); + } + for (int i = CATEGORY_START_LOCATION; i < args.length; i++) { + try { + setCaterogyIdSet(SyncCategoryIdSet.toCategoryId(args[i])); + } catch (MessageView m) { + throw new MessageView(40025, LogCategorySet.SYNC_SYNC, + Message.SYNC_INVALID_ARGUMENT + " checkArgument."); + } + } + } else if (args[MODE_LOCATION].equals("-s")) { + setServerMode(SBY_MODE); + } else { + setServerMode(MODE_ERROR); + throw new MessageView(40026, LogCategorySet.SYNC_SYNC, + Message.SYNC_INVALID_ARGUMENT + " checkArgument."); + } + + // debug log(out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("L7SyncCommand::checkArgument(String[] args) throws MessageView out "); + debugLogger.debug("11234 " + buf.toString()); + } + + } + + /** + *

starts L7GUI synchronous processing

+ * + * @param args + */ + public static void main(String[] args) { + // debug log(in method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("L7SyncCommand::main(String[] args) in args= "); + if (0 == args.length) { + buf.append("null"); + } else { + for (int i = 0; i < args.length; i++) { + if (args.length - 1 == i) { + buf.append(args[i].toString()); + break; + } + buf.append(args[i].toString() + ","); + } + } + debugLogger.debug("11235 " + buf.toString()); + } + + if (0 == args.length) { + L7SyncCommand.usage(); + + } else { + L7SyncCommand l7SyncCommand = new L7SyncCommand(args); + l7SyncCommand.start(); + } + // debug log(out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("L7SyncCommand::main(String[] args) out "); + debugLogger.debug("11236 " + buf.toString()); + } + + } + + /** + *

starts active or stand-by processing

+ * + */ + protected void start() { + // debug log(in method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("L7SyncCommand::start() in "); + debugLogger.debug("11237 " + buf.toString()); + } + + L7SyncManager l7SyncManager = new L7SyncManager(); + switch (serverMode) { + case ACT_MODE: + try { + l7SyncManager.syncAct(getCategoryIdSet()); + } catch (MessageView m) { + System.out.println(m.message); + } + break; + + case SBY_MODE: + try { + l7SyncManager.syncSby(); + } catch (MessageView m) { + System.out.println(m.message); + } + break; + default: + System.out.println(Message.SYNC_INVALID_SERVER_MODE); + break; + } + // debug log(out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("L7SyncCommand::start() out "); + debugLogger.debug("11238 " + buf.toString()); + } + + } + + /** + *

shows how to use L7SyncCommand

+ * + */ + protected static void usage() { + // debug log(in method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("L7SyncCommand::usage() in "); + debugLogger.debug("11239 " + buf.toString()); + } + + System.out.println( + "Usage: L7SyncCommand -a [CATEGORY]...\n" + + " L7SyncCommand -s\n" + + "\n" + + "Commands:\n" + + " -a active mode. send specified category data to standby server.\n" + + " -s standby mode. receive data from active server.\n" + + "\n" + + "Category:\n" + + " l7vsd_log log settings of l7vsd\n" + + " adm_log log settings of l7vsadm\n" + + " snmp_log log settings of l7agent\n" + + " log_all all log settings\n" + + " adm_info command settings of l7vsadm\n" + + " replication_info replication settings of l7vsd\n" + + " snmp_info interval settings of l7agent\n" + + " monitor global settings of l7directord.cf\n" + + " service virtual settings of l7directord.cf\n" + + " userdata user data of l7gui\n" + ); + + // debug log(out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("L7SyncCommand::usage() out "); + debugLogger.debug("11240 " + buf.toString()); + } + + } + + /** + *

gets CategoryIdSet

+ * + * @return categorySet + */ + protected HashSet getCategoryIdSet() { + // debug log(in method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("L7SyncCommand::getCategoryIdSet() in "); + debugLogger.debug("11241 " + buf.toString()); + } + + // debug log(out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("L7SyncCommand::getCategoryIdSet() out "); + buf.append("return= " + categorySet.toString()); + debugLogger.debug("11242 " + buf.toString()); + } + + return categorySet; + } + + /** + *

sets CaterogyIdSet

+ * + * @param categoryId + */ + protected void setCaterogyIdSet(Integer categoryId) { + // debug log(in method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("L7SyncCommand::setCaterogyIdSet() in "); + debugLogger.debug("11243 " + buf.toString()); + } + categorySet.add(categoryId); + + // debug log(out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("L7SyncCommand::setCaterogyIdSet() out "); + debugLogger.debug("11244 " + buf.toString()); + } + } + + /** + *

gets serverMode

+ * + * @return + */ + protected int getServerMode() { + // debug log(in method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("L7SyncCommand::getServerMode() in "); + debugLogger.debug("11245 " + buf.toString()); + } + // debug log(out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("L7SyncCommand::getServerMode() out "); + buf.append("return= " + serverMode); + debugLogger.debug("11246 " + buf.toString()); + } + return serverMode; + } + + /** + *

sets serverMode

+ * + * @param mode + */ + protected void setServerMode(int mode) { + // debug log(in method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("L7SyncCommand::setServerMode() in "); + buf.append("mode= " + mode); + debugLogger.debug("11247 " + buf.toString()); + } + // debug log(out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("L7SyncCommand::getServerMode() out "); + debugLogger.debug("11248 " + buf.toString()); + } + serverMode = mode; + } +} diff --git a/src/src/org/ultramonkey/l7/model/L7SyncManager.java b/src/src/org/ultramonkey/l7/model/L7SyncManager.java new file mode 100644 index 0000000..c0f0390 --- /dev/null +++ b/src/src/org/ultramonkey/l7/model/L7SyncManager.java @@ -0,0 +1,747 @@ +package org.ultramonkey.l7.model; + +import java.net.*; +import java.util.HashSet; +import java.util.Vector; + +import org.apache.log4j.Logger; +import org.ultramonkey.l7.controller.DirectorController; +import org.ultramonkey.l7.controller.DirectorData; +import org.ultramonkey.l7.controller.L7vsConfController; +import org.ultramonkey.l7.controller.L7vsConfData; +import org.ultramonkey.l7.controller.LogSet; + +/** + *

class L7SyncManager

+ *

Copyright(c) NTT COMWARE 2008

+ * @author momose + */ +public class L7SyncManager { + protected Logger debugLogger = Logger.getLogger(LogCategorySet.SYNC_SYNC); + + protected Logger debugDirectorLogger = Logger + .getLogger(LogCategorySet.SYNC_SYNC_DIRECTOR_DATA); + + protected Logger debugL7vsdConfLogger = Logger + .getLogger(LogCategorySet.SYNC_SYNC_L7VSDCONF_DATA); + + protected Logger debugUserLogger = Logger + .getLogger(LogCategorySet.SYNC_SYNC_USER_DATA); + + protected String categoryName; + + protected String actHost; + + protected String sbyHost; + + protected int sbyPort; + + protected Logger logger = Logger.getLogger(LogCategorySet.SYNC_SYNC); + + protected Logger directorLogger = Logger + .getLogger(LogCategorySet.SYNC_SYNC_DIRECTOR_DATA); + + protected Logger l7vsdConfLogger = Logger + .getLogger(LogCategorySet.SYNC_SYNC_L7VSDCONF_DATA); + + protected Logger userLogger = Logger.getLogger(LogCategorySet.SYNC_SYNC_USER_DATA); + + protected enum SyncDataType { + DIRECTORDATA, L7VSCONFDATA, USERDATA + }; + + /** + * Constructor gets data from Parameter class + * + */ + public L7SyncManager() { + // debug log(constructor) + if (debugLogger.isDebugEnabled()) { + debugLogger.debug("11058 class L7SyncManager created."); + } + + Parameter parameter = Parameter.getInstance(); + actHost = parameter.getValue("actHost"); + sbyHost = parameter.getValue("sbyHost"); + sbyPort = Integer.parseInt(parameter.getValue("sbyPort")); + } + + /** + *

Active server sends synchronous data from active server to stand-by server. It recieves results from stand-by server.

+ * + * @param categoryIdSet category IDs of synchronous data + * @throws MessageView + */ + public void syncAct(HashSet categoryIdSet) throws MessageView { + // debug log(in method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("L7SyncManager::syncAct(HashSet categoryIdSet) throws MessageView in "); + buf.append("categoryIdSet= " + categoryIdSet.toString()); + debugLogger.debug("11059 " + buf.toString()); + } + + Vector payloadVec = new Vector(); + Payload payload = null; + L7SyncSocket l7SyncSocket = new L7SyncSocket(); + + for (int categoryId : categoryIdSet) { + switch (getDataTypeFromId(categoryId)) { + case DIRECTORDATA: + try { + DirectorController directorController = new DirectorController(); + payload = new Payload(categoryId, directorController + .getDirectorData()); + } catch (Exception e) { + logger.error("41007 " + Message.SYNC_SET_ERROR + "DirectorData : " + e); + throw new MessageView(40012, LogCategorySet.SYNC_START_STOP, + Message.SYNC_SET_ERROR + " DirectorData :" + e); + } + break; + + case L7VSCONFDATA: + L7vsConfController l7vsConfController = new L7vsConfController(); + try { + payload = new Payload(categoryId, l7vsConfController.getConfData()); + } catch (FileNotReadException e) { + logger.error("41008 " + Message.SYNC_SET_ERROR + "L7vsConfData : " + e); + throw new MessageView(40013, LogCategorySet.SYNC_SYNC, + Message.SYNC_GET_ERROR + " L7vsConfData :" + e); + } + break; + + case USERDATA: + try { + UserManager userManager = new UserManager(); + payload = new Payload(categoryId, userManager.getUserList()); + } catch (FileNotReadException e) { + logger.error("41009 " + Message.SYNC_SET_ERROR + "L7vsdConfData : " + e); + throw new MessageView(40030, LogCategorySet.SYNC_SYNC, + Message.SYNC_GET_ERROR + " UserData :" + e); + } + break; + + default: + throw new MessageView(40027, LogCategorySet.SYNC_START_STOP, + Message.SYNC_INVALID_CATEGORY_ID); + } + payloadVec.add(payload); + } + try { + if (sbyHost == null) + throw new ConnectException(); + Socket socket = new Socket(sbyHost, sbyPort); + l7SyncSocket + .openConnection(socket.getInputStream(), socket + .getOutputStream()); + } catch (Exception e) { + logger.error("41010 " + Message.SYNC_OPEN_ERROR + " : " + e); + throw new MessageView(40014, LogCategorySet.SYNC_START_STOP, + Message.SYNC_OPEN_ERROR); + } + sendRecv(l7SyncSocket, payloadVec); + + try { + l7SyncSocket.closeConnection(); + } catch (MessageView m) { + logger.error("41011 " + m.message); + throw m; + } + + // debug log(out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("L7SyncManager::syncAct(HashSet categoryIdSet) throws MessageView out "); + debugLogger.debug("11060 " + buf.toString()); + } + + } + + /** + *

Stand-by server recieves synchronous data from active server. It compares synchronous data. It updates stand-by data if there are any differences between active server settings and stand-by server settings.

+ * + * @throws MessageView + */ + public void syncSby() throws MessageView { + // debug log(in method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("L7SyncManager::syncSby() throws MessageView in "); + debugLogger.debug("11061 " + buf.toString()); + } + + L7SyncSocket l7SyncSocket = new L7SyncSocket(); + Payload recvPayload = null; + Payload sendPayload; + String[] recvData; + Object sbyData; + + try { + l7SyncSocket.openConnection(System.in, System.out); + } catch (MessageView m) { + logger.error("41012 " + m.message); + throw m; + } + + while (null != (recvData = l7SyncSocket.recvData())) { + try { + recvPayload = new Payload(recvData); + switch (getDataTypeFromId(recvPayload.categoryId)) { + case DIRECTORDATA: + DirectorController directorController = new DirectorController(); + try { + DirectorData sbyDirectorData = compareDirectorData(recvPayload, + directorController.getDirectorData()); + if (null != sbyDirectorData) { + directorController.setDirectorData(sbyDirectorData); + } + } catch (Exception e) { + throw new MessageView(40015, LogCategorySet.SYNC_START_STOP, + Message.SYNC_GET_ERROR + " DirectorData"); + } + break; + + case L7VSCONFDATA: + L7vsConfController l7vsConfController = new L7vsConfController(); + try { + L7vsConfData sbyL7vsConfData = compareL7vsConfData(recvPayload, + l7vsConfController.getConfData()); + if (null != sbyL7vsConfData) { + l7vsConfController.setConfData(sbyL7vsConfData); + } + } catch (FileNotReadException e) { + throw new MessageView(40016, LogCategorySet.SYNC_SYNC, + Message.SYNC_GET_ERROR + " L7vsConfData :" + e); + } catch (FileNotWriteException e) { + throw new MessageView(40017, LogCategorySet.SYNC_SYNC, + Message.SYNC_SET_ERROR + " L7vsConfData :" + e); + } + break; + + case USERDATA: + try { + UserManager userManager = new UserManager(); + Vector sbyUserVec = compareUserData(recvPayload, + userManager.getUserList()); + if (null != sbyUserVec) { + userManager.setUserList(sbyUserVec); + } + } catch (Exception e) { + throw new MessageView(40018, LogCategorySet.SYNC_START_STOP, + Message.SYNC_GET_ERROR + " userdata"); + } + break; + default: + throw new MessageView(40028, LogCategorySet.SYNC_START_STOP, + Message.SYNC_INVALID_CATEGORY_ID); + } + sendPayload = new Payload(SyncCategoryIdSet.SYNC_OK, new DirectorData()); + logger.info("21001 " + SyncCategoryIdSet.toCategoryName(recvPayload.categoryId) + + Message.SYNC_SUCCESS); + + } catch (MessageView m) { + logger.error("41013 " + m.message); + sendPayload = new Payload(SyncCategoryIdSet.SYNC_NG, new DirectorData()); + } + + l7SyncSocket.sendData(sendPayload.getMessage()); + } + // debug log(out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("L7SyncManager::syncSby() throws MessageView out "); + debugLogger.debug("11062 " + buf.toString()); + } + + } + + /** + *

Sends synchronous data and recieves results from stand-by server.

+ * + * @param l7SyncSocket + * @param payloadVec synchronous data + * @throws MessageView + */ + protected void sendRecv(L7SyncSocket l7SyncSocket, Vector payloadVec) + throws MessageView { + // debug log(in method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("L7SyncManager::sendRecv(L7SyncSocket l7SyncSocket, Vector payloadVec) throws MessageView in "); + buf.append("l7SyncSocket= " + l7SyncSocket.toString() + ", "); + buf.append("payloadVec= " + payloadVec.toString()); + debugLogger.debug("11063 " + buf.toString()); + } + + Payload recvPayload; + for (Payload payload : payloadVec) { + l7SyncSocket.sendData(payload.getMessage()); + recvPayload = new Payload(l7SyncSocket.recvData()); + switch (recvPayload.categoryId) { + case SyncCategoryIdSet.SYNC_NG: + logger.error("41014 " + Message.SYNC_FAIL + " : " + + SyncCategoryIdSet.toCategoryName(payload.categoryId)); + throw new MessageView( + 40019, + LogCategorySet.SYNC_CONNECTION, + Message.SYNC_FAIL + + " : " + + SyncCategoryIdSet + .toCategoryName(payload.categoryId)); + case SyncCategoryIdSet.SYNC_OK: + logger.info("21002 " + SyncCategoryIdSet.toCategoryName(payload.categoryId) + + Message.SYNC_SUCCESS); + break; + default: + throw new MessageView(40029, LogCategorySet.SYNC_START_STOP, + Message.SYNC_INVALID_CATEGORY_ID); + } + } + // debug log(out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("L7SyncManager::sendRecv(L7SyncSocket l7SyncSocket, Vector payloadVec) throws MessageView out "); + debugLogger.debug("11064 " + buf.toString()); + } + + } + + /** + *

Compares DirectorData settings in active server with those in stand-by server. Updates DirectorData in stand-by server if there are any differences between them.

+ * + * @param categoryId category ID of synchronous data + * @param recvData recieve data from active server + * @throws MessageView + */ + protected DirectorData compareDirectorData(Payload recvData, + DirectorData sbyDirectorData) throws MessageView { + // debug log(in method) + if (debugDirectorLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("L7SyncManager::compareDirectorData(Payload recvData, DirectorData sbyDirectorData) throws MessageView in "); + buf.append("recvData= " + recvData.toString() + ", "); + buf.append("sbyDirectorData= " + sbyDirectorData.toString()); + debugDirectorLogger.debug("11065 " + buf.toString()); + } + + DirectorData actDirectorData = recvData.getDirectorData(); + boolean needSync = false; + + switch (recvData.categoryId) { + case SyncCategoryIdSet.MONITOR_ID: + if (actDirectorData.checkTimeOut != sbyDirectorData.checkTimeOut) { + directorLogger.info("21003 " + Message.SYNC_DIFFERENT_DATA + " : checkTimeOut "); + sbyDirectorData.checkTimeOut = actDirectorData.checkTimeOut; + needSync = true; + } + if (actDirectorData.negotiateTimeOut != sbyDirectorData.negotiateTimeOut) { + directorLogger.info("21004 " + Message.SYNC_DIFFERENT_DATA + " : negotiateTimeOut "); + sbyDirectorData.negotiateTimeOut = actDirectorData.negotiateTimeOut; + needSync = true; + } + if (actDirectorData.checkInterval != sbyDirectorData.checkInterval) { + directorLogger.info("21005 " + Message.SYNC_DIFFERENT_DATA + " : checkInterval "); + sbyDirectorData.checkInterval = actDirectorData.checkInterval; + needSync = true; + } + if (actDirectorData.checkCount != sbyDirectorData.checkCount) { + directorLogger.info("21006 " + Message.SYNC_DIFFERENT_DATA + " : checkCount "); + sbyDirectorData.checkCount = actDirectorData.checkCount; + needSync = true; + } + if (actDirectorData.autoreload != sbyDirectorData.autoreload) { + directorLogger.info("21007 " + Message.SYNC_DIFFERENT_DATA + " : autoreload "); + sbyDirectorData.autoreload = actDirectorData.autoreload; + needSync = true; + } + if (!actDirectorData.callback.equals(sbyDirectorData.callback)) { + directorLogger.info("21008 " + Message.SYNC_DIFFERENT_DATA + " : callback "); + sbyDirectorData.callback = actDirectorData.callback; + needSync = true; + } + if (!actDirectorData.fallback.equals(sbyDirectorData.fallback)) { + directorLogger.info("21009 " + Message.SYNC_DIFFERENT_DATA + " : fallback "); + sbyDirectorData.fallback = actDirectorData.fallback; + needSync = true; + } + if (!actDirectorData.logfile.equals(sbyDirectorData.logfile)) { + directorLogger.info("21010 " + Message.SYNC_DIFFERENT_DATA + " : logfile "); + sbyDirectorData.logfile = actDirectorData.logfile; + needSync = true; + } + if (!actDirectorData.execute.equals(sbyDirectorData.execute)) { + directorLogger.info("21011 " + Message.SYNC_DIFFERENT_DATA + " : execute "); + sbyDirectorData.execute = actDirectorData.execute; + needSync = true; + } + if (!actDirectorData.supervised.equals(sbyDirectorData.supervised)) { + directorLogger.info("21012 " + Message.SYNC_DIFFERENT_DATA + " : supervised "); + sbyDirectorData.supervised = actDirectorData.supervised; + needSync = true; + } + if (!actDirectorData.quiescent.equals(sbyDirectorData.quiescent)) { + directorLogger.info("21013 " + Message.SYNC_DIFFERENT_DATA + " : quiescent "); + sbyDirectorData.quiescent = actDirectorData.quiescent; + needSync = true; + } + break; + + case SyncCategoryIdSet.SERVICE_ID: + if (actDirectorData.virtualSettings.size() != sbyDirectorData.virtualSettings + .size()) { + sbyDirectorData.virtualSettings = actDirectorData.virtualSettings; + directorLogger.info("21014 " + Message.SYNC_DIFFERENT_DATA + " : virtualSettings "); + needSync = true; + } else { + if (!actDirectorData.virtualSettings + .equals(sbyDirectorData.virtualSettings)) { + sbyDirectorData.virtualSettings = actDirectorData.virtualSettings; + needSync = true; + } + } + break; + + default: + throw new MessageView(40020, LogCategorySet.SYNC_SYNC_DIRECTOR_DATA, + Message.SYNC_INVALID_CATEGORY_ID); + } + if (!needSync) { + directorLogger.info("21015 " + Message.SYNC_SAME_DATA + " : " + + SyncCategoryIdSet.toCategoryName(recvData.categoryId)); + + // debug log(out method) + if (debugDirectorLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("L7SyncManager::compareDirectorData(Payload recvData, DirectorData sbyDirectorData) throws MessageView out "); + buf.append("return= null"); + debugDirectorLogger.debug("11066 " + buf.toString()); + } + return null; + } + + // debug log(out method) + if (debugDirectorLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("L7SyncManager::compareDirectorData(Payload recvData, DirectorData sbyDirectorData) throws MessageView out "); + buf.append("return= " + sbyDirectorData.toString()); + debugDirectorLogger.debug("11067 " + buf.toString()); + } + + return sbyDirectorData; + } + + /** + *

Compares UserData settings in active server with those in stand-by server. Updates UserData in stand-by server if there are any differences between them.

+ * + * @param categoryId category id of synchronous data + * @param recvData recieve data from active server + * @throws MessageView + */ + protected Vector compareUserData(Payload recvData, + Vector sbyUserVec) throws MessageView { + // debug log(in method) + if (debugUserLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("L7SyncManager::compareUserData(Payload recvData, Vector sbyUserVec) throws MessageView in "); + buf.append("recvData= " + recvData.toString() + ", "); + buf.append("sbyUserVec= " + sbyUserVec.toString()); + debugUserLogger.debug("11068 " + buf.toString()); + } + + if (SyncCategoryIdSet.USERDATA_ID != recvData.categoryId) { + throw new MessageView(40021, LogCategorySet.SYNC_SYNC_USER_DATA, + Message.SYNC_INVALID_CATEGORY_ID); + } + + Vector actUserVec = recvData.getUserData(); + + if (actUserVec.size() != sbyUserVec.size() || !actUserVec.equals(sbyUserVec)) { + userLogger.info("21016 " + Message.SYNC_DIFFERENT_DATA + " : " + + SyncCategoryIdSet.toCategoryName(recvData.categoryId)); + + // debug log(out method) + if (debugUserLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("L7SyncManager::compareUserData(Payload recvData, Vector sbyUserVec) throws MessageView out "); + buf.append("return= " + actUserVec.toString()); + debugUserLogger.debug("11069 " + buf.toString()); + } + + return actUserVec; + } else { + userLogger.info("21017 " + Message.SYNC_SAME_DATA + " : " + + SyncCategoryIdSet.toCategoryName(recvData.categoryId)); + + // debug log(out method) + if (debugUserLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("L7SyncManager::compareUserData(Payload recvData, Vector sbyUserVec) throws MessageView out "); + buf.append("return= null"); + debugUserLogger.debug("11070 " + buf.toString()); + } + + return null; + } + } + + /** + *

Compares L7vsConfData settings in active server with those in stand-by server. Updates L7vsConfData in stand-by server if there are any differences between them.

+ * + * @param categoryId category ID of synchronous data + * @param recvData recieve data from active server + * @throws MessageView + */ + protected L7vsConfData compareL7vsConfData(Payload recvData, + L7vsConfData sbyL7vsdConfData) throws MessageView { + // debug log(in method) + if (debugL7vsdConfLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("L7SyncManager::compareL7vsConfData(Payload recvData, L7vsConfData sbyL7vsdConfData) throws MessageView in "); + buf.append("recvData= " + recvData.toString() + ", "); + buf.append("sbyL7vsdConfData= " + sbyL7vsdConfData.toString()); + debugL7vsdConfLogger.debug("11071 " + buf.toString()); + } + + L7vsConfData actL7vsdConfData = recvData.getL7vsdConfData(); + boolean needSync = false; + L7vsConfController confController = new L7vsConfController(); + + switch (recvData.categoryId) { + case SyncCategoryIdSet.L7VSD_LOG_ID: + needSync = compareLogSettings(actL7vsdConfData.logger.lbLog, + sbyL7vsdConfData.logger.lbLog); + if (needSync) { + sbyL7vsdConfData.logger.lbLog = actL7vsdConfData.logger.lbLog; + } + break; + + case SyncCategoryIdSet.ADM_LOG_ID: + needSync = compareLogSettings(actL7vsdConfData.logger.admLog, + sbyL7vsdConfData.logger.admLog); + if (needSync) { + sbyL7vsdConfData.logger.admLog = actL7vsdConfData.logger.admLog; + } + break; + + case SyncCategoryIdSet.SNMP_LOG_ID: + needSync = compareLogSettings(actL7vsdConfData.logger.snmpLog, + sbyL7vsdConfData.logger.snmpLog); + if (needSync) { + sbyL7vsdConfData.logger.snmpLog = actL7vsdConfData.logger.snmpLog; + } + break; + + case SyncCategoryIdSet.LOG_ALL_ID: + boolean lbLogFlg = compareLogSettings(actL7vsdConfData.logger.lbLog, + sbyL7vsdConfData.logger.lbLog); + boolean admLogFlg = compareLogSettings(actL7vsdConfData.logger.admLog, + sbyL7vsdConfData.logger.admLog); + boolean snmpLogFlg = compareLogSettings(actL7vsdConfData.logger.snmpLog, + sbyL7vsdConfData.logger.snmpLog); + + needSync = lbLogFlg || admLogFlg || snmpLogFlg; + + if (needSync) { + sbyL7vsdConfData.logger.lbLog = actL7vsdConfData.logger.lbLog; + sbyL7vsdConfData.logger.admLog = actL7vsdConfData.logger.admLog; + sbyL7vsdConfData.logger.snmpLog = actL7vsdConfData.logger.snmpLog; + } + break; + + case SyncCategoryIdSet.REPLICATION_INFO_ID: + if (actL7vsdConfData.replicationInterval != sbyL7vsdConfData.replicationInterval) { + logger.info("21018 " + Message.SYNC_DIFFERENT_DATA + ": Replication"); + sbyL7vsdConfData.replicationInterval = actL7vsdConfData.replicationInterval; + needSync = true; + } + break; + + case SyncCategoryIdSet.SNMP_INFO_ID: + if (actL7vsdConfData.snmpInterval != sbyL7vsdConfData.snmpInterval) { + logger.info("21019 " + Message.SYNC_DIFFERENT_DATA + ": snmpInterval"); + sbyL7vsdConfData.snmpInterval = actL7vsdConfData.snmpInterval; + needSync = true; + } + break; + + case SyncCategoryIdSet.ADM_INFO_ID: + if (actL7vsdConfData.admCmdInterval != sbyL7vsdConfData.admCmdInterval) { + logger.info("21020 " + Message.SYNC_DIFFERENT_DATA + ": admCmdInterval"); + sbyL7vsdConfData.admCmdInterval = actL7vsdConfData.admCmdInterval; + needSync = true; + } + if (actL7vsdConfData.admCmdCount != sbyL7vsdConfData.admCmdCount) { + logger.info("21021 " + Message.SYNC_DIFFERENT_DATA + ": admCmdCount"); + sbyL7vsdConfData.admCmdCount = actL7vsdConfData.admCmdCount; + needSync = true; + } + if (actL7vsdConfData.admConInterval != sbyL7vsdConfData.admConInterval) { + logger.info("21022 " + Message.SYNC_DIFFERENT_DATA + ": admConInterval"); + sbyL7vsdConfData.admConInterval = actL7vsdConfData.admConInterval; + needSync = true; + } + if (actL7vsdConfData.admConCount != sbyL7vsdConfData.admConCount) { + logger.info("21023 " + Message.SYNC_DIFFERENT_DATA + ": admConCount"); + sbyL7vsdConfData.admConCount = actL7vsdConfData.admConCount; + needSync = true; + } + break; + + default: + l7vsdConfLogger.error("41015 " + Message.SYNC_INVALID_CATEGORY_ID); + throw new MessageView(40022, LogCategorySet.SYNC_SYNC_L7VSDCONF_DATA, + Message.SYNC_INVALID_CATEGORY_ID); + } + + if (!needSync) { + l7vsdConfLogger.info("21024 " + Message.SYNC_SAME_DATA + " : " + + SyncCategoryIdSet.toCategoryName(recvData.categoryId)); + if (debugL7vsdConfLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("L7SyncManager::compareL7vsConfData(Payload recvData, L7vsConfData sbyL7vsdConfData) throws MessageView out "); + buf.append("return= null"); + debugL7vsdConfLogger.debug("11072 " + buf.toString()); + } + return null; + + } else { + // debug log(out method) + if (debugL7vsdConfLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("L7SyncManager::compareL7vsConfData(Payload recvData, L7vsConfData sbyL7vsdConfData) throws MessageView out "); + buf.append("return= " + sbyL7vsdConfData.toString()); + debugL7vsdConfLogger.debug("11073 " + buf.toString()); + } + + return sbyL7vsdConfData; + } + } + + /** + *

Gets synchronous data class from category ID.

+ * + * @param categoryId category ID of synchronous data + * @return data class name of synchronous data + * @throws MessageView + */ + protected SyncDataType getDataTypeFromId(int categoryId) throws MessageView { + // debug log(in method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("L7SyncManager::getDataTypeFromId(int categoryId) throws MessageView in "); + buf.append("categoryId=" + categoryId); + debugLogger.debug("11074 " + buf.toString()); + } + + switch (categoryId) { + case SyncCategoryIdSet.MONITOR_ID: + case SyncCategoryIdSet.SERVICE_ID: + // debug log(out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("L7SyncManager::getDataTypeFromId(int categoryId) throws MessageView out "); + buf.append("return= SyncDataType.DIRECTORDATA"); + debugLogger.debug("11075 " + buf.toString()); + } + return SyncDataType.DIRECTORDATA; + + case SyncCategoryIdSet.L7VSD_LOG_ID: + case SyncCategoryIdSet.ADM_LOG_ID: + case SyncCategoryIdSet.SNMP_LOG_ID: + case SyncCategoryIdSet.REPLICATION_INFO_ID: + case SyncCategoryIdSet.ADM_INFO_ID: + case SyncCategoryIdSet.SNMP_INFO_ID: + case SyncCategoryIdSet.LOG_ALL_ID: + // debug log(out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("L7SyncManager::getDataTypeFromId(int categoryId) throws MessageView out "); + buf.append("return= SyncDataType.L7VSCONFDATA"); + debugLogger.debug("11076 " + buf.toString()); + } + return SyncDataType.L7VSCONFDATA; + + case SyncCategoryIdSet.USERDATA_ID: + // debug log(out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("L7SyncManager::getDataTypeFromId(int categoryId) throws MessageView out "); + buf.append("return= SyncDataType.USERDATA"); + debugLogger.debug("11077 " + buf.toString()); + } + return SyncDataType.USERDATA; + + default: + throw new MessageView(40023, LogCategorySet.SYNC_SYNC, + Message.SYNC_INVALID_CATEGORY_ID); + } + } + + /** + *

Compares log settings in active server with those in stand-by server.

+ * + * @param actLogger LogSet of active server + * @param sbyLogger LogSet of stand-by server + * @return sync flag + */ + protected boolean compareLogSettings(LogSet actLogger, LogSet sbyLogger) { + // debug log(in method) + if (debugL7vsdConfLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("L7SyncManager::compareLogSettings(LogSet actLogger, LogSet sbyLogger) in "); + buf.append("actLogger= " + actLogger.toString() + ", "); + buf.append("sbyLogger= " + sbyLogger.toString()); + debugL7vsdConfLogger.debug("11078 " + buf.toString()); + } + + boolean syncFlag = false; + if (!actLogger.logLevel.equals(sbyLogger.logLevel)) { + l7vsdConfLogger.info("21025 " + Message.SYNC_DIFFERENT_DATA + " : LogLevel "); + syncFlag = true; + } + if (!actLogger.maxFileSize.equals(sbyLogger.maxFileSize)) { + l7vsdConfLogger.info("21026 " + Message.SYNC_DIFFERENT_DATA + " : maxFileSize "); + syncFlag = true; + } + if (actLogger.maxBackupIndex != sbyLogger.maxBackupIndex) { + l7vsdConfLogger.info("21027 " + Message.SYNC_DIFFERENT_DATA + " : maxBackupIndex "); + syncFlag = true; + } + if (!actLogger.fileName.equals(sbyLogger.fileName)) { + l7vsdConfLogger.info("21028 " + Message.SYNC_DIFFERENT_DATA + " : fileName "); + syncFlag = true; + } + if (!actLogger.rotation.equals(sbyLogger.rotation)) { + l7vsdConfLogger.info("21029 " + Message.SYNC_DIFFERENT_DATA + " : rotation "); + syncFlag = true; + } + // debug log(out method) + if (debugL7vsdConfLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("L7SyncManager::compareLogSettings(LogSet actLogger, LogSet sbyLogger) out "); + buf.append("return= " + syncFlag); + debugL7vsdConfLogger.debug("11079 " + buf.toString()); + } + + return syncFlag; + } +} diff --git a/src/src/org/ultramonkey/l7/model/L7SyncSocket.java b/src/src/org/ultramonkey/l7/model/L7SyncSocket.java new file mode 100644 index 0000000..67ffcb4 --- /dev/null +++ b/src/src/org/ultramonkey/l7/model/L7SyncSocket.java @@ -0,0 +1,247 @@ +package org.ultramonkey.l7.model; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; + +import org.apache.log4j.Logger; + +/** + *

+ * class L7SyncSocket + *

+ *

+ * Copyright(c) NTT COMWARE 2008 + *

+ * + * @author momose + */ +public class L7SyncSocket { + protected Logger debugLogger = Logger + .getLogger(LogCategorySet.SYNC_CONNECTION); + + protected OutputStream outputStream; + + protected InputStream inputStream; + + protected BufferedReader bufferedReader; + + protected BufferedWriter bufferedWriter; + + protected final String SEPARATOR = "\r\n"; + + protected final int ENTRY_NUMBER = 3; + + /** + * Constructor + * + */ + public L7SyncSocket() { + // debug log(constructor) + if (debugLogger.isDebugEnabled()) { + debugLogger.debug("11221 class L7SyncSocket created."); + } + } + + /** + *

+ * Sets inputStream and outputastream which got at L7SyncManager. + *

+ * + * @param inputStream + * @param outputStream + * @throws MessageView + */ + public void openConnection(InputStream inputStream, + OutputStream outputStream) throws MessageView { + + // debug log(in method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("L7SyncSocket::openConnection(InputStream inputStream, OutputStream outputStream) throws MessageView in "); + + if (null != inputStream) { + buf.append("inputStream= " + inputStream.toString() + ", "); + } else { + buf.append("inputStream= " + "null, "); + } + if (null != outputStream) { + buf.append("outputStream= " + outputStream.toString()); + } else { + buf.append("outputStream= " + "null"); + } + debugLogger.debug("11222 " + buf.toString()); + } + + if ((null == inputStream) || (null == outputStream)) { + throw new MessageView(40009, LogCategorySet.SYNC_CONNECTION, + Message.SYNC_INVALID_ARGUMENT + " OpenConnection : null"); + } + + this.inputStream = inputStream; + this.outputStream = outputStream; + + bufferedWriter = new BufferedWriter(new OutputStreamWriter( + this.outputStream)); + + bufferedReader = new BufferedReader(new InputStreamReader( + this.inputStream)); + + // debug log(out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("L7SyncSocket::openConnection(InputStream inputStream, OutputStream outputStream) throws MessageView out "); + debugLogger.debug("11223 " + buf.toString()); + } + + } + + /** + *

+ * Sends data. + *

+ * + * @param payloadStr + * recieve data + * @throws MessageView + */ + public void sendData(String[] payloadStr) throws MessageView { + // debug log(in method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("L7SyncSocket::sendData(String[] payloadStr) throws MessageView in "); + buf.append("payloadStr= "); + if (null == payloadStr) { + buf.append("null"); + } else { + for (int i = 0; i < payloadStr.length; i++) { + if (payloadStr.length - 1 == i) { + buf.append(payloadStr[i].toString()); + break; + } + buf.append(payloadStr[i].toString() + ","); + } + } + debugLogger.debug("11224 " + buf.toString()); + } + + if (null == payloadStr) { + throw new MessageView(40010, LogCategorySet.SYNC_CONNECTION, + Message.SYNC_INVALID_ARGUMENT + " SendData : " + payloadStr); + } + try { + for (int i = 0; i < payloadStr.length; i++) { + bufferedWriter.write(payloadStr[i]); + bufferedWriter.write(SEPARATOR); + } + bufferedWriter.write(SEPARATOR); + bufferedWriter.flush(); + } catch (Exception e) { + throw new MessageView(50001, LogCategorySet.SYNC_CONNECTION, + Message.SYNC_SEND_ERROR + " : " + e); + } + // debug log(out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("L7SyncSocket::sendData(String[] payloadStr) throws MessageView out "); + debugLogger.debug("11225 " + buf.toString()); + } + } + + /** + *

+ * Recieves data. + *

+ * + * @return buffer send data + * @throws MessageView + */ + public String[] recvData() throws MessageView { + // debug log(in method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("L7SyncSocket::recvData() throws MessageView in "); + debugLogger.debug("11226 " + buf.toString()); + } + + String readStr; + String[] readDataArray = null; + + try { + readDataArray = new String[ENTRY_NUMBER]; + int i = 0; + while (true) { + readStr = bufferedReader.readLine(); + if (null == readStr) { + return null; + } + + if ((0 == readStr.length())) { + break; + } + if (i >= ENTRY_NUMBER) { + throw new MessageView(40011, + LogCategorySet.SYNC_CONNECTION, + Message.SYNC_INVALID_RECV_DATA); + } + readDataArray[i] = readStr; + i++; + } + } catch (Exception e) { + throw new MessageView(50002, LogCategorySet.SYNC_CONNECTION, + Message.SYNC_RECV_ERROR + " : " + e); + } + + // debug log(out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("L7SyncSocket::recvData() throws MessageView out "); + buf.append("return= "); + if (0 == readDataArray.length) { + buf.append("null"); + } else { + for (int i = 0; i < readDataArray.length; i++) { + if (readDataArray.length - 1 == i) { + buf.append(readDataArray[i].toString()); + break; + } + buf.append(readDataArray[i].toString() + ","); + } + } + debugLogger.debug("11227 " + buf.toString()); + } + return readDataArray; + } + + /** + *

+ * Active server closes connection after recieving all results from stand-by + * server. + *

+ * + * @throws MessageView + */ + public void closeConnection() throws MessageView { + // debug log(in method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("L7SyncSocket::closeConnection() throws MessageView in "); + debugLogger.debug("11228 " + buf.toString()); + } + try { + outputStream.close(); + } catch (Exception e) { + throw new MessageView(50003, LogCategorySet.SYNC_CONNECTION, + Message.SYNC_CLOSE_ERROR + " :" + e); + } + // debug log(out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("L7SyncSocket::closeConnection() throws MessageView out "); + debugLogger.debug("11229 " + buf.toString()); + } + } +} diff --git a/src/src/org/ultramonkey/l7/model/L7guiFramework.java b/src/src/org/ultramonkey/l7/model/L7guiFramework.java new file mode 100644 index 0000000..6b1175c --- /dev/null +++ b/src/src/org/ultramonkey/l7/model/L7guiFramework.java @@ -0,0 +1,997 @@ +package org.ultramonkey.l7.model; + +import java.io.*; +import java.util.*; +import java.util.regex.*; + +import org.apache.log4j.Logger; +import org.ultramonkey.l7.controller.*; + +/** + * + *

+ * class L7guiFramework + *

+ *

+ * Copyright(c) NTT COMWARE 2008 + *

+ * + * @author tanuma + */ +public class L7guiFramework { + + private Logger ioCommandLogger = Logger.getLogger(LogCategorySet.GUI_IO_COMMAND); + private Logger ioFileLogger = Logger.getLogger(LogCategorySet.GUI_IO_FILE); + private Logger saveLogger = Logger.getLogger(LogCategorySet.GUI_SAVE); + private Logger syncLogger = Logger.getLogger(LogCategorySet.GUI_SYNC); + private Logger repLogger = Logger.getLogger(LogCategorySet.GUI_REPLICATION); + private Logger snmpLogger = Logger.getLogger(LogCategorySet.GUI_SNMP); + + /** + * + *

+ * addVirtualSetting method + *

+ * + * @param vs + * virtual service to be added to l7vsd. + * @return result of l7vsadm add virtual service command command. + */ + public boolean addVirtualSetting(VirtualSetting vs) { + // --- debug log (in method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11101 L7guiFramework::addVirtualSetting(VirtualSetting vs) in vs=(" + vs + ")"); + } + // --- debug log (in method) --- + + L7vsAdmController admController = new L7vsAdmController(); + boolean ret = admController.addVirtualService(vs); + + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11102 L7guiFramework::addVirtualSetting(VirtualSetting vs) out return=" + ret); + } + // --- debug log (out method) --- + return ret; + } + + /** + * + *

+ * delVirtualSetting method + *

+ * + * @param vs + * virtual service to be removed from l7vsd. + * @return result of l7vsadm delete virtual service command. + */ + public boolean delVirtualSetting(VirtualSetting vs) { + // --- debug log (in method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11103 L7guiFramework::delVirtualSetting(VirtualSetting vs) in vs=(" + vs + ")"); + } + // --- debug log (in method) --- + + L7vsAdmController admController = new L7vsAdmController(); + boolean ret = admController.delVirtualService(vs); + + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11104 L7guiFramework::delVirtualSetting(VirtualSetting vs) out return=" + ret); + } + // --- debug log (out method) --- + return ret; + } + + /** + * + *

+ * getAdmData method + *

+ * + * @return result of l7vsadm list command, including virtual service + * setting. + */ + public L7vsAdmData getAdmData() { + // --- debug log (in method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11105 L7guiFramework::getAdmData() in"); + } + // --- debug log (in method) --- + + L7vsAdmController admController = new L7vsAdmController(); + L7vsAdmData ret = admController.getData(); + + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11106 L7guiFramework::getAdmData() out return=(" + ret + ")"); + } + // --- debug log (out method) --- + return ret; + } + + /** + * + *

+ * reloadAdmData method + *

+ * + * @param category + * @return result of l7vsadm reload config. + */ + public boolean reloadAdmData(L7vsConfCategory category) { + // --- debug log (in method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11107 L7guiFramework::reloadAdmData() in category=" + category); + } + // --- debug log (in method) --- + + L7vsAdmController admController = new L7vsAdmController(); + boolean ret = admController.reloadConf(category); + + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11108 L7guiFramework::reloadAdmData() out return=" + ret); + } + // --- debug log (out method) --- + return ret; + } + + /** + * + *

+ * getClusterData method + *

+ * + * @return cluster data. + */ + public ClusterData getClusterData() { + // --- debug log (in method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11109 L7guiFramework::getClusterData() in"); + } + // --- debug log (in method) --- + + ClusterController cluster = new ClusterController(); + ClusterData ret = cluster.getData(); + + // --- debug log (in method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11110 L7guiFramework::getClusterData() out return=(" + ret + ")"); + } + // --- debug log (in method) --- + return ret; + } + + /** + * + *

+ * setClusterData method + *

+ * + * @param c + */ + public void setClusterData(ClusterData c) { + // --- debug log (in method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11111 L7guiFramework::setClusterData(ClusterData c) in c=(" + c + ")"); + } + // --- debug log (in method) --- + + ClusterController cluster = new ClusterController(); + cluster.setData(c); + + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11112 L7guiFramework::setClusterData(ClusterData c) out"); + } + // --- debug log (out method) --- + } + + /** + * + *

+ * setClusterMode method + *

+ * + * @param mode + * @return result of switch over. + */ + public boolean setClusterMode() { + // --- debug log (in method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11113 L7guiFramework::setClusterMode() in"); + } + // --- debug log (in method) --- + + ClusterController cluster = new ClusterController(); + boolean ret = cluster.changeClusterMode(); + + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11114 L7guiFramework::setClusterMode() out return=" + ret); + } + // --- debug log (out method) --- + return ret; + } + + /** + * + *

+ * getDirectorData method + *

+ * + * @return l7directord.cf data. + */ + public DirectorData getDirectorData() { + // --- debug log (in method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11115 L7guiFramework::getDirectorData() in"); + } + // --- debug log (in method) --- + + DirectorData d = null; + DirectorController directord = new DirectorController(); + try { + d = directord.getDirectorData(); + } catch (Exception e) { + ioFileLogger.error("41016 Exception occured: " + e.getMessage()); + } + + // --- debug log (out method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11116 L7guiFramework::getDirectorData() out return=(" + d + ")"); + } + // --- debug log (out method) --- + return d; + } + + /** + * + *

+ * setDirectorData method + *

+ * + * @param d + * @return result of save l7directord.cf. + */ + public boolean setDirectorData(DirectorData d) { + // --- debug log (in method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11117 L7guiFramework::setDirectorData(DirectorData d) in d=(" + d + ")"); + } + // --- debug log (in method) --- + + boolean ret = true; + + DirectorController directord = new DirectorController(); + try { + directord.setDirectorData(d); + } catch (FileNotWriteException e) { + ioFileLogger.error("41017 Exception occured: " + e.getMessage()); + ret = false; + } catch (Exception e) { + ioFileLogger.error("41018 Exception occured: " + e.getMessage()); + ret = false; + } + + // --- debug log (out method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11118 L7guiFramework::setDirectorData() out return=" + ret); + } + // --- debug log (out method) --- + return ret; + } + + /** + * + *

+ * checkDirectorData method + *

+ * + * @param d + * @return result of check l7directord.cf. + */ + public String checkDirectorData(DirectorData d) { + // --- debug log (in method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11119 L7guiFramework::checkDirectorData(DirectorData d) in d=(" + d + ")"); + } + // --- debug log (in method) --- + + String result = null; + DirectorController directord = new DirectorController(); + try { + result = directord.checkDirectorData(d); + } catch (FileNotWriteException e) { + ioFileLogger.error("41019 Exception occured: " + e.getMessage()); + } catch (Exception e) { + ioFileLogger.error("41020 Exception occured: " + e.getMessage()); + } + + // --- debug log (out method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11120 L7guiFramework::setDirectorData() out return=\"" + result + "\""); + } + // --- debug log (out method) --- + return result; + } + + /** + * + *

+ * getReplicationData method + *

+ * + * @return replication setting data. + */ + public ReplicationData getReplicationData() { + // --- debug log (in method) --- + if (repLogger.isDebugEnabled()) { + repLogger.debug("11121 L7guiFramework::getReplicationData() in"); + } + // --- debug log (in method) --- + + ReplicationData replicationData = new ReplicationData(); + + L7vsAdmController admController = new L7vsAdmController(); + L7vsAdmData admData = admController.getData(); + L7vsConfController confController = new L7vsConfController(); + try { + L7vsConfData confData = confController.getConfData(); + + replicationData.interval = confData.replicationInterval; + replicationData.otherNode = confData.replicationOtherNode; + replicationData.component = confData.component; + replicationData.nic = confData.replicationNic; + replicationData.replicationMode = admData.replicationMode; + } catch (FileNotReadException e) { + ioFileLogger.error("41021 Exception occured: " + e.getMessage()); + replicationData = null; + } catch (NullPointerException e) { + ioFileLogger.error("41022 Exception occured: " + e.getMessage()); + replicationData = null; + } catch (Exception e) { + ioFileLogger.error("41023 Exception occured: " + e.getMessage()); + replicationData = null; + } + + // --- debug log (out method) --- + if (repLogger.isDebugEnabled()) { + repLogger.debug("11122 L7guiFramework::getReplicationData() out return=(" + replicationData + ")"); + } + // --- debug log (out method) --- + return replicationData; + } + + /** + * + *

+ * setReplicationData method + *

+ * + * @param r + * @return result of save l7vs.cf. + */ + public boolean setReplicationData(ReplicationData r) { + // --- debug log (in method) --- + if (repLogger.isDebugEnabled()) { + repLogger.debug("11123 L7guiFramework::setReplicationData(ReplicationData r) in r=(" + r + ")"); + } + // --- debug log (in method) --- + + boolean ret = true; + L7vsConfController confController = new L7vsConfController(); + try { + L7vsConfData cf = confController.getConfData(); + cf.replicationInterval = r.interval; + confController.setConfData(cf); + } catch (FileNotReadException e) { + ioFileLogger.error("41024 Exception occured: " + e.getMessage()); + ret = false; + } catch (FileNotWriteException e) { + ioFileLogger.error("41025 Exception occured: " + e.getMessage()); + ret = false; + } catch (NullPointerException e) { + ioFileLogger.error("41026 Exception occured: " + e.getMessage()); + ret = false; + } catch (Exception e) { + ioFileLogger.error("41027 Exception occured: " + e.getMessage()); + ret = false; + } + + // --- debug log (out method) --- + if (repLogger.isDebugEnabled()) { + repLogger.debug("11124 L7guiFramework::setReplicationData(ReplicationData r) out return=" + ret); + } + // --- debug log (out method) --- + return ret; + } + + /** + * + *

+ * setReplicationMode method + *

+ * + * @param mode + * @return result of l7vsadm change replication mode command. + */ + public boolean setReplicationMode(ReplicationStatus mode) { + // --- debug log (in method) --- + if (repLogger.isDebugEnabled()) { + repLogger.debug("11125 L7guiFramework::setReplicationMode(ReplicationStatus mode) in mode=" + mode); + } + // --- debug log (in method) --- + + L7vsAdmController admController = new L7vsAdmController(); + boolean ret = admController.setReplicationMode(mode); + + // --- debug log (out method) --- + if (repLogger.isDebugEnabled()) { + repLogger.debug("11126 L7guiFramework::setReplicationMode(ReplicationStatus mode) out return=" + ret); + } + // --- debug log (out method) --- + return ret; + } + + /** + * + *

+ * dumpReplicationData method + *

+ * + * @return result of l7vsadm replication dump command. + */ + public boolean dumpReplicationData() { + // --- debug log (in method) --- + if (repLogger.isDebugEnabled()) { + repLogger.debug("11127 L7guiFramework::dumpReplicationData() in"); + } + // --- debug log (in method) --- + + L7vsAdmController admController = new L7vsAdmController(); + boolean ret = admController.dumpReplicationData(); + + // --- debug log (out method) --- + if (repLogger.isDebugEnabled()) { + repLogger.debug("11128 L7guiFramework::dumpReplicationData() out return=" + ret); + } + // --- debug log (out method) --- + return ret; + } + + /** + * + *

+ * getSnmpAgentData method + *

+ * + * @return SNMP agent data. + */ + public SnmpAgentData getSnmpAgentData() { + // --- debug log (in method) --- + if (snmpLogger.isDebugEnabled()) { + snmpLogger.debug("11129 L7guiFramework::getSnmpAgentData() in"); + } + // --- debug log (in method) --- + + SnmpAgentData snmpData = new SnmpAgentData(); + + L7vsAdmController admController = new L7vsAdmController(); + L7vsAdmData admData = admController.getData(); + L7vsConfController confController = new L7vsConfController(); + try { + snmpData.status = admData.snmpStatus; + + L7vsConfData confData = confController.getConfData(); + snmpData.interval = confData.snmpInterval; + } catch (FileNotReadException e) { + ioFileLogger.error("41028 Exception occured: " + e.getMessage()); + snmpData = null; + } catch (NullPointerException e) { + ioFileLogger.error("41029 Exception occured: " + e.getMessage()); + snmpData = null; + } catch (Exception e) { + ioFileLogger.error("41030 Exception occured: " + e.getMessage()); + snmpData = null; + } + + // --- debug log (out method) --- + if (snmpLogger.isDebugEnabled()) { + snmpLogger.debug("11130 L7guiFramework::getSnmpAgentData() out return=(" + snmpData + ")"); + } + // --- debug log (out method) --- + return snmpData; + } + + /** + * + *

+ * setSnmpAgentData method + *

+ * + * @param s + * @return result of save l7vs.cf + */ + public boolean setSnmpAgentData(SnmpAgentData s) { + // --- debug log (in method) --- + if (snmpLogger.isDebugEnabled()) { + snmpLogger.debug("11131 L7guiFramework::setSnmpAgentData(SnmpAgentData s) in s=(" + s + ")"); + } + // --- debug log (in method) --- + + boolean ret = true; + L7vsConfController confController = new L7vsConfController(); + try { + L7vsConfData cf = confController.getConfData(); + cf.snmpInterval = s.interval; + confController.setConfData(cf); + } catch (FileNotReadException e) { + ioFileLogger.error("41031 Exception occured: " + e.getMessage()); + ret = false; + } catch (FileNotWriteException e) { + ioFileLogger.error("41032 Exception occured: " + e.getMessage()); + ret = false; + } catch (NullPointerException e) { + ioFileLogger.error("41033 Exception occured: " + e.getMessage()); + ret = false; + } catch (Exception e) { + ioFileLogger.error("41034 Exception occured: " + e.getMessage()); + ret = false; + } + + // --- debug log (out method) --- + if (snmpLogger.isDebugEnabled()) { + snmpLogger.debug("11132 L7guiFramework::setSnmpAgentData(SnmpAgentData s) out return=" + ret); + } + // --- debug log (out method) --- + return ret; + } + + /** + * + *

+ * getL7vsConfData method + *

+ * + * @return l7vs.cf data. + */ + public L7vsConfData getL7vsConfData() { + // --- debug log (in method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11133 L7guiFramework::getL7vsConfData() in"); + } + // --- debug log (in method) --- + + L7vsConfController confController = new L7vsConfController(); + L7vsConfData ret = null; + try { + ret = confController.getConfData(); + } catch (FileNotReadException e) { + ioFileLogger.error("41035 Exception occured: " + e.getMessage()); + ret = null; + } catch (Exception e) { + ioFileLogger.error("41036 Exception occured: " + e.getMessage()); + ret = null; + } + + // --- debug log (out method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11134 L7guiFramework::getL7vsConfData() out return=" + ret); + } + // --- debug log (out method) --- + return ret; + } + + /** + * + *

+ * setL7vsConfData method + *

+ * + * @param cf + * @return result of save l7vs.cf + */ + public boolean setL7vsConfData(L7vsConfData cf) { + // --- debug log (in method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11135 L7guiFramework::setL7vsConfData(L7vsConfData cf) in cf=(" + cf + ")"); + } + // --- debug log (in method) --- + + boolean ret = true; + L7vsConfController confController = new L7vsConfController(); + try { + confController.setConfData(cf); + } catch (FileNotWriteException e) { + ioFileLogger.error("41037 Exception occured: " + e.getMessage()); + ret = false; + } catch (Exception e) { + ioFileLogger.error("41038 Exception occured: " + e.getMessage()); + ret = false; + } + + // --- debug log (out method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11136 L7guiFramework::setL7vsConfData(L7vsConfData cf) out return=" + ret); + } + // --- debug log (out method) --- + return ret; + } + + /** + * + *

+ * getLogData method + *

+ * + * @return log setting data. + */ + public LogData getLogData() { + // --- debug log (in method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11137 L7guiFramework::getLogData() in"); + } + // --- debug log (in method) --- + + L7vsLogController logController = new L7vsLogController(); + LogData ret = logController.getData(); + + // --- debug log (out method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11138 L7guiFramework::getLogData() out return=(" + ret + ")"); + } + // --- debug log (out method) --- + return ret; + } + + /** + * + *

+ * saveExecute method + *

+ * + * @param h + * @return + */ + public boolean saveExecute(HashSet h) { + // --- debug log (in method) --- + if (saveLogger.isDebugEnabled()) { + saveLogger.debug("11139 L7guiFramework::saveExecute(HashSet h) in h=(" + h + ")"); + } + // --- debug log (in method) --- + + if (h == null) { + saveLogger.warn("31001 Invalid null argument."); + // --- debug log (out method) --- + if (saveLogger.isDebugEnabled()) { + saveLogger.debug("11140 L7guiFramework::saveExecute(HashSet h) out return=false"); + } + // --- debug log (out method) --- + return false; + } + + L7vsAdmController admController = new L7vsAdmController(); + L7vsConfController confController = new L7vsConfController(); + Iterator i = h.iterator(); + while (i.hasNext()) { + SaveCategoryIdSet s = (SaveCategoryIdSet) i.next(); + switch (s) { + case LOG_ID: + L7vsAdmData admData = admController.getData(); + try { + L7vsConfData cf = confController.getConfData(); + if (admData.l7vsdLogLevel.equals(cf.logger.lbLog.logLevel) + && admData.snmpLogLevel + .equals(cf.logger.snmpLog.logLevel)) { + saveLogger.info("21030 All log level settings have not changed."); + // --- debug log (out method) --- + if (saveLogger.isDebugEnabled()) { + saveLogger.debug("11141 L7guiFramework::saveExecute(HashSet h) out return=false"); + } + // --- debug log (out method) --- + return true; + } + cf.logger.lbLog.logLevel = admData.l7vsdLogLevel; + cf.logger.snmpLog.logLevel = admData.snmpLogLevel; + + confController.setConfData(cf); + } catch (FileNotReadException e) { + ioFileLogger.error("41039 Exception occured: " + e.getMessage()); + // --- debug log (out method) --- + if (saveLogger.isDebugEnabled()) { + saveLogger.debug("11142 L7guiFramework::saveExecute(HashSet h) out return=false"); + } + // --- debug log (out method) --- + return false; + } catch (FileNotWriteException e) { + ioFileLogger.error("41040 Exception occured: " + e.getMessage()); + // --- debug log (out method) --- + if (saveLogger.isDebugEnabled()) { + saveLogger.debug("11143 L7guiFramework::saveExecute(HashSet h) out return=false"); + } + // --- debug log (out method) --- + return false; + } catch (Exception e) { + ioFileLogger.error("41041 Exception occured: " + e.getMessage()); + // --- debug log (out method) --- + if (saveLogger.isDebugEnabled()) { + saveLogger.debug("11144 L7guiFramework::saveExecute(HashSet h) out return=false"); + } + // --- debug log (out method) --- + return false; + } + break; + case VS_ID: + admData = admController.getData(); + DirectorController directord = new DirectorController(); + try { + DirectorData directorData = directord.getDirectorData(); + boolean sameFlag = true; + int admVsCount = admData.virtualSettings.size(); + Vector delVsList = new Vector(); + for (VirtualSetting directorVs : directorData.virtualSettings) { + boolean found = false; + for (VirtualSetting admVs : admData.virtualSettings) { + if (admVs.isSameService(directorVs)) { + if (! admVs.equalsAdm(directorVs)) { + directorVs.sched = admVs.sched; + directorVs.qosclient = admVs.qosclient; + directorVs.qosservice = admVs.qosservice; + directorVs.maxconn = admVs.maxconn; + directorVs.sorryserver = admVs.sorryserver; + directorVs.real = admVs.real; + sameFlag = false; + } + admData.virtualSettings.remove(admVs); + found = true; + break; + } + } + if (found == false) + delVsList.add(directorVs); + } + for (VirtualSetting admVs : admData.virtualSettings) { + directorData.virtualSettings.add(admVs); + sameFlag = false; + } + for (VirtualSetting delVs : delVsList) { + directorData.virtualSettings.remove(delVs); + sameFlag = false; + } + if (sameFlag) { + saveLogger.info("21031 All Virtual Service setting have not changed."); + // --- debug log (out method) --- + if (saveLogger.isDebugEnabled()) { + saveLogger.debug("11145 L7guiFramework::saveExecute(HashSet h) out return=false"); + } + // --- debug log (out method) --- + return true; + } + directord.setDirectorData(directorData); + } catch (FileNotReadException e) { + ioFileLogger.error("41042 Exception occured: " + e.getMessage()); + // --- debug log (out method) --- + if (saveLogger.isDebugEnabled()) { + saveLogger.debug("11146 L7guiFramework::saveExecute(HashSet h) out return=false"); + } + // --- debug log (out method) --- + return false; + } catch (FileNotWriteException e) { + ioFileLogger.error("41043 Exception occured: " + e.getMessage()); + // --- debug log (out method) --- + if (saveLogger.isDebugEnabled()) { + saveLogger.debug("11147 L7guiFramework::saveExecute(HashSet h) out return=false"); + } + // --- debug log (out method) --- + return false; + } catch (Exception e) { + ioFileLogger.error("41044 Exception occured: " + e.getMessage()); + // --- debug log (out method) --- + if (saveLogger.isDebugEnabled()) { + saveLogger.debug("11148 L7guiFramework::saveExecute(HashSet h) out return=false"); + } + // --- debug log (out method) --- + return false; + } + break; + default: + saveLogger.warn("31002 Unknown save category was specified."); + // --- debug log (out method) --- + if (saveLogger.isDebugEnabled()) { + saveLogger.debug("11149 L7guiFramework::saveExecute(HashSet h) out return=false"); + } + // --- debug log (out method) --- + return false; + } + } + + // --- debug log (out method) --- + if (saveLogger.isDebugEnabled()) { + saveLogger.debug("11150 L7guiFramework::saveExecute(HashSet h) out return=true"); + } + // --- debug log (out method) --- + return true; + } + + /** + * + *

+ * syncExecute method + *

+ * + * @param h + * @return result of sync file. + */ + public boolean syncExecute(HashSet h) { + // --- debug log (out method) --- + if (syncLogger.isDebugEnabled()) { + syncLogger.debug("11151 L7guiFramework::syncExecute(HashSet h) in h=(" + h + ")"); + } + // --- debug log (out method) --- + + L7SyncManager sync = new L7SyncManager(); + try { + sync.syncAct(h); + } catch (MessageView mv) { + syncLogger.error("41045 Exception occured: " + mv.getMessage()); + // --- debug log (out method) --- + if (syncLogger.isDebugEnabled()) { + syncLogger.debug("11152 L7guiFramework::syncExecute(HashSet h) out return=false"); + } + // --- debug log (out method) --- + return false; + } + + // --- debug log (out method) --- + if (syncLogger.isDebugEnabled()) { + syncLogger.debug("11153 L7guiFramework::syncExecute(HashSet h) out return=true"); + } + // --- debug log (out method) --- + return true; + } + + /** + * + *

+ * getL7vsdProcessStatus method + *

+ * + * @return existence of l7vsd process. + */ + public boolean getL7vsdProcessStatus() { + // --- debug log (in method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11154 L7guiFramework::getL7vsdProcessStatus() in"); + } + // --- debug log (in method) --- + + boolean ret = processCheck("l7vsd"); + + // --- debug log (out method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11155 L7guiFramework::getL7vsdProcessStatus() out return=" + ret); + } + // --- debug log (out method) --- + return ret; + } + + /** + * + *

+ * getL7directordProcessStatus method + *

+ * + * @return existence of l7directord process. + */ + public boolean getL7directordProcessStatus() { + // --- debug log (in method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11156 L7guiFramework::getL7directordProcessStatus() in"); + } + // --- debug log (in method) --- + + boolean ret = processCheck("l7directord"); + + // --- debug log (out method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11157 L7guiFramework::getL7directordProcessStatus() out return=" + ret); + } + // --- debug log (out method) --- + return ret; + } + + /** + * + *

+ * setLogLevel method + *

+ * + * @param category + * @return result of l7vsadm set log level command. + */ + public boolean setLogLevel(HashMap category) { + // --- debug log (in method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11158 L7guiFramework::setLogLevel(HashMap category in category=(" + category + ")"); + } + // --- debug log (in method) --- + + L7vsAdmController admController = new L7vsAdmController(); + boolean ret = admController.setLogLevel(category); + + // --- debug log (out method) --- + if (ioCommandLogger.isDebugEnabled()) { + ioCommandLogger.debug("11159 L7guiFramework::setLogLevel(HashMap category out return=" + ret); + } + // --- debug log (out method) --- + return ret; + } + + /** + * + *

+ * processCheck method + *

+ * + * @param regex + * @return existence of regex process. + */ + protected boolean processCheck(String regex) { + // --- debug log (in method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11160 L7guiFramework::processCheck(String regex) in regex=\"" + regex + "\""); + } + // --- debug log (in method) --- + + boolean found = false; + String proc = "/proc"; + Pattern p = Pattern.compile("^\\d+$"); + Pattern l7vsd = Pattern.compile("^Name:\t" + regex + "$"); + + try { + File dir = new File(proc); + File[] procdir = dir.listFiles(); + for (int i = 0; i < procdir.length; i++) { + Matcher m = p.matcher(procdir[i].getName()); + if (m.matches()) { + BufferedReader f = null; + try { + f = new BufferedReader(new FileReader("/proc/" + + procdir[i].getName() + "/status")); + String line; + while ((line = f.readLine()) != null) { + Matcher mt = l7vsd.matcher(line); + if (mt.matches()) { + found = true; + break; + } + } + } catch (FileNotFoundException e) { + ioFileLogger.error("41046 Exception occured: " + e.getMessage()); + } catch (IOException e) { + ioFileLogger.error("41047 Exception occured: " + e.getMessage()); + } finally { + try { + if (f != null) { + f.close(); + } + } catch (Exception e) { + ioFileLogger.error("41048 Exception occured: " + e.getMessage()); + } + } + } + } + } catch (Exception e) { + ioFileLogger.error("41049 Exception occured: " + e.getMessage()); + } + + // --- debug log (out method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11161 L7guiFramework::processCheck(String regex) out return=" + found); + } + // --- debug log (out method) --- + return found; + } +} diff --git a/src/src/org/ultramonkey/l7/model/LogCategorySet.java b/src/src/org/ultramonkey/l7/model/LogCategorySet.java new file mode 100644 index 0000000..35ac371 --- /dev/null +++ b/src/src/org/ultramonkey/l7/model/LogCategorySet.java @@ -0,0 +1,69 @@ +package org.ultramonkey.l7.model; + +/** + *

+ * class LogCategorySet + *

+ *

+ * Copyright(c) NTT COMWARE 2008 + *

+ * + * @author nakai + */ +public interface LogCategorySet { + public String L7VSD = "l7vsd"; + + public String L7VSADM = "l7vsadm"; + + public String L7DIRECTORD = "l7directord"; + + public String SNMPAGENT = "SNMPAgent"; + + public String L7GUI = "l7gui"; + + public String SYNC = "syncResource"; + + public String HA = "HA"; + + public String GUI_START_STOP = "l7gui_StartStop"; + + public String GUI_USER_AUTHENTICATION = "l7gui_UserAuthentication"; + + public String GUI_VIRTUALSERVICE = "l7gui_VirtualService"; + + public String GUI_MONITOR = "l7gui_Monitor"; + + public String GUI_SNMP = "l7gui_SnmpAgent"; + + public String GUI_REPLICATION = "l7gui_Replication"; + + public String GUI_LOG = "l7gui_Log"; + + public String GUI_USER_MANAGE = "l7gui_UserManage"; + + public String GUI_REDUNDANT = "l7gui_Redundant"; + + public String GUI_SAVE = "l7gui_Save"; + + public String GUI_SYNC = "l7gui_Sync"; + + public String GUI_SAVE_SYNC = "l7gui_SaveSync"; + + public String GUI_IO = "l7gui_I/O"; + + public String GUI_IO_FILE = "l7gui_I/O.File"; + + public String GUI_IO_COMMAND = "l7gui_I/O.Command"; + + public String SYNC_START_STOP = "l7sync_StartStop"; + + public String SYNC_CONNECTION = "l7sync_Connection"; + + public String SYNC_SYNC = "l7sync_Sync"; + + public String SYNC_SYNC_DIRECTOR_DATA = "l7sync_Sync.DirectorData"; + + public String SYNC_SYNC_L7VSDCONF_DATA = "l7sync_Sync.L7vsdConfData"; + + public String SYNC_SYNC_USER_DATA = "l7sync_Sync.UserData"; +} diff --git a/src/src/org/ultramonkey/l7/model/Message.java b/src/src/org/ultramonkey/l7/model/Message.java new file mode 100644 index 0000000..6192ed5 --- /dev/null +++ b/src/src/org/ultramonkey/l7/model/Message.java @@ -0,0 +1,181 @@ +package org.ultramonkey.l7.model; + +/** + *

class Message

+ *

Copyright(c) NTT COMWARE 2008

+ * @author tsubone + */ +public interface Message { + public static final String INVALID_SESSSION = "Invalid session."; + + public static final String UNEXPECTED_ERROR = "Unexpected error."; + + public static final String USERID_PASSWORD_ERROR = "Invalid \"User ID\" or \"Password\"."; + + public static final String USER_AUTH_ERROR = "User Authentication failed."; + + public static final String VALIDATION_ERROR = "Validation error."; + + public static final String INVALID_VALUE = "Invalid value."; + + public static final String REQUIED_ITEM = "Required fields."; + + public static final String NOT_INPUT_ITEM = "Please fill in the required fields."; + + public static final String DIRECTOR_DATA_ERROR = "Cannot get the l7directord.cf data."; + + public static final String DIRECTOR_SYNTAX_ERROR = "Syntax error of l7directord.cf"; + + public static final String L7VS_CONF_DATA_ERROR = "Cannot get the l7vs.cf data."; + + public static final String CLUSTER_DATA_ERROR = "Cannot get the cluster data."; + + public static final String VS_SELECT_ERROR = "Please select one of the following VirtualServices."; + + public static final String NOT_EQUAL = "The Password and confirmation Password do not match."; + + public static final String PASSWORD_INVALID = "Invalid current Password."; + + public static final String SAVE_CATEGORY_SELECT_ERROR = "Please select one or some of the followings."; + + public static final String SAVE_LOG_VS_SUCCESS = "Log's and VirtualService's settings have been saved."; + + public static final String SAVE_LOG_SUCCESS = "Log's setting has been saved."; + + public static final String SAVE_VS_SUCCESS = "VirtualService's setting has been saved. "; + + public static final String SAVE_LOG_FAIL = "Failed to save Log's setting."; + + public static final String SAVE_VS_FAIL = "Failed to save VirtualService's setting."; + + public static final String SAVE_LOG_VS_FAIL = "Failed to save Log's and VirtualService's settings"; + + public static final String NO_VS = "Such VirtualService does not exist."; + + public static final String ADD_VS_ERROR = "Failed to add VirtualService."; + + public static final String SYNC_CATEGORY_SELECT_ERROR = "Please select one or some of the followings."; + + public static final String NOT_EXIST = "All fields are empty."; + + public static final String WRITE_ERROR = "Cannot write file."; + + public static final String WRITE_ERROR_L7DIRECTORD = "Cannot write new data to the l7directord.cf file."; + + public static final String WRITE_ERROR_L7VS = "Cannot write new data to the l7vs.cf file."; + + public static final String READ_ERROR = "Cannot read file."; + + public static final String USER_CHANGE_SUCCESS = "User data changed."; + + public static final String USER_ADD_SUCCESS = "New user added."; + + public static final String USER_MAX = "GUI Users is up to 16 users. You cannot add over 16 users."; + + public static final String SAME_USER_EXISTS = "Already the same user exists."; + + public static final String USER_REMOVE_SELECT_ERROR = "Please select one or some of the followings."; + + public static final String SELF_USER_DELETE = "Cannot delete yourself."; + + public static final String USER_DELETE_SUCCESS = "User deleted."; + + public static final String USER_DELETE_FAIL = "Failed to delete user."; + + public static final String LOG_NOT_FOUND = "Log file is not found."; + + public static final String REAL_SERVER_EXIST = "Already the same RealServer exists."; + + public static final String VIRTUAL_SERVER_EXIST = "Already the same VirtualService exists."; + + public static final String SYNC_ERROR_L7DIRECTORD = "Failed in the synchronization of the l7directord.cf file."; + + public static final String SYNC_ERROR_L7VS = "Failed in the synchronization of the l7vs.cf file."; + + public static final String L7VSADM_ERROR = "An error occurred while processing l7vsadm command."; + + public static final String CLUSTER_COMMAND_ERROR = "An error occurred while processing cluster management command."; + + public static final String DIRECTOR_SAVE = "Succeeded to modify monitor settings."; + + public static final String DIRECTOR_SAVESYNC = "Succeeded to modify and sync monitor settings."; + + public static final String VS_ADD_APPLY = "Succeeded to add a new VirtualService setting."; + + public static final String VS_ADD_SAVE = "Succeeded to add and save a new VirtualService setting. If the settings is not reflected in the following list, please refresh this page after waited for a while."; + + public static final String VS_ADD_SAVESYNC = "Succeeded to add, save, and sync a new VirtualService setting. If the settings is not reflected in the following list, please refresh this page after waited for a while."; + + public static final String VS_REMOVE_APPLY = "Succeeded to remove a VirtualService setting."; + + public static final String VS_REMOVE_SAVE = "Succeeded to remove and save a VirtualService setting. If the settings is not reflected in the following list, please refresh this page after waited for a while."; + + public static final String VS_REMOVE_SAVESYNC = "Succeeded to remove and save, sync a VirtualService setting. If the settings is not reflected in the following list, please refresh this page after waited for a while."; + + public static final String VS_MODIFY_APPLY = "Succeeded to modify VirtualService setting."; + + public static final String VS_MODIFY_SAVE = "Succeeded to modify and save VirtualService setting. If the settings is not reflected in the following list, please refresh this page after waited for a while."; + + public static final String VS_MODIFY_SAVESYNC = "Succeeded to modify, save and sync VirtualService setting. If the settings is not reflected in the following list, please refresh this page after waited for a while."; + + public static final String CLUSTER_SWITCHORVER = "Succeeded to switch-over cluster."; + + public static final String REP_MASTER = "Succeeded to start replication."; + + public static final String REP_MASTER_STOP = "Succeeded to stop replication."; + + public static final String REP_SLAVE = "Succeeded to start replication."; + + public static final String REP_SLAVE_STOP = "Succeeded to stop replication."; + + public static final String REP_INFO_SAVE = "Succeeded to modify and save replication setting."; + + public static final String REP_INFO_SAVESYNC = "Succeeded to modify, save and sync replication setting."; + + public static final String REP_START = "Succeeded to dump replication data."; + + public static final String LOGLEVEL_CHANGE_APPLY = "Succeeded to change log level."; + + public static final String LOGLEVEL_CHANGE_SAVE = "Succeeded to change and save log level."; + + public static final String LOGLEVEL_CHANGE_SAVESYNC = "Succeeded to change, save and sync log level"; + + public static final String SNMP_INFO_SAVE = "Succeeded to change and save SNMP Agent setting."; + + public static final String SNMP_INFO_SAVESYNC = "Succeeded to change, save and sync SNMP Agent setting."; + + public static final String SYNC = "Succeeded to sync resources."; + + // Messages for L7GUI synchronous processing + public static final String SYNC_INVALID_CATEGORY_ID = "Invalid category id."; + + public static final String SYNC_ENCODE_ERROR = "Failed to serialize or encode."; + + public static final String SYNC_DECODE_ERROR = "Failed to decode or deserialize."; + + public static final String SYNC_SET_ERROR = "Failed to set "; + + public static final String SYNC_GET_ERROR = "Failed to get data"; + + public static final String SYNC_OPEN_ERROR = "Failed to open connection"; + + public static final String SYNC_FAIL = "Failed to synchronize "; + + public static final String SYNC_SEND_ERROR = "Failed to send data"; + + public static final String SYNC_INVALID_ARGUMENT = "Invalid argument supplied for"; + + public static final String SYNC_RECV_ERROR = "Failed to receive data"; + + public static final String SYNC_CLOSE_ERROR = "Failed to close connection."; + + public static final String SYNC_INVALID_RECV_DATA = "Invalid receive data."; + + public static final String SYNC_SUCCESS = " was synchronized."; + + public static final String SYNC_DIFFERENT_DATA = "Different data between active server and stand-by server"; + + public static final String SYNC_SAME_DATA = "The same data between active server and stand-by server"; + + public static final String SYNC_INVALID_SERVER_MODE = "Invalid server mode."; +} diff --git a/src/src/org/ultramonkey/l7/model/MessageView.java b/src/src/org/ultramonkey/l7/model/MessageView.java new file mode 100644 index 0000000..bd4b218 --- /dev/null +++ b/src/src/org/ultramonkey/l7/model/MessageView.java @@ -0,0 +1,214 @@ +package org.ultramonkey.l7.model; + +import java.io.Serializable; + +import org.apache.log4j.Logger; + +/** + * + *

class MessageView

+ *

Copyright(c) NTT COMWARE 2008

+ * @author tanuma + */ +public class MessageView extends Throwable implements Serializable { + static final long serialVersionUID = 1L; + + private Logger ioLogger = Logger.getLogger(LogCategorySet.GUI_IO); + private Logger logger = Logger.getLogger(LogCategorySet.GUI_LOG); + + protected String message = ""; + protected int errno = 0; + protected String category = ""; + + /** + * + * Constructor + * + * @param errno + * @param category + * @param message + */ + public MessageView(int errno, String category, String message) { + // --- debug log (constructor) --- + if (ioLogger.isDebugEnabled()) { + ioLogger.debug("11085 class MessageView created."); + } + // --- debug log (constructor) --- + + if (message != null) + this.message = new String(message); + if (category != null) + this.category = new String(category); + this.errno = errno; + + putLog(); + } + + /** + * + * Constructor + * + */ + public MessageView() { + // --- debug log (constructor) --- + if (ioLogger.isDebugEnabled()) { + ioLogger.debug("11086 class MessageView created."); + } + // --- debug log (constructor) --- + } + + /** + * + *

getMessage method

+ * + * @return + */ + public String getMessage() { + // --- debug log (in/out method) --- + if (ioLogger.isDebugEnabled()) { + ioLogger.debug("11087 MessageView::getMessage() in"); + ioLogger.debug("11088 MessageView::getMessage() out return=\"" + this.message + "\""); + } + // --- debug log (in/out method) --- + return this.message; + } + + /** + * + *

setMessage method

+ * + * @param message + */ + public void setMessage(String message) { + // --- debug log (in method) --- + if (ioLogger.isDebugEnabled()) { + ioLogger.debug("11089 MessageView::setMessage(String message) in message=\"" + message + "\""); + } + // --- debug log (in method) --- + + this.message = message; + putLog(); + + // --- debug log (out method) --- + if (ioLogger.isDebugEnabled()) { + ioLogger.debug("11090 MessageView::setMessage(String message) out"); + } + // --- debug log (out method) --- + } + + /** + * + *

getErrno method

+ * + * @return + */ + public int getErrno() { + // --- debug log (in/out method) --- + if (ioLogger.isDebugEnabled()) { + ioLogger.debug("11091 MessageView::getErrno() in"); + ioLogger.debug("11092 MessageView::getErrno() out return=\"" + this.errno + "\""); + } + // --- debug log (in/out method) --- + return this.errno; + } + + /** + * + *

setErrno method

+ * + * @param errno + */ + public void setErrno(int errno) { + // --- debug log (in method) --- + if (ioLogger.isDebugEnabled()) { + ioLogger.debug("11093 MessageView::setErrno(int errno) in errno=" + errno); + } + // --- debug log (in method) --- + + this.errno = errno; + + // --- debug log (out method) --- + if (ioLogger.isDebugEnabled()) { + ioLogger.debug("11094 MessageView::setErrno(int errno) out"); + } + // --- debug log (out method) --- + } + + /** + * + *

getCategory method

+ * + * @return + */ + public String getCategory() { + // --- debug log (in/out method) --- + if (ioLogger.isDebugEnabled()) { + ioLogger.debug("11095 MessageView::getCategory() in"); + ioLogger.debug("11096 MessageView::getCategory() out return=\"" + this.category + "\""); + } + // --- debug log (in/out method) --- + return this.category; + } + + /** + * + *

setCategory method

+ * + * @param category + */ + public void setCategory(String category) { + // --- debug log (in method) --- + if (ioLogger.isDebugEnabled()) { + ioLogger.debug("11097 MessageView::setMessage(String category) in category=\"" + category + "\""); + } + // --- debug log (in method) --- + + this.category = category; + + // --- debug log (out method) --- + if (ioLogger.isDebugEnabled()) { + ioLogger.debug("11098 MessageView::setMessage(String category) out"); + } + // --- debug log (out method) --- + } + + /** + * + *

putLog method

+ * + */ + protected void putLog() { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + logger.debug("11099 MessageView::putLog() in"); + } + // --- debug log (in method) --- + + if (this.message != null && this.category != null && this.errno >= 10000) { + Logger logger = Logger.getLogger(this.category); + if (this.errno < 20000) { + logger.debug(this.errno + " " + this.message); + } else if (this.errno < 30000) { + logger.info(this.errno + " " + this.message); + } else if (this.errno < 40000) { + logger.warn(this.errno + " " + this.message); + } else if (this.errno < 50000) { + logger.error(this.errno + " " + this.message); + } else if (this.errno < 60000) { + logger.fatal(this.errno + " " + this.message); + } + } + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11100 MessageView::putLog() out"); + } + // --- debug log (out method) --- + } + + public String toString() { + return + "message=\"" + this.message + "\", " + + "errno=" + this.errno + ", " + + "category=\"" + this.category + "\""; + } +} diff --git a/src/src/org/ultramonkey/l7/model/Parameter.java b/src/src/org/ultramonkey/l7/model/Parameter.java new file mode 100644 index 0000000..7457c16 --- /dev/null +++ b/src/src/org/ultramonkey/l7/model/Parameter.java @@ -0,0 +1,200 @@ +package org.ultramonkey.l7.model; + +import java.io.*; +import java.util.*; + +import org.apache.log4j.Logger; + +/** + * + *

class Parameter

+ *

Copyright(c) NTT COMWARE 2008

+ * @author tanuma + */ +public final class Parameter { + + private Logger ioFileLogger = Logger.getLogger(LogCategorySet.GUI_IO_FILE); + private static Logger ioFileLogger_s = Logger.getLogger(LogCategorySet.GUI_IO_FILE); + + private static final String FILENAME = "/etc/l7vs/l7gui.cf"; + + /** + * parameter key name of session timeout + */ + public static final String SESSION_TIMEOUT = "max_session_time"; + + /** + * parameter key name of session timeout + */ + public static final String L7VSADM_TIMEOUT_FLAG = "l7vsadm_timeout_flag"; + + /** + * instance of this class (singleton) + */ + protected static Parameter instance = null; + + /** + * parameter map + */ + protected HashMap paramMap = null; + + /** + * + * Constructor + * + */ + protected Parameter() { + // --- debug log (constructor) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11001 class Parameter created."); + } + // --- debug log (constructor) --- + paramMap = new HashMap(); + try { + loadFromFile(); + } catch(Exception e) { + ioFileLogger.error("41001 Cannot read l7gui.cf file."); + } + } + + /** + * + *

getInstance method

+ * + * @return instance of this class + */ + public synchronized static Parameter getInstance() { + // --- debug log (in method) --- + if (ioFileLogger_s.isDebugEnabled()) { + ioFileLogger_s.debug("11002 Parameter::getInstance() in"); + } + // --- debug log (in method) --- + + if (instance == null) { + instance = new Parameter(); + } + + // --- debug log (out method) --- + if (ioFileLogger_s.isDebugEnabled()) { + ioFileLogger_s.debug("11003 Parameter::getInstance() out return=(" + instance + ")"); + } + // --- debug log (out method) --- + return instance; + } + + /** + * + *

loadFromFile method

+ * + * @throws FileNotReadException + */ + protected void loadFromFile() throws FileNotReadException { + // --- debug log (in method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11004 Parameter::loadFromFile() throws FileNotReadException in"); + } + // --- debug log (in method) --- + + BufferedReader br = null; + try { + br = new BufferedReader(new InputStreamReader(new FileInputStream( + FILENAME))); + String str = br.readLine(); + while (str != null) { + str = str.replaceAll("\\s", ""); + String[] params = str.split("=", 2); + if (params.length == 2) { + if (params[0].startsWith("#") == false) + this.setValue(params[0], params[1]); + } + str = br.readLine(); + } + } catch (Exception e) { + StringBuffer buf = new StringBuffer(); + FileNotReadException ex = new FileNotReadException(); + buf.append("Cannot open file: "); + buf.append(FILENAME); + buf.append(" / Exception Message: "); + buf.append(e.getMessage()); + ex.setFileName(FILENAME); + ex.setErrMessage(buf.toString()); + // --- debug log (out method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11005 Parameter::loadFromFile() throws FileNotReadException out exception=\"" + ex.toString() + "\""); + } + // --- debug log (out method) --- + throw ex; + } + // --- debug log (out method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11006 Parameter::loadFromFile() throws FileNotReadException out"); + } + // --- debug log (out method) --- + } + + /** + * + *

setValue method

+ * + * @param key key with which the specified value is to be associated. + * @param value value to be associated with the specified key. + * @return previous value associated with specified key, or null if there was no mapping for key. + */ + public String setValue(String key, String value) { + // --- debug log (in method) --- + if (ioFileLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("Parameter::setValue(String key, String value) in "); + buf.append("key=\"" + key + "\", "); + buf.append("value=\"" + value + "\""); + ioFileLogger.debug("11007 " + buf.toString()); + } + // --- debug log (in method) --- + + String oldValue = null; + if (key != null) + oldValue = paramMap.put(key, value); + + // --- debug log (in method) --- + if (ioFileLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("Parameter::setValue(String key, String value) out "); + buf.append("return=\"" + oldValue + "\""); + ioFileLogger.debug("11008 " + buf.toString()); + } + // --- debug log (in method) --- + return oldValue; + } + + /** + * + *

getValue method

+ * + * @param key the key whose associated value is to be returned. + * @return the value to which this map maps the specified key, or null if the map contains no mapping for this key. + */ + public String getValue(String key) { + // --- debug log (in method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11009 Parameter::getValue(String key) in key=\"" + key + "\""); + } + // --- debug log (in method) --- + + String value = paramMap.get(key); + + // --- debug log (out method) --- + if (ioFileLogger.isDebugEnabled()) { + ioFileLogger.debug("11010 Parameter::getValue(String key) out return=\"" + value + "\""); + } + // --- debug log (out method) --- + return value; + } + + /** + * + * {@inheritDoc} + */ + public String toString() { + return "paramMap=(" + paramMap + ")"; + } +} diff --git a/src/src/org/ultramonkey/l7/model/Payload.java b/src/src/org/ultramonkey/l7/model/Payload.java new file mode 100644 index 0000000..4c0c893 --- /dev/null +++ b/src/src/org/ultramonkey/l7/model/Payload.java @@ -0,0 +1,502 @@ +package org.ultramonkey.l7.model; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.OutputStream; +import java.util.Vector; + +import javax.mail.internet.MimeUtility; + +import org.apache.log4j.Logger; +import org.ultramonkey.l7.controller.DirectorData; +import org.ultramonkey.l7.controller.L7vsConfData; + +/** + *

class Payload

+ *

Copyright(c) NTT COMWARE 2008

+ * @author momose + */ +public class Payload { + protected Logger debugLogger = Logger.getLogger(LogCategorySet.SYNC_SYNC); + + protected Logger debugDirectorLogger = Logger + .getLogger(LogCategorySet.SYNC_SYNC_DIRECTOR_DATA); + + protected Logger debugL7vsdConfLogger = Logger + .getLogger(LogCategorySet.SYNC_SYNC_L7VSDCONF_DATA); + + protected Logger debugUserLogger = Logger + .getLogger(LogCategorySet.SYNC_SYNC_USER_DATA); + + // �{�f�B����V���A���C�Y�����Abase64�G���R�[�h�����f�[�^�T�C�Y��i�[����int�ϐ� + protected int size; + + // ����Ώۂ̃J�e�S��ID��i�[����int�ϐ� + protected int categoryId; + + // ����Ώۃf�[�^��i�[����Object�ϐ� + protected Object body; + + // �G���R�[�h��@��i�[����String�萔 + protected final String ENCODING = "base64"; + + // �ʐM�f�[�^��size�̃L�[����i�[����String�萔 + protected final String SIZE_KEY_STRING = "size="; + + // �ʐM�f�[�^�̃J�e�S���̃L�[����i�[����String�萔 + protected final String CATEGORY_KEY_STRING = "category="; + + // �ʐM�f�[�^�̃{�f�B���̃L�[����i�[����String�萔 + protected final String BODY_KEY_STRING = "body="; + + // �ʐM�f�[�^�̉�s��i�[����String�萔 + protected final String separator = "\r\n"; + + // �T�C�Y�̒l�̌�����i�[����萔 + protected final int SIZE_PADDING_NUMBER = 7; + + // �J�e�S���̒l�̌�����i�[����萔 + protected final int CATEGORY_PADDING_NUMBER = 2; + + // payload�N���X�̍��ڐ��i�T�C�Y�A�J�e�S��ID�A�{�f�B�j + protected final int ENTRY_NUMBER = 3; + + /** + * Constructor + * + * @param str recieve data + * @throws MessageView + */ + public Payload(String[] str) throws MessageView { + // debug log(constructor) + if (debugLogger.isDebugEnabled()) { + debugLogger.debug("11175 class Payload created."); + } + + // �T�C�Y�̃L�[�ƒl��i�[����String�ϐ� + String sizeStr = str[0]; + // �L�[�ƒl��"="�ŕ��� + String[] sizeSplit = sizeStr.split("="); + // �擾�����T�C�Y�̒l��size�Ɋi�[ + size = Integer.parseInt(sizeSplit[1]); + + // �J�e�S��ID�̃L�[�ƒl��i�[����String�ϐ� + String categoryStr = str[1]; + // �L�[�ƒl��"="�ŕ��� + String[] categorySplit = categoryStr.split("="); + // �擾�����J�e�S��ID�̒l��cateogyId�Ɋi�[ + categoryId = Integer.parseInt(categorySplit[1]); + + // �{�f�B�̃L�[�ƒl��i�[����String�ϐ� + String bodyStr = str[2]; + // �L�[�ƒl��"="�ŕ��� + String[] bodySplit = bodyStr.split("=", 2); + // �擾�����{�f�B�̃T�C�Y���r���� + + if (bodySplit[1].length() != size) { + // �f�[�^�̎擾���s�̃��b�Z�[�W��ԋp + throw new MessageView(40003, LogCategorySet.SYNC_SYNC, Message.SYNC_GET_ERROR + + " : payload"); + } + + // �J�e�S��ID��SYNC_OK��SYNC_NG�ȊO�̏ꍇ + if ((SyncCategoryIdSet.SYNC_OK != categoryId) + && (SyncCategoryIdSet.SYNC_NG != categoryId)) { + // �擾�����{�f�B�̒l��body�Ɋi�[ + body = decodeAndDeserialize(bodySplit[1]); + } + } + + /** + * Constructor + * + * @param categoryId + * @param userData + * @throws MessageView + */ + public Payload(int categoryId, Vector userData) throws MessageView { + // debug log(constructor) + if (debugUserLogger.isDebugEnabled()) { + debugUserLogger.debug("11176 class Payload created."); + } + // �J�e�S��ID��USER_DATA_ID�̏ꍇ + switch (categoryId) { + case SyncCategoryIdSet.USERDATA_ID: + // �T�C�Y�͐ݒ肵�Ȃ� + size = 0; + // ��̃J�e�S��ID��categoryId�ɐݒ� + this.categoryId = categoryId; + // ���UserData��Object�^�Ƃ���body�ɐݒ� + setBody((Object) userData); + break; + + // �f�[�^�N���X�ɑ��݂��Ȃ��J�e�S����w�肵���ꍇ + default: + // �J�e�S�������s���ł��郁�b�Z�[�W��ԋp + throw new MessageView(40004, LogCategorySet.SYNC_SYNC_USER_DATA, + Message.SYNC_INVALID_CATEGORY_ID); + } + } + + /** + * Constructor + * + * @param categoryId + * @param directorData + * @throws MessageView + */ + public Payload(int categoryId, DirectorData directorData) throws MessageView { + // debug log(constructor) + if (debugDirectorLogger.isDebugEnabled()) { + debugDirectorLogger.debug("11177 class Payload created."); + } + switch (categoryId) { + // �J�e�S��ID��MONITOR_ID��SERVICE_ID�̏ꍇ + case SyncCategoryIdSet.MONITOR_ID: + case SyncCategoryIdSet.SERVICE_ID: + case SyncCategoryIdSet.SYNC_OK: + case SyncCategoryIdSet.SYNC_NG: + // �T�C�Y�͐ݒ肵�Ȃ� + size = 0; + // ��̃J�e�S��ID��categoryId�ɐݒ� + this.categoryId = categoryId; + // ���DirectorData��Object�^�Ƃ���body�ɐݒ� + setBody((Object) directorData); + break; + + // �f�[�^�N���X�ɑ��݂��Ȃ��J�e�S����w�肵���ꍇ + default: + // �J�e�S�������s���ł��郁�b�Z�[�W��ԋp + throw new MessageView(40005, LogCategorySet.SYNC_SYNC_DIRECTOR_DATA, + Message.SYNC_INVALID_CATEGORY_ID); + } + } + + /** + * Constructor + * + * @param categoryId + * @param l7vsConfData + * @throws MessageView + */ + public Payload(int categoryId, L7vsConfData l7vsConfData) throws MessageView { + // debug log(constructor) + if (debugL7vsdConfLogger.isDebugEnabled()) { + debugL7vsdConfLogger.debug("11178 class Payload created."); + } + // �J�e�S��ID��L7VSD_LOG_ID�AADM_LOG_ID�ASNMP_LOG_ID�AREPLICATION_INFO_ID�AADM_INFO_ID�̏ꍇ + switch (categoryId) { + case SyncCategoryIdSet.L7VSD_LOG_ID: + case SyncCategoryIdSet.ADM_LOG_ID: + case SyncCategoryIdSet.SNMP_LOG_ID: + case SyncCategoryIdSet.REPLICATION_INFO_ID: + case SyncCategoryIdSet.SNMP_INFO_ID: + case SyncCategoryIdSet.ADM_INFO_ID: + case SyncCategoryIdSet.LOG_ALL_ID: + // �T�C�Y�͐ݒ肵�Ȃ� + size = 0; + // ��̃J�e�S��ID��categoryId�ɐݒ� + this.categoryId = categoryId; + // ���L7vsConfData��Object�^�Ƃ���body�ɐݒ� + setBody((Object) l7vsConfData); + break; + + // �f�[�^�N���X�ɑ��݂��Ȃ��J�e�S����w�肵���ꍇ + default: + // �J�e�S�������s���ł��郁�b�Z�[�W��ԋp + throw new MessageView(40006, LogCategorySet.SYNC_SYNC_L7VSDCONF_DATA, + Message.SYNC_INVALID_CATEGORY_ID); + } + } + + /** + *

Gets body.

+ * + * @return body�@ + */ + protected Object getBody() { + // debug log(in method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("Payload::getBody() in "); + debugLogger.debug("11179 " + buf.toString()); + } + + // debug log(out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("Payload::getBody() out "); + buf.append("return= " + body.toString()); + debugLogger.debug("11180 " + buf.toString()); + } + + //�@�{�f�B����ԋp + return body; + } + + /** + *

Sets body.

+ * + * @param body + */ + protected void setBody(Object body) { + // debug log(in method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("Payload::setBody(Object body) in "); + buf.append("body= " + body.toString()); + debugLogger.debug("11181 " + buf.toString()); + } + + // debug log(out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("Payload::setBody(Object body) out "); + debugLogger.debug("11182 " + buf.toString()); + } + // body����ݒ� + this.body = body; + } + + /** + *

Serializes and encodes data.

+ * + * @return formatted data + * @throws MessageView + */ + protected String serializeAndEncode() throws MessageView { + // debug log(in method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("Payload::serializeAndEncode() throws MessageView in "); + debugLogger.debug("11183 " + buf.toString()); + } + + try { + // �擾�����f�[�^��V���A���C�Y + ByteArrayOutputStream byteArray = new ByteArrayOutputStream(); + ObjectOutputStream outputStream = new ObjectOutputStream(byteArray); + outputStream.writeObject(body); + outputStream.flush(); + outputStream.close(); + + // �V���A���C�Y�����f�[�^��Base64�ŃG���R�[�h + OutputStream base64OutputStream = MimeUtility.encode(byteArray, ENCODING); + byte[] serializeByte = byteArray.toByteArray(); + byteArray.reset(); + base64OutputStream.write(serializeByte); + base64OutputStream.close(); + + // debug log(out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("Payload::serializeAndEncode() throws MessageView out "); + buf.append("return= " + byteArray.toString()); + debugLogger.debug("11184 " + buf.toString().replaceAll("[\r\n]", "")); + } + // �G���R�[�h�����f�[�^��ԋp + return byteArray.toString().replaceAll("[\r\n]", ""); + + // �V���A���C�Y�܂��̓G���R�[�h�Ɏ��s�����ꍇ + } catch (Exception e) { + // �V���A���C�Y���s�̃��b�Z�[�W��ԋp + throw new MessageView(40007, LogCategorySet.SYNC_SYNC, + Message.SYNC_ENCODE_ERROR); + } + + } + + /** + *

Decodes and deserializes data.

+ * + * @param body body data which is serialized and encoded + * @return data at body + * @throws MessageView + */ + protected Object decodeAndDeserialize(String body) throws MessageView { + // debug log(in method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("Payload::decodeAndDeserialize(String body) throws MessageView in "); + buf.append("body= " + body); + debugLogger.debug("11185 " + buf.toString()); + } + + try { + // �f�R�[�h�����f�[�^��i�[����byte�z�� + byte[] readBytes = new byte[10000000]; + + // body��Base64�Ńf�R�[�h + InputStream base64InputStream = MimeUtility.decode(new ByteArrayInputStream( + body.getBytes()), "base64"); + // �f�R�[�h�����f�[�^��擾 + base64InputStream.read(readBytes); + + // �f�R�[�h�����f�[�^��f�V���A���C�Y���邽�߂�ObjectInputStream�C���X�^���X + ObjectInputStream inputStream = new ObjectInputStream( + new ByteArrayInputStream(readBytes)); + + Object result = inputStream.readObject(); + // debug log(out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("Payload::decodeAndDeserialize(String body) throws MessageView out "); + buf.append("return= " + result.toString()); + debugLogger.debug("11186 " + buf.toString()); + } + + // �f�V���A���C�Y�������ʂ�ԋp + return result; + + // �f�V���A���C�Y�܂��̓f�R�[�h�Ɏ��s�����ꍇ + } catch (Exception e) { + // �f�V���A���C�Y���s�̃��b�Z�[�W��ԋp + throw new MessageView(40008, LogCategorySet.SYNC_SYNC, + Message.SYNC_DECODE_ERROR + e); + } + } + + /** + *

Formats data.

+ * + * @return formatted data + * @throws MessageView + */ + public String[] getMessage() throws MessageView { + // debug log(in method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("Payload::getMessage() throws MessageView in "); + debugLogger.debug("11187 " + buf.toString()); + } + + // Base64�G���R�[�h���A�V���A���C�Y�����{�f�B����i�[����String�ϐ� + String body = serializeAndEncode(); + // �G���R�[�h�ƃV���A���C�Y��̃{�f�B���̒�����i�[����String�ϐ� + String sizeNumber = new Integer(body.length()).toString(); + // �J�e�S��ID��i�[����String�ϐ� + String categoryStr = new Integer(categoryId).toString(); + + // ���`��̃T�C�Y��i�[����StringBuffer�C���X�^���X + StringBuffer sizeBuffer = new StringBuffer(); + //�@�T�C�Y�̃L�[����lj� + sizeBuffer.append(SIZE_KEY_STRING); + // �T�C�Y��0�p�f�B���O���A�l��lj� + sizeBuffer.append(sizeNumber); + for (int count = 0; count < SIZE_PADDING_NUMBER - sizeNumber.length(); count++) { + sizeBuffer.insert(SIZE_KEY_STRING.length(), "0"); + } + + // ���`��̃J�e�S����i�[����StringBuffer�C���X�^���X + StringBuffer categoryBuffer = new StringBuffer(); + // �J�e�S���̃L�[����lj� + categoryBuffer.append(CATEGORY_KEY_STRING); + // �J�e�S����0�p�f�B���O���A�l��lj� + categoryBuffer.append(categoryStr); + for (int count = 0; count < CATEGORY_PADDING_NUMBER - categoryStr.length(); count++) { + categoryBuffer.insert(CATEGORY_KEY_STRING.length(), "0"); + } + + // ���`��̃{�f�B��i�[����StringBuffer�C���X�^���X + StringBuffer bodyBuffer = new StringBuffer(); + // �{�f�B�̃L�[����lj� + bodyBuffer.append(BODY_KEY_STRING); + // �{�f�B�̒l��lj� + bodyBuffer.append(body); + + // Payload�N���X�𐮌`�����f�[�^�i�[����String�^�z�� + String[] messageArray = new String[ENTRY_NUMBER]; + // �T�C�Y��messageArray�Ɋi�[ + messageArray[0] = sizeBuffer.toString(); + // �J�e�S����messageArray�Ɋi�[ + messageArray[1] = categoryBuffer.toString(); + // �{�f�B��messageArray�Ɋi�[ + messageArray[2] = bodyBuffer.toString(); + + // debug log(out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("Payload::getMessage() throws MessageView out "); + buf.append("return= " + messageArray.toString()); + debugLogger.debug("11188 " + buf.toString()); + } + + // ���`��̏���ԋp + return messageArray; + } + + /** + *

Gets UserData from Payload.

+ * + * @return userData + */ + public Vector getUserData() { + // debug log(in method) + if (debugUserLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("Payload::getUserData() in "); + debugUserLogger.debug("11189 " + buf.toString()); + } + // debug log(out method) + if (debugUserLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("Payload::getUserData() out "); + buf.append("return= " + ((Vector) body).toString()); + debugUserLogger.debug("11190 " + buf.toString()); + } + + // �{�f�B����UserData�^�ɕϊ����ĕԋp + return (Vector) body; + } + + /** + *

Gets DirectorData from Payload.

+ * + * @return directorData + */ + public DirectorData getDirectorData() { + // debug log(in method) + if (debugDirectorLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("Payload::getDirectorData() in "); + debugLogger.debug("11191 " + buf.toString()); + } + // debug log(out method) + if (debugDirectorLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("Payload::getDirectorData() out "); + buf.append("return= " + ((DirectorData) body).toString()); + debugDirectorLogger.debug("11192 " + buf.toString()); + } + // �{�f�B����DirectorData�^�ɕϊ����ĕԋp + return (DirectorData) body; + } + + /** + *

Gets L7vsdConfData from Payload.

+ * + * @return l7vsdConfData + */ + public L7vsConfData getL7vsdConfData() { + // debug log(in method) + if (debugL7vsdConfLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("Payload::getL7vsdConfData() in "); + debugL7vsdConfLogger.debug("11193 " + buf.toString()); + } + // debug log(out method) + if (debugL7vsdConfLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("Payload::getL7vsdConfData() out "); + buf.append("return= " + ((L7vsConfData) body).toString()); + debugL7vsdConfLogger.debug("11194 " + buf.toString()); + } + // �{�f�B����l7vsConfData�^�ɕϊ����ĕԋp + return (L7vsConfData) body; + } +} diff --git a/src/src/org/ultramonkey/l7/model/SaveCategoryIdSet.java b/src/src/org/ultramonkey/l7/model/SaveCategoryIdSet.java new file mode 100644 index 0000000..d384f5e --- /dev/null +++ b/src/src/org/ultramonkey/l7/model/SaveCategoryIdSet.java @@ -0,0 +1,19 @@ +package org.ultramonkey.l7.model; + +/** + *

class SyncCategoryId

+ *

Copyright(c) NTT COMWARE 2008

+ * @author tanuma + */ +public enum SaveCategoryIdSet { + + /** + * save category: virtual service setting + */ + VS_ID, + + /** + * save category: log level setting + */ + LOG_ID +} diff --git a/src/src/org/ultramonkey/l7/model/SessionTransData.java b/src/src/org/ultramonkey/l7/model/SessionTransData.java new file mode 100644 index 0000000..7ba4a71 --- /dev/null +++ b/src/src/org/ultramonkey/l7/model/SessionTransData.java @@ -0,0 +1,36 @@ +package org.ultramonkey.l7.model; + +import java.io.Serializable; + +import org.apache.log4j.Logger; + +public class SessionTransData implements Serializable { + static final long serialVersionUID = 1; + + private Logger syncLogger = Logger.getLogger(LogCategorySet.GUI_SYNC); + + public String sourceURI; + public String destURI; + public String errorURI; + public int mode; + + public SessionTransData() { + // --- debug log (constructor) --- + if (syncLogger.isDebugEnabled()) { + syncLogger.debug("11230 class SessionTransData created."); + } + // --- debug log (constructor) --- + } + + public SessionTransData(String sourceURI, String destURI, String errorURI, int mode) { + // --- debug log (constructor) --- + if (syncLogger.isDebugEnabled()) { + syncLogger.debug("11231 class SessionTransData created."); + } + // --- debug log (constructor) --- + this.sourceURI = sourceURI; + this.destURI = destURI; + this.errorURI = errorURI; + this.mode = mode; + } +} diff --git a/src/src/org/ultramonkey/l7/model/SyncCategoryIdSet.java b/src/src/org/ultramonkey/l7/model/SyncCategoryIdSet.java new file mode 100644 index 0000000..7d85f65 --- /dev/null +++ b/src/src/org/ultramonkey/l7/model/SyncCategoryIdSet.java @@ -0,0 +1,350 @@ +package org.ultramonkey.l7.model; + +//import java.util.logging.Logger; +import org.apache.log4j.Logger; + +/** + *

class SyncCategoryId

+ *

Copyright(c) NTT COMWARE 2008

+ * @author momose + */ +public class SyncCategoryIdSet { + protected static Logger debugLogger = Logger.getLogger(LogCategorySet.SYNC_SYNC); + + static public final int SYNC_OK = 1; + + static public final int SYNC_NG = 2; + + static public final int L7VSD_LOG_ID = 3; + + static public final int ADM_LOG_ID = 4; + + static public final int SNMP_LOG_ID = 5; + + static public final int REPLICATION_INFO_ID = 6; + + static public final int SNMP_INFO_ID = 7; + + static public final int ADM_INFO_ID = 8; + + static public final int MONITOR_ID = 9; + + static public final int SERVICE_ID = 10; + + static public final int USERDATA_ID = 11; + + static public final int LOG_ALL_ID = 12; + + /** + *

change category name to category ID

+ * + * @param inStr category name + * @return + * @throws MessageView + */ + public static int toCategoryId(String inStr) throws MessageView { + + // debug log(in method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView in "); + buf.append("inStr= " + inStr); + debugLogger.debug("11195 " + buf.toString()); + } + + if (inStr.equals("SYNC_OK")) { + // debug log(out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView out "); + buf.append("return= SYNC_OK"); + debugLogger.debug("11196 " + buf.toString()); + } + return SYNC_OK; + } + if (inStr.equals("SYNC_NG")) { + // debug log(out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView out "); + buf.append("return= SYNC_NG"); + debugLogger.debug("11197 " + buf.toString()); + } + return SYNC_NG; + } + if (inStr.equals("l7vsd_log")) { + // debug log (out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView out "); + buf.append("return= L7VSD_LOG_ID"); + debugLogger.debug("11198 " + buf.toString()); + } + return L7VSD_LOG_ID; + } + if (inStr.equals("adm_log")) { + // debug log (out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView out "); + buf.append("return= ADM_LOG_ID"); + debugLogger.debug("11199 " + buf.toString()); + } + return ADM_LOG_ID; + } + if (inStr.equals("snmp_log")) { + // debug log (out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView out "); + buf.append("return= SNMP_LOG_ID"); + debugLogger.debug("11200 " + buf.toString()); + } + return SNMP_LOG_ID; + } + if (inStr.equals("replication_info")) { + // debug log (out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView out "); + buf.append("return= REPLICATION_INFO_ID"); + debugLogger.debug("11201 " + buf.toString()); + } + return REPLICATION_INFO_ID; + } + if (inStr.equals("snmp_info")) { + // debug log (out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView out "); + buf.append("return= SNMP_INFO_ID"); + debugLogger.debug("11202 " + buf.toString()); + } + return SNMP_INFO_ID; + } + if (inStr.equals("adm_info")) { + // debug log (out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView out "); + buf.append("return= ADM_INFO_ID"); + debugLogger.debug("11203 " + buf.toString()); + } + return ADM_INFO_ID; + } + if (inStr.equals("monitor")) { + // debug log (out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView out "); + buf.append("return= MONITOR_ID"); + debugLogger.debug("11204 " + buf.toString()); + } + return MONITOR_ID; + } + if (inStr.equals("service")) { + // debug log (out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView out "); + buf.append("return= SERVICE_ID"); + debugLogger.debug("11205 " + buf.toString()); + } + return SERVICE_ID; + } + if (inStr.equals("userdata")) { + // debug log (out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView out "); + buf.append("return= USERDATA_ID"); + debugLogger.debug("11206 " + buf.toString()); + } + return USERDATA_ID; + } + if (inStr.equals("log_all")) { + // debug log (out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView out "); + buf.append("return= LOG_ALL_ID"); + debugLogger.debug("11207 " + buf.toString()); + } + return LOG_ALL_ID; + } else + throw new MessageView(40001, LogCategorySet.SYNC_SYNC, + Message.SYNC_INVALID_ARGUMENT + " toCategoryId : " + inStr); + + } + + /** + *

change category ID to category name

+ * + * @param categoryId category ID + * @return category name + * @throws MessageView + */ + public static String toCategoryName(int categoryId) throws MessageView { + // debug log(in method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView in "); + buf.append("categoryId= " + categoryId); + debugLogger.debug("11208 " + buf.toString()); + } + + switch (categoryId) { + case L7VSD_LOG_ID: + // debug log(out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView out "); + buf.append("return= l7vsd_log"); + debugLogger.debug("11209 " + buf.toString()); + } + return "l7vsd_log"; + + case ADM_LOG_ID: + // debug log(out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView out "); + buf.append("return= adm_log"); + debugLogger.debug("11210 " + buf.toString()); + } + return "adm_log"; + + case SNMP_LOG_ID: + // debug log(out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView out "); + buf.append("return= snmp_log"); + debugLogger.debug("11211 " + buf.toString()); + } + + return "snmp_log"; + + case REPLICATION_INFO_ID: + // debug log(out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView out "); + buf.append("return= replication_info"); + debugLogger.debug("11212 " + buf.toString()); + } + return "replication_info"; + + case SNMP_INFO_ID: + // debug log(out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView out "); + buf.append("return= snmp_info"); + debugLogger.debug("11213 " + buf.toString()); + } + return "snmp_info"; + + case ADM_INFO_ID: + // debug log(out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView out "); + buf.append("return= adm_info"); + debugLogger.debug("11214 " + buf.toString()); + } + return "adm_info"; + + case MONITOR_ID: + // debug log(out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView out "); + buf.append("return= monitor"); + debugLogger.debug("11215 " + buf.toString()); + } + return "monitor"; + + case SERVICE_ID: + // debug log(out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView out "); + buf.append("return= service"); + debugLogger.debug("11216 " + buf.toString()); + } + return "service"; + + case USERDATA_ID: + // debug log(out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView out "); + buf.append("return= userdata"); + debugLogger.debug("11217 " + buf.toString()); + } + return "userdata"; + + case LOG_ALL_ID: + // debug log(out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView out "); + buf.append("return= log_all"); + debugLogger.debug("11218 " + buf.toString()); + } + return "log_all"; + + case SYNC_OK: + // debug log(out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView out "); + buf.append("return= sync_ok"); + debugLogger.debug("11219 " + buf.toString()); + } + return "sync_ok"; + + case SYNC_NG: + // debug log(out method) + if (debugLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView out "); + buf.append("return= sync_ng"); + debugLogger.debug("11220 " + buf.toString()); + } + return "sync_ng"; + + default: + throw new MessageView(40002, LogCategorySet.SYNC_SYNC, + Message.SYNC_INVALID_ARGUMENT + " toCategoryName : " + + categoryId); + } + } +} diff --git a/src/src/org/ultramonkey/l7/model/UserData.java b/src/src/org/ultramonkey/l7/model/UserData.java new file mode 100644 index 0000000..48a7e3e --- /dev/null +++ b/src/src/org/ultramonkey/l7/model/UserData.java @@ -0,0 +1,95 @@ +package org.ultramonkey.l7.model; + +import java.io.Serializable; + +import org.apache.log4j.Logger; + +/** + *

class UserData

+ *

Copyright(c) NTT COMWARE 2008

+ * @author nakai + */ +public class UserData implements Serializable { + static final long serialVersionUID = 1L; + + public String userName = null; + public String passwd = null; + public int acl = -1; + public String description = null; + + /** + * + * Constructor + * + */ + public UserData() { + // --- debug log (constructor) --- + Logger userLogger = Logger.getLogger(LogCategorySet.GUI_USER_MANAGE); + if (userLogger.isDebugEnabled()) { + userLogger.debug("11080 class UserData created."); + } + // --- debug log (constructor) --- + this.userName = null; + this.passwd = null; + this.acl = -1; + this.description = null; + } + + public UserData(UserData copy) { + // --- debug log (constructor) --- + Logger userLogger = Logger.getLogger(LogCategorySet.GUI_USER_MANAGE); + if (userLogger.isDebugEnabled()) { + userLogger.debug("11081 class UserData created."); + } + // --- debug log (constructor) --- + if (copy.userName != null) + this.userName = copy.userName; + if (copy.passwd != null) + this.passwd = copy.passwd; + if (copy.description != null) + this.description = copy.description; + this.acl = copy.acl; + } + + /** + * + *

equals method

+ * + * @param user + * @return + */ + public boolean equals(UserData user) { + // --- debug log (in method) --- + Logger userLogger = Logger.getLogger(LogCategorySet.GUI_USER_MANAGE); + if (userLogger.isDebugEnabled()) { + userLogger.debug("11082 Parameter::equals(UserData user) in user=(" + user + ")"); + } + // --- debug log (in method) --- + + if (user != null && + this.userName.equals(user.userName) && + this.passwd.equals(user.passwd) && + this.acl == user.acl) { + // --- debug log (out method) --- + if (userLogger.isDebugEnabled()) { + userLogger.debug("11083 Parameter::equals(UserData user) return=true"); + } + // --- debug log (out method) --- + return true; + } + // --- debug log (out method) --- + if (userLogger.isDebugEnabled()) { + userLogger.debug("11084 Parameter::equals(UserData user) return=false"); + } + // --- debug log (out method) --- + return false; + } + + public String toString() { + return + "userName=\"" + this.userName + "\", " + + "passwd=\"" + this.passwd + "\", " + + "acl=" + this.acl + ", " + + "description=\"" + this.description + "\""; + } +} diff --git a/src/src/org/ultramonkey/l7/model/UserManager.java b/src/src/org/ultramonkey/l7/model/UserManager.java new file mode 100644 index 0000000..e6dc175 --- /dev/null +++ b/src/src/org/ultramonkey/l7/model/UserManager.java @@ -0,0 +1,500 @@ +package org.ultramonkey.l7.model; + +import java.util.Vector; +import java.io.*; +import javax.servlet.http.*; + +import org.apache.log4j.Logger; + +/** + * + *

+ * class UserManager + *

+ *

+ * Copyright(c) NTT COMWARE 2008 + *

+ * + * @author tanuma + */ +public final class UserManager { + static final long serialVersionUID = 1; + + /** + * userdata save filename ("/opt/l7vsd/userdata.dat") + */ + protected static final String FileName = "/opt/l7vsd/userdata.dat"; + + /** + * instance of this class (singleton) + */ + protected static UserManager instance = null; + + /** + * userdata structure + */ + protected Vector uservec = null; + protected Vector olduservec = null; + + protected UserManager() throws FileNotReadException { + // --- debug log (constructor) --- + Logger userLogger = Logger.getLogger(LogCategorySet.GUI_USER_MANAGE); + if (userLogger.isDebugEnabled()) { + userLogger.debug("11011 class UserManager created."); + } + // --- debug log (constructor) --- + + uservec = new Vector(); + this.loadFromFile(); + } + + /** + * + *

+ * getInstance method + *

+ * + * @return instance of this class. + */ + public synchronized static UserManager getInstance() { + // --- debug log (in method) --- + Logger userLogger = Logger.getLogger(LogCategorySet.GUI_USER_MANAGE); + if (userLogger.isDebugEnabled()) { + userLogger.debug("11012 UserManager::getInstance() in"); + } + // --- debug log (in method) --- + + if (instance == null) { + try { + instance = new UserManager(); + } catch (FileNotReadException e) { + userLogger.error("41002 Exception occured: " + e.getMessage()); + // --- debug log (out method) --- + if (userLogger.isDebugEnabled()) { + userLogger.debug("11013 UserManager::getInstance() out return=null"); + } + // --- debug log (out method) --- + return null; + } + } + + // --- debug log (out method) --- + if (userLogger.isDebugEnabled()) { + userLogger.debug("11014 UserManager::getInstance() out return=(" + instance + ")"); + } + // --- debug log (out method) --- + return instance; + } + + /** + * save function + * + * @return true/false + */ + protected void saveToFile() throws FileNotWriteException { + // --- debug log (in method) --- + Logger userLogger = Logger.getLogger(LogCategorySet.GUI_USER_MANAGE); + if (userLogger.isDebugEnabled()) { + userLogger.debug("11015 UserManager::saveToFile() throws FileNotWriteException in"); + } + // --- debug log (in method) --- + + try { + ObjectOutputStream oos = new ObjectOutputStream( + new FileOutputStream(FileName)); + oos.writeObject(uservec); + oos.close(); + } catch (IOException e) { + this.uservec = this.olduservec; + FileNotWriteException exception = new FileNotWriteException(); + exception.setFileName(FileName); + exception.setErrMessage("Cannot write file."); + userLogger.error("41003 Exception occured: " + e.getMessage()); + // --- debug log (out method) --- + if (userLogger.isDebugEnabled()) { + userLogger.debug("11016 UserManager::saveToFile() throws FileNotWriteException out exception=\"" + exception.toString() + "\""); + } + // --- debug log (out method) --- + throw exception; + } + + // --- debug log (out method) --- + if (userLogger.isDebugEnabled()) { + userLogger.debug("11017 UserManager::saveToFile() throws FileNotWriteException out"); + } + // --- debug log (out method) --- + } + + /** + * load function + * + * @return true/false + */ + protected void loadFromFile() throws FileNotReadException { + // --- debug log (in method) --- + Logger userLogger = Logger.getLogger(LogCategorySet.GUI_USER_MANAGE); + if (userLogger.isDebugEnabled()) { + userLogger.debug("11018 UserManager::loadFromFile() throws FileNotReadException in"); + } + // --- debug log (in method) --- + + try { + ObjectInputStream ois = new ObjectInputStream( + new FileInputStream(FileName)); + uservec = (Vector) ois.readObject(); + ois.close(); + } catch (FileNotFoundException ex) { + FileNotReadException exception = new FileNotReadException(); + exception.setFileName(FileName); + exception.setErrMessage("Cannot read file."); + userLogger.error("41004 Exception occured: " + ex.getMessage()); + // --- debug log (out method) --- + if (userLogger.isDebugEnabled()) { + userLogger.debug("11019 UserManager::loadFromFile() throws FileNotReadException out exception=\"" + exception.toString() + "\""); + } + // --- debug log (out method) --- + throw exception; + } catch (IOException ex) { + FileNotReadException exception = new FileNotReadException(); + exception.setFileName(FileName); + exception.setErrMessage("Catch IOException: " + ex.getMessage()); + userLogger.error("41005 Exception occured: " + ex.getMessage()); + // --- debug log (out method) --- + if (userLogger.isDebugEnabled()) { + userLogger.debug("11020 UserManager::loadFromFile() throws FileNotReadException out exception=\"" + exception.toString() + "\""); + } + // --- debug log (out method) --- + throw exception; + } catch (ClassNotFoundException ex) { + FileNotReadException exception = new FileNotReadException(); + exception.setFileName(FileName); + exception.setErrMessage("Catch ClassNotFoundException."); + userLogger.error("41006 Exception occured: " + ex.getMessage()); + // --- debug log (out method) --- + if (userLogger.isDebugEnabled()) { + userLogger.debug("11021 UserManager::loadFromFile() throws FileNotReadException out exception=\"" + exception.toString() + "\""); + } + // --- debug log (out method) --- + throw exception; + } + + // --- debug log (out method) --- + if (userLogger.isDebugEnabled()) { + userLogger.debug("11022 UserManager::loadFromFile() throws FileNotReadException out"); + } + // --- debug log (out method) --- + } + + /** + * + *

+ * authUser method + *

+ * + * @param userid + * @param userpass + * @return + */ + public UserData authUser(String userid, String userpass) { + // --- debug log (in method) --- + Logger userLogger = Logger.getLogger(LogCategorySet.GUI_USER_MANAGE); + if (userLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("UserManager::authUser(String userid, String userpass) in "); + buf.append("userid=\"" + userid + "\", "); + buf.append("userpass=\"" + userpass + "\""); + userLogger.debug("11023 " + buf.toString()); + } + // --- debug log (in method) --- + + UserData ret = null; + if (userid != null || userpass != null) { + for (UserData data : uservec) { + if (data.userName.equals(userid) && data.passwd.equals(userpass)) { + ret = data; + break; + } + } + } + + // --- debug log (out method) --- + if (userLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("UserManager::authUser(String userid, String userpass) out "); + buf.append("return=(" + ret + ")"); + userLogger.debug("11024 " + buf.toString()); + } + // --- debug log (out method) --- + return ret; + } + + /** + * + *

+ * closeUser method + *

+ * + * @param request + */ + public void closeUser(HttpServletRequest request) { + // --- debug log (in method) --- + Logger userLogger = Logger.getLogger(LogCategorySet.GUI_USER_MANAGE); + if (userLogger.isDebugEnabled()) { + userLogger.debug("11025 UserManager::closeUser(HttpServletRequest request) in request=(" + request +")"); + } + // --- debug log (in method) --- + + if (request != null) { + HttpSession session = request.getSession(); + if (session != null) { + session.invalidate(); + } + } + + // --- debug log (out method) --- + if (userLogger.isDebugEnabled()) { + userLogger.debug("11026 UserManager::closeUser(HttpServletRequest request) out"); + } + // --- debug log (out method) --- + } + + /** + * check userid in userlist + * + * @param userid + * @return + */ + public UserData findUser(String userid) { + // --- debug in (out method) --- + Logger userLogger = Logger.getLogger(LogCategorySet.GUI_USER_MANAGE); + if (userLogger.isDebugEnabled()) { + userLogger.debug("11027 UserManager::findUser(String userid) in userid=\"" + userid + "\""); + } + // --- debug log (in method) --- + + UserData ret = null; + if (userid != null) { + for (UserData data : uservec) { + if (data.userName.equals(userid)) { + ret = data; + } + } + } + + // --- debug log (out method) --- + if (userLogger.isDebugEnabled()) { + userLogger.debug("11028 UserManager::findUser(String userid) out return=(" + ret + ")"); + } + // --- debug log (out method) --- + return ret; + } + + /** + * user data add in UserDatas + * + * @param userid + * userid + * @param password + * password + * @param acl + * @param description + * @throws Exception + * UserData can't write + */ + public boolean addUser(String userid, String password, int acl, + String description) throws FileNotWriteException { + // --- debug log (in method) --- + Logger userLogger = Logger.getLogger(LogCategorySet.GUI_USER_MANAGE); + if (userLogger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("UserManager::addUser(String userid, String password, int acl, String description) throws FileNotWriteException in "); + buf.append("userid=\"" + userid + "\", "); + buf.append("password=\"" + password + "\", "); + buf.append("acl=" + acl + ", "); + buf.append("description=\"" + description + "\""); + userLogger.debug("11029 " + buf.toString()); + } + // --- debug log (in method) --- + + if (userid == null || password == null || description == null) { + // --- debug log (out method) --- + if (userLogger.isDebugEnabled()) { + userLogger.debug("11030 UserManager::addUser(String userid, String password, int acl, String description) throws FileNotWriteException out return=false"); + } + // --- debug log (out method) --- + return false; + } + UserData data = findUser(userid); + if (data == null) { + data = new UserData(); + data.userName = userid; + data.passwd = password; + data.acl = acl; + data.description = description; + this.deepCopy(); + uservec.add(data); + this.saveToFile(); + } else { + // --- debug log (out method) --- + if (userLogger.isDebugEnabled()) { + userLogger.debug("11031 UserManager::addUser(String userid, String password, int acl, String description) throws FileNotWriteException out return=false"); + } + // --- debug log (out method) --- + return false; + } + + // --- debug log (out method) --- + if (userLogger.isDebugEnabled()) { + userLogger.debug("11032 UserManager::addUser(String userid, String password, int acl, String description) throws FileNotWriteException out return=true"); + } + // --- debug log (out method) --- + return true; + } + + /** + * + *

+ * changeUser method + *

+ * + * @param data + * @return + * @throws FileNotWriteException + */ + public boolean changeUser(UserData data) throws FileNotWriteException { + // --- debug log (in method) --- + Logger userLogger = Logger.getLogger(LogCategorySet.GUI_USER_MANAGE); + if (userLogger.isDebugEnabled()) { + userLogger.debug("11033 UserManager::changeUser(UserData data) throws FileNotWriteException in data=(" + data + ")"); + } + // --- debug log (in method) --- + + if (data == null) { + // --- debug log (out method) --- + if (userLogger.isDebugEnabled()) { + userLogger.debug("11034 UserManager::changeUser(UserData data) throws FileNotWriteException out return=false"); + } + // --- debug log (out method) --- + return false; + } + UserData found = findUser(data.userName); + if (found != null) { + this.deepCopy(); + found.passwd = data.passwd; + found.acl = data.acl; + found.description = data.description; + this.saveToFile(); + } else { + // --- debug log (out method) --- + if (userLogger.isDebugEnabled()) { + userLogger.debug("11035 UserManager::changeUser(UserData data) throws FileNotWriteException out return=false"); + } + // --- debug log (out method) --- + return false; + } + + // --- debug log (out method) --- + if (userLogger.isDebugEnabled()) { + userLogger.debug("11036 UserManager::changeUser(UserData data) throws FileNotWriteException out return=true"); + } + // --- debug log (out method) --- + return true; + } + + /** + * user data delete from UserDatas + * + * @param userid + * @throws Exception + */ + public boolean delUser(String userid) throws FileNotWriteException { + // --- debug log (in method) --- + Logger userLogger = Logger.getLogger(LogCategorySet.GUI_USER_MANAGE); + if (userLogger.isDebugEnabled()) { + userLogger.debug("11037 UserManager::delUser(String userid) throws FileNotWriteException in userid=\"" + userid + "\""); + } + // --- debug log (in method) --- + + if (userid == null) { + // --- debug log (out method) --- + if (userLogger.isDebugEnabled()) { + userLogger.debug("11038 UserManager::delUser(String userid) throws FileNotWriteException out return=false"); + } + // --- debug log (out method) --- + return false; + } + UserData data = findUser(userid); + if (data != null && uservec.size() > 1) { + this.deepCopy(); + uservec.remove(data); + this.saveToFile(); + // --- debug log (out method) --- + if (userLogger.isDebugEnabled()) { + userLogger.debug("11039 UserManager::delUser(String userid) throws FileNotWriteException out return=true"); + } + // --- debug log (out method) --- + return true; + } + + // --- debug log (out method) --- + if (userLogger.isDebugEnabled()) { + userLogger.debug("11040 UserManager::delUser(String userid) throws FileNotWriteException out return=false"); + } + // --- debug log (out method) --- + return false; + } + + /** + * + *

+ * getUserList method + *

+ * + * @return + */ + public Vector getUserList() throws FileNotReadException { + // --- debug log (in/out method) --- + Logger userLogger = Logger.getLogger(LogCategorySet.GUI_USER_MANAGE); + if (userLogger.isDebugEnabled()) { + userLogger.debug("11041 UserManager::getUserList() in"); + userLogger.debug("11042 UserManager::getUserList() out return=(" + uservec + ")"); + } + // --- debug log (in/out method) --- + this.loadFromFile(); + + return this.uservec; + } + + /** + * + *

+ * setUserList method + *

+ */ + public void setUserList(Vector uservec) throws FileNotWriteException { + // --- debug log (in method) --- + Logger userLogger = Logger.getLogger(LogCategorySet.GUI_USER_MANAGE); + if (userLogger.isDebugEnabled()) { + userLogger.debug("11043 UserManager::setUserList(Vector uservec) in uservec=(" + uservec + ")"); + } + // --- debug log (in method) --- + + this.deepCopy(); + this.uservec = uservec; + this.saveToFile(); + + // --- debug log (out method) --- + if (userLogger.isDebugEnabled()) { + userLogger.debug("11044 UserManager::setUserList(Vector uservec) out"); + } + // --- debug log (out method) --- + } + + protected void deepCopy() { + this.olduservec = new Vector(); + for (UserData cur : this.uservec) { + UserData copy = new UserData(cur); + olduservec.add(copy); + } + } +} diff --git a/src/src/org/ultramonkey/l7/view/ButtonMode.java b/src/src/org/ultramonkey/l7/view/ButtonMode.java new file mode 100644 index 0000000..f9d2d61 --- /dev/null +++ b/src/src/org/ultramonkey/l7/view/ButtonMode.java @@ -0,0 +1,25 @@ +package org.ultramonkey.l7.view; + +/** + *

class ButtonMode

+ *

Copyright(c) NTT COMWARE 2008

+ * @author kubota + */ +public interface ButtonMode { + public static final String APPLY = "Apply"; + public static final String SAVE = "Save"; + public static final String SAVESYNC = "Save + Sync"; + public static final String SWITCH_OVER = "SwitchOver"; + public static final String REP_MASTER_RUNNING = "Master Run"; + public static final String REP_MASTER_STOPPING = "Master Stop"; + public static final String REP_SLAVE_RUNNING = "Slave Run"; + public static final String REP_SLAVE_STOPPING = "Slave Stop"; + public static final String REP_EXECUTE = "Execute"; + public static final String CHANGE = "Change"; + public static final String ADD = "Add"; + public static final String MODIFY = "Modify"; + public static final String REMOVE = "Remove"; + public static final String DELETE = "Delete"; + public static final String YES = "Yes"; + +} diff --git a/src/src/org/ultramonkey/l7/view/CommandExecuter.java b/src/src/org/ultramonkey/l7/view/CommandExecuter.java new file mode 100644 index 0000000..6f415c3 --- /dev/null +++ b/src/src/org/ultramonkey/l7/view/CommandExecuter.java @@ -0,0 +1,880 @@ +package org.ultramonkey.l7.view; + +import java.io.Serializable; +import java.util.HashSet; + +import javax.servlet.http.HttpSession; + +import org.ultramonkey.l7.controller.*; +import org.ultramonkey.l7.model.*; + +public class CommandExecuter extends Thread implements Serializable { + static final long serialVersionUID = 1L; + + ExecuteMode mode; + + Object DataClass; + + Object OrgDataClass; + + Object NewDataClass; + + HttpSession session; + + public CommandExecuter(HttpSession session) { + this.session = session; + this.mode = null; + this.DataClass = null; + this.OrgDataClass = null; + this.NewDataClass = null; + + } + + private void setThreadStatus(MessageView mv) { + session.setAttribute(SessionKeys.COMMAND_MESSAGE, mv); + } + + private void setThreadStatus(String st) { + session.setAttribute(SessionKeys.THREAD_STATUS, st); + } + + private void setThreadStatus(String st, String mes) { + session.setAttribute(SessionKeys.THREAD_STATUS, st); + } + + public void setExecute(ExecuteMode mode, DirectorData DataClass) + throws IllegalArgumentException { + if (DataClass == null) { + throw (new IllegalArgumentException( + "Exception DirectorData is null.")); + } + this.mode = mode; + this.DataClass = DataClass; + } + + public void setExecute(ExecuteMode mode, VirtualSetting DataClass) + throws IllegalArgumentException { + if (DataClass == null) { + throw (new IllegalArgumentException( + "Exception VirtualSettingData is null.")); + } + this.mode = mode; + this.DataClass = DataClass; + + } + + public void setExecute(ExecuteMode mode, VirtualSetting OrgDataClass, + VirtualSetting NewDataClass) throws IllegalArgumentException { + if (OrgDataClass == null || NewDataClass == null) { + throw (new IllegalArgumentException( + "Exception VirtualSettingData is null.")); + } + + this.mode = mode; + this.OrgDataClass = OrgDataClass; + this.NewDataClass = NewDataClass; + } + + public void setExecute(ExecuteMode mode) { + this.mode = mode; + } + + public void setExecute(ExecuteMode mode, ReplicationData DataClass) { + if (DataClass == null) { + throw (new IllegalArgumentException( + "Exception ReplicationData is null.")); + } + this.mode = mode; + this.DataClass = DataClass; + } + + public void setExecute(ExecuteMode mode, LogData DataClass) { + if (DataClass == null) { + throw (new IllegalArgumentException("Exception LogDeta is null.")); + } + this.mode = mode; + this.DataClass = DataClass; + + } + + public void setExecute(ExecuteMode mode, SnmpAgentData DataClass) { + if (DataClass == null) { + throw (new IllegalArgumentException( + "Exception SnmpAgentData is null.")); + } + this.mode = mode; + this.DataClass = DataClass; + + } + + public void setExecute(ExecuteMode mode, HashSet DataClass) { + if (DataClass == null) { + throw (new IllegalArgumentException( + "Exception categoryList is null.")); + } + this.mode = mode; + this.DataClass = DataClass; + + } + + private boolean vsRemove(DirectorData dd, VirtualSetting vs) { + int i; + for (i = 0; i < dd.virtualSettings.size(); i++) { + if (vs.isSameService(dd.virtualSettings.elementAt(i))) { + dd.virtualSettings.remove(i); + return true; + } + } + return false; + } + + private boolean vsRemove(L7vsAdmData ad, VirtualSetting vs) { + int i; + for (i = 0; i < ad.virtualSettings.size(); i++) { + if (vs.isSameService(ad.virtualSettings.elementAt(i))) { + return true; + } + } + return false; + } + + public void run() { + boolean result = false; + boolean sameVs = false; + String message = ""; + int errno = 0; + HashSet cset = new HashSet(); + DirectorData dd; + L7vsAdmData ad; + setThreadStatus(SessionKeys.THREAD_RUNNING); + L7guiFramework framework = new L7guiFramework(); + L7vsConfController confController = new L7vsConfController(); + switch (this.mode) { + case DIRECTOR_SAVE: + String syntax = framework.checkDirectorData((DirectorData) this.DataClass); + if (syntax == null || !syntax.matches("^Syntax OK\n$")) { + errno = 41099; + if (syntax == null) + message = Message.WRITE_ERROR_L7DIRECTORD; + else { + String[] error = syntax.split("at line \\d+: ", 2); + if (error.length == 2) + message = Message.DIRECTOR_SYNTAX_ERROR + ": \"" + error[1] + "\""; + else + message = Message.DIRECTOR_SYNTAX_ERROR + " \"" + syntax + "\""; + } + result = false; + break; + } + else if (!(result = framework + .setDirectorData((DirectorData) this.DataClass))) { + errno = 41100; + message = Message.WRITE_ERROR_L7DIRECTORD; + break; + } + errno = 21049; + message = Message.DIRECTOR_SAVE; + session.setAttribute(SessionKeys.VS_SAVE_STATE, SessionKeys.SAVE); + session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.NO_SYNC); + session.setAttribute(SessionKeys.MONITOR_SYNC_STATE, SessionKeys.NO_SYNC); + break; + + case DIRECTOR_SAVESYNC: + syntax = framework.checkDirectorData((DirectorData) this.DataClass); + if (syntax == null || !syntax.matches("^Syntax OK\n$")) { + errno = 41101; + if (syntax == null) + message = Message.WRITE_ERROR_L7DIRECTORD; + else { + String[] error = syntax.split("at line \\d+: ", 2); + if (error.length == 2) + message = Message.DIRECTOR_SYNTAX_ERROR + ": \"" + error[1] + "\""; + else + message = Message.DIRECTOR_SYNTAX_ERROR + "\"" + syntax + "\""; + } + result = false; + break; + } + else if (!(result = framework + .setDirectorData((DirectorData) this.DataClass))) { + errno = 41102; + message = Message.WRITE_ERROR_L7DIRECTORD; + break; + } + session.setAttribute(SessionKeys.VS_SAVE_STATE, SessionKeys.SAVE); + session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.NO_SYNC); + session.setAttribute(SessionKeys.MONITOR_SYNC_STATE, SessionKeys.NO_SYNC); + cset.add(SyncCategoryIdSet.MONITOR_ID); + if (!(result = framework.syncExecute(cset))) { + errno = 41103; + message = Message.SYNC_ERROR_L7DIRECTORD; + break; + } + errno = 21050; + message = Message.DIRECTOR_SAVESYNC; + session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.SYNC); + session.setAttribute(SessionKeys.MONITOR_SYNC_STATE, SessionKeys.SYNC); + break; + + case VS_ADD_APPLY: // + if (!(result = framework + .addVirtualSetting((VirtualSetting) this.DataClass))) { + errno = 41104; + message = Message.L7VSADM_ERROR; + break; + } + errno = 21051; + message = Message.VS_ADD_APPLY; + session.setAttribute(SessionKeys.VS_SAVE_STATE, SessionKeys.NO_SAVE); + session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.NO_SYNC); + break; + + case VS_ADD_SAVE: // + // SAVE + if ((dd = framework.getDirectorData()) == null) { + errno = 41105; + message = Message.DIRECTOR_DATA_ERROR; + result = false; + break; + } + for (VirtualSetting exist : dd.virtualSettings) { + if (exist.isSameService((VirtualSetting) DataClass)) { + sameVs = true; + break; + } + } + if (sameVs == true) { + errno = 41106; + message = Message.VIRTUAL_SERVER_EXIST; + result = false; + break; + } + dd.virtualSettings.add((VirtualSetting) this.DataClass); + syntax = framework.checkDirectorData(dd); + if (syntax == null || !syntax.matches("^Syntax OK\n$")) { + errno = 41107; + if (syntax == null) + message = Message.WRITE_ERROR_L7DIRECTORD; + else { + String[] error = syntax.split("at line \\d+: ", 2); + if (error.length == 2) + message = Message.DIRECTOR_SYNTAX_ERROR + ": \"" + error[1] + "\""; + else + message = Message.DIRECTOR_SYNTAX_ERROR + "\"" + syntax + "\""; + } + result = false; + break; + } + else if (!(result = framework.setDirectorData(dd))) { + errno = 41108; + message = Message.WRITE_ERROR_L7DIRECTORD; + break; + } + errno = 21052; + message = Message.VS_ADD_SAVE; + session.setAttribute(SessionKeys.VS_SAVE_STATE, SessionKeys.SAVE); + session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.NO_SYNC); + break; + + case VS_ADD_SAVESYNC: // + // SAVE + if ((dd = framework.getDirectorData()) == null) { + errno = 41109; + message = Message.DIRECTOR_DATA_ERROR; + result = false; + break; + } + for (VirtualSetting exist : dd.virtualSettings) { + if (exist.isSameService((VirtualSetting) DataClass)) { + sameVs = true; + break; + } + } + if (sameVs == true) { + errno = 41110; + message = Message.VIRTUAL_SERVER_EXIST; + result = false; + break; + } + dd.virtualSettings.add((VirtualSetting) this.DataClass); + syntax = framework.checkDirectorData(dd); + if (syntax == null || !syntax.matches("^Syntax OK\n$")) { + errno = 41111; + if (syntax == null) + message = Message.WRITE_ERROR_L7DIRECTORD; + else { + String[] error = syntax.split("at line \\d+: ", 2); + if (error.length == 2) + message = Message.DIRECTOR_SYNTAX_ERROR + ": \"" + error[1] + "\""; + else + message = Message.DIRECTOR_SYNTAX_ERROR + "\"" + syntax + "\""; + } + result = false; + break; + } + else if (!(result = framework.setDirectorData(dd))) { + errno = 41112; + message = Message.WRITE_ERROR_L7DIRECTORD; + break; + } + session.setAttribute(SessionKeys.VS_SAVE_STATE, SessionKeys.SAVE); + session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.NO_SYNC); + // SYNC + cset.add(SyncCategoryIdSet.SERVICE_ID); + if (!(result = framework.syncExecute(cset))) { + errno = 41113; + message = Message.SYNC_ERROR_L7DIRECTORD; + break; + } + errno = 21053; + message = Message.VS_ADD_SAVESYNC; + session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.SYNC); + break; + + case VS_REMOVE_APPLY: // + if (!(result = framework + .delVirtualSetting((VirtualSetting) this.DataClass))) { + errno = 41114; + message = Message.L7VSADM_ERROR; + break; + } + errno = 21054; + message = Message.VS_REMOVE_APPLY; + session.setAttribute(SessionKeys.VS_SAVE_STATE, SessionKeys.NO_SAVE); + session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.NO_SYNC); + break; + + case VS_REMOVE_SAVE: // + // SAVE + if ((dd = framework.getDirectorData()) == null) { + errno = 41115; + message = Message.DIRECTOR_DATA_ERROR; + result = false; + break; + } + if ((ad = framework.getAdmData()) == null) { + errno = 41116; + message = Message.L7VSADM_ERROR; + result = false; + break; + } + result = this.vsRemove(dd, (VirtualSetting) this.DataClass); + syntax = framework.checkDirectorData(dd); + if (syntax == null || !syntax.matches("^Syntax OK\n$")) { + errno = 41117; + if (syntax == null) + message = Message.WRITE_ERROR_L7DIRECTORD; + else { + String[] error = syntax.split("at line \\d+: ", 2); + if (error.length == 2) + message = Message.DIRECTOR_SYNTAX_ERROR + ": \"" + error[1] + "\""; + else + message = Message.DIRECTOR_SYNTAX_ERROR + "\"" + syntax + "\""; + } + result = false; + break; + } + if (result == false) { + if(!(result = this.vsRemove(ad, (VirtualSetting) this.DataClass))) { + errno = 41118; + message = Message.NO_VS; + break; + } else if (!(result = framework.delVirtualSetting((VirtualSetting) this.DataClass))) { + errno = 41119; + message = Message.L7VSADM_ERROR; + break; + } + session.setAttribute(SessionKeys.VS_SAVE_STATE, SessionKeys.NO_SAVE); + session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.NO_SYNC); + } + if (!(result = framework.setDirectorData(dd))) { + errno = 41120; + message = Message.WRITE_ERROR_L7DIRECTORD; + break; + } + errno = 21055; + message = Message.VS_REMOVE_SAVE; + session.setAttribute(SessionKeys.VS_SAVE_STATE, SessionKeys.SAVE); + session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.NO_SYNC); + break; + + case VS_REMOVE_SAVESYNC: // + // SAVE + if ((dd = framework.getDirectorData()) == null) { + errno = 41121; + message = Message.DIRECTOR_DATA_ERROR; + result = false; + break; + } + if ((ad = framework.getAdmData()) == null) { + errno = 41122; + message = Message.L7VSADM_ERROR; + result = false; + break; + } + result = this.vsRemove(dd, (VirtualSetting) this.DataClass); + syntax = framework.checkDirectorData(dd); + if (syntax == null || !syntax.matches("^Syntax OK\n$")) { + errno = 41123; + if (syntax == null) + message = Message.WRITE_ERROR_L7DIRECTORD; + else { + String[] error = syntax.split("at line \\d+: ", 2); + if (error.length == 2) + message = Message.DIRECTOR_SYNTAX_ERROR + ": \"" + error[1] + "\""; + else + message = Message.DIRECTOR_SYNTAX_ERROR + "\"" + syntax + "\""; + } + result = false; + break; + } + if (result == false) { + if(!(result = this.vsRemove(ad, (VirtualSetting) this.DataClass))) { + errno = 41124; + message = Message.NO_VS; + break; + } else if (!(result = framework.delVirtualSetting((VirtualSetting) this.DataClass))) { + errno = 41125; + message = Message.L7VSADM_ERROR; + break; + } + session.setAttribute(SessionKeys.VS_SAVE_STATE, SessionKeys.NO_SAVE); + session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.NO_SYNC); + } + if (!(result = framework.setDirectorData(dd))) { + errno = 41126; + message = Message.WRITE_ERROR_L7DIRECTORD; + break; + } + session.setAttribute(SessionKeys.VS_SAVE_STATE, SessionKeys.SAVE); + session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.NO_SYNC); + + // SYNC + cset.add(SyncCategoryIdSet.SERVICE_ID); + if (!(result = framework.syncExecute(cset))) { + errno = 41127; + message = Message.SYNC_ERROR_L7DIRECTORD; + break; + } + errno = 21056; + message = Message.VS_REMOVE_SAVESYNC; + session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.SYNC); + break; + + case VS_MODIFY_APPLY: // + if (!(result = framework + .delVirtualSetting((VirtualSetting) this.OrgDataClass))) { + errno = 41128; + message = Message.L7VSADM_ERROR; + break; + } + if (!(result = framework + .addVirtualSetting((VirtualSetting) this.NewDataClass))) { + errno = 41129; + message = Message.L7VSADM_ERROR; + break; + } + errno = 21057; + message = Message.VS_MODIFY_APPLY; + session.setAttribute(SessionKeys.VS_SAVE_STATE, SessionKeys.NO_SAVE); + session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.NO_SYNC); + break; + + case VS_MODIFY_SAVE: // + if ((dd = framework.getDirectorData()) == null) { + errno = 41130; + message = Message.DIRECTOR_DATA_ERROR; + result = false; + break; + } + if ((ad = framework.getAdmData()) == null) { + errno = 41131; + message = Message.L7VSADM_ERROR; + result = false; + break; + } + result = this.vsRemove(dd, (VirtualSetting) this.OrgDataClass); + for (VirtualSetting exist : dd.virtualSettings) { + if (exist.isSameService((VirtualSetting) NewDataClass)) { + sameVs = true; + break; + } + } + if (sameVs == true) { + errno = 41132; + message = Message.VIRTUAL_SERVER_EXIST; + result = false; + break; + } + dd.virtualSettings.add((VirtualSetting) this.NewDataClass); + syntax = framework.checkDirectorData(dd); + if (syntax == null || !syntax.matches("^Syntax OK\n$")) { + errno = 41133; + if (syntax == null) + message = Message.WRITE_ERROR_L7DIRECTORD; + else { + String[] error = syntax.split("at line \\d+: ", 2); + if (error.length == 2) + message = Message.DIRECTOR_SYNTAX_ERROR + ": \"" + error[1] + "\""; + else + message = Message.DIRECTOR_SYNTAX_ERROR + "\"" + syntax + "\""; + } + result = false; + break; + } + if (result == false) { + if(!(result = this.vsRemove(ad, (VirtualSetting) this.OrgDataClass))) { + errno = 41134; + message = Message.NO_VS; + break; + } else if (!(result = framework.delVirtualSetting((VirtualSetting) this.OrgDataClass))) { + errno = 41135; + message = Message.L7VSADM_ERROR; + break; + } + session.setAttribute(SessionKeys.VS_SAVE_STATE, SessionKeys.NO_SAVE); + session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.NO_SYNC); + } + if (!(result = framework.setDirectorData(dd))) { + errno = 41136; + message = Message.WRITE_ERROR_L7DIRECTORD; + break; + } + errno = 21058; + message = Message.VS_MODIFY_SAVE; + session.setAttribute(SessionKeys.VS_SAVE_STATE, SessionKeys.SAVE); + session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.NO_SYNC); + break; + + case VS_MODIFY_SAVESYNC: // + if ((dd = framework.getDirectorData()) == null) { + errno = 41137; + message = Message.DIRECTOR_DATA_ERROR; + result = false; + break; + } + if ((ad = framework.getAdmData()) == null) { + errno = 41138; + message = Message.L7VSADM_ERROR; + result = false; + break; + } + result = this.vsRemove(dd, (VirtualSetting) this.OrgDataClass); + for (VirtualSetting exist : dd.virtualSettings) { + if (exist.isSameService((VirtualSetting) NewDataClass)) { + sameVs = true; + break; + } + } + if (sameVs == true) { + errno = 41139; + message = Message.VIRTUAL_SERVER_EXIST; + result = false; + break; + } + dd.virtualSettings.add((VirtualSetting) this.NewDataClass); + syntax = framework.checkDirectorData(dd); + if (syntax == null || !syntax.matches("^Syntax OK\n$")) { + errno = 41140; + if (syntax == null) + message = Message.WRITE_ERROR_L7DIRECTORD; + else { + String[] error = syntax.split("at line \\d+: ", 2); + if (error.length == 2) + message = Message.DIRECTOR_SYNTAX_ERROR + ": \"" + error[1] + "\""; + else + message = Message.DIRECTOR_SYNTAX_ERROR + "\"" + syntax + "\""; + } + result = false; + break; + } + if (result == false) { + if(!(result = this.vsRemove(ad, (VirtualSetting) this.OrgDataClass))) { + errno = 41141; + message = Message.NO_VS; + break; + } else if (!(result = framework.delVirtualSetting((VirtualSetting) this.OrgDataClass))) { + errno = 41142; + message = Message.L7VSADM_ERROR; + break; + } + session.setAttribute(SessionKeys.VS_SAVE_STATE, SessionKeys.NO_SAVE); + session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.NO_SYNC); + } + if (!(result = framework.setDirectorData(dd))) { + errno = 41143; + message = Message.WRITE_ERROR_L7DIRECTORD; + break; + } + session.setAttribute(SessionKeys.VS_SAVE_STATE, SessionKeys.SAVE); + session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.NO_SYNC); + // SYNC + cset.add(SyncCategoryIdSet.SERVICE_ID); + if (!(result = framework.syncExecute(cset))) { + errno = 41144; + message = Message.SYNC_ERROR_L7DIRECTORD; + break; + } + errno = 21059; + message = Message.VS_MODIFY_SAVESYNC; + session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.SYNC); + break; + + case CLUSTER_SWITCHORVER: // + if (!(result = framework.setClusterMode())) { + errno = 41145; + message = Message.CLUSTER_COMMAND_ERROR; + } else { + errno = 21060; + message = Message.CLUSTER_SWITCHORVER; + } + break; + + case REP_MASTER: // + if (!(result = framework + .setReplicationMode(ReplicationStatus.MASTER))) { + errno = 41146; + message = Message.L7VSADM_ERROR; + } else { + errno = 21061; + message = Message.REP_MASTER; + } + break; + + case REP_MASTER_STOP: // + if (!(result = framework + .setReplicationMode(ReplicationStatus.MASTER_STOP))) { + errno = 41147; + message = Message.L7VSADM_ERROR; + } else { + errno = 21062; + message = Message.REP_MASTER_STOP; + } + break; + + case REP_SLAVE: // + if (!(result = framework + .setReplicationMode(ReplicationStatus.SLAVE))) { + errno = 41148; + message = Message.L7VSADM_ERROR; + } else { + errno = 21063; + message = Message.REP_SLAVE; + } + break; + + case REP_SLAVE_STOP: // + if (!(result = framework + .setReplicationMode(ReplicationStatus.SLAVE_STOP))) { + errno = 41149; + message = Message.L7VSADM_ERROR; + } else { + errno = 21064; + message = Message.REP_SLAVE_STOP; + } + break; + + case REP_INFO_SAVE: // + if (!(result = framework + .setReplicationData((ReplicationData) DataClass))) { + errno = 41150; + message = Message.WRITE_ERROR_L7VS; + } else { + errno = 21065; + message = Message.REP_INFO_SAVE; + session.setAttribute(SessionKeys.REP_SYNC_STATE, SessionKeys.NO_SYNC); + } + break; + + case REP_INFO_SAVESYNC: // + if (result = framework + .setReplicationData((ReplicationData) DataClass)) { + session.setAttribute(SessionKeys.REP_SYNC_STATE, SessionKeys.NO_SYNC); + // SYNC + cset.add(SyncCategoryIdSet.REPLICATION_INFO_ID); + if (!(result = framework.syncExecute(cset))) { + errno = 41151; + message = Message.SYNC_ERROR_L7VS; + } else { + errno = 21066; + message = Message.REP_INFO_SAVESYNC; + session.setAttribute(SessionKeys.REP_SYNC_STATE, SessionKeys.SYNC); + } + } else { + errno = 41152; + message = Message.WRITE_ERROR_L7VS; + } + break; + + case REP_START:// + if (!(result = framework.dumpReplicationData())) { + errno = 41153; + message = Message.L7VSADM_ERROR; + } else { + errno = 21067; + message = Message.REP_START; + } + break; + + case LOGLEVEL_CHANGE_APPLY: + LogData ld = (LogData) DataClass; + if (! (result = framework.setLogLevel(ld.lbLog.logLevel))) { + errno = 41154; + message = Message.L7VSADM_ERROR; + } + else if (! (result = framework.setLogLevel(ld.snmpLog.logLevel))) { + errno = 41155; + message = Message.L7VSADM_ERROR; + } else { + errno = 21068; + message = Message.LOGLEVEL_CHANGE_APPLY; + session.setAttribute(SessionKeys.LOG_SAVE_STATE, SessionKeys.NO_SAVE); + session.setAttribute(SessionKeys.LOG_SYNC_STATE, SessionKeys.NO_SYNC); + } + break; + + case LOGLEVEL_CHANGE_SAVE: // + try { + L7vsConfData cf = confController.getConfData(); + cf.logger = (LogData) DataClass; + if (! (result = framework.setL7vsConfData(cf))) { + errno = 41156; + message = Message.WRITE_ERROR_L7VS; + } else if (! (result = framework.reloadAdmData(L7vsConfCategory.LOGGER))) { + errno = 41157; + message = Message.L7VSADM_ERROR; + } else if (! (result = framework.reloadAdmData(L7vsConfCategory.SNMPAGENT))) { + errno = 41158; + message = Message.L7VSADM_ERROR; + } else { + errno = 21069; + message = Message.LOGLEVEL_CHANGE_SAVE; + session.setAttribute(SessionKeys.LOG_SAVE_STATE, SessionKeys.SAVE); + session.setAttribute(SessionKeys.LOG_SYNC_STATE, SessionKeys.NO_SYNC); + } + } catch (Exception e) { + errno = 41159; + message = Message.L7VS_CONF_DATA_ERROR; + result = false; + } + break; + + case LOGLEVEL_CHANGE_SAVESYNC: // + try { + L7vsConfData cf = confController.getConfData(); + cf.logger = (LogData) DataClass; + if (! (result = framework.setL7vsConfData(cf))) { + errno = 41160; + message = Message.WRITE_ERROR_L7VS; + } else if (! (result = framework.reloadAdmData(L7vsConfCategory.LOGGER))) { + errno = 41161; + message = Message.L7VSADM_ERROR; + } else if (! (result = framework.reloadAdmData(L7vsConfCategory.SNMPAGENT))) { + errno = 41162; + message = Message.L7VSADM_ERROR; + } else { + session.setAttribute(SessionKeys.LOG_SAVE_STATE, SessionKeys.SAVE); + session.setAttribute(SessionKeys.LOG_SYNC_STATE, SessionKeys.NO_SYNC); + cset.add(SyncCategoryIdSet.LOG_ALL_ID); + if (! (result = framework.syncExecute(cset))) { + errno = 41163; + message = Message.SYNC_ERROR_L7VS; + } else { + errno = 21070; + message = Message.LOGLEVEL_CHANGE_SAVESYNC; + session.setAttribute(SessionKeys.LOG_SYNC_STATE, SessionKeys.SYNC); + } + } + } catch (Exception e) { + errno = 41164; + message = Message.L7VS_CONF_DATA_ERROR; + result = false; + } + break; + + case SNMP_INFO_SAVE: // + if (!(result = framework + .setSnmpAgentData((SnmpAgentData) DataClass))) { + errno = 41165; + message = Message.WRITE_ERROR_L7VS; + } else { + errno = 21071; + message = Message.SNMP_INFO_SAVE; + session.setAttribute(SessionKeys.SNMP_SYNC_STATE, SessionKeys.NO_SYNC); + } + break; + + case SNMP_INFO_SAVESYNC: // + if (!(result = framework + .setSnmpAgentData((SnmpAgentData) DataClass))) { + errno = 41166; + message = Message.WRITE_ERROR_L7VS; + break; + } + session.setAttribute(SessionKeys.SNMP_SYNC_STATE, SessionKeys.NO_SYNC); + // SYNC + cset.add(SyncCategoryIdSet.SNMP_INFO_ID); + if (!(result = framework.syncExecute(cset))) { + errno = 41167; + message = Message.SYNC_ERROR_L7VS; + } else { + errno = 21072; + message = Message.SNMP_INFO_SAVESYNC; + session.setAttribute(SessionKeys.SNMP_SYNC_STATE, SessionKeys.SYNC); + } + break; + + case SYNC: // + HashSet syncSet = (HashSet) DataClass; + if (!(result = framework.syncExecute(syncSet))) { + errno = 41168; + message = Message.SYNC_FAIL; + } else { + errno = 21073; + message = Message.SYNC; + for (int i : syncSet) { + switch(i) { + case SyncCategoryIdSet.L7VSD_LOG_ID: + case SyncCategoryIdSet.ADM_LOG_ID: + case SyncCategoryIdSet.SNMP_LOG_ID: + case SyncCategoryIdSet.LOG_ALL_ID: + session.setAttribute(SessionKeys.LOG_SYNC_STATE, SessionKeys.SYNC); + break; + case SyncCategoryIdSet.REPLICATION_INFO_ID: + session.setAttribute(SessionKeys.REP_SYNC_STATE, SessionKeys.SYNC); + break; + case SyncCategoryIdSet.SNMP_INFO_ID: + session.setAttribute(SessionKeys.SNMP_SYNC_STATE, SessionKeys.SYNC); + break; + case SyncCategoryIdSet.MONITOR_ID: + session.setAttribute(SessionKeys.MONITOR_SYNC_STATE, SessionKeys.SYNC); + break; + case SyncCategoryIdSet.SERVICE_ID: + session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.SYNC); + break; + case SyncCategoryIdSet.USERDATA_ID: + session.setAttribute(SessionKeys.GUI_SYNC_STATE, SessionKeys.SYNC); + case SyncCategoryIdSet.ADM_INFO_ID: + default: + } + } + } + break; + + default: + throw (new IllegalArgumentException("Illegal Parameter.")); + } + MessageView mv = new MessageView(); + mv.setCategory(LogCategorySet.GUI_IO_COMMAND); + mv.setMessage(message); + mv.setErrno(errno); + setThreadStatus(mv); + + if (result != true) { + setThreadStatus(SessionKeys.THREAD_FAIL); + } else { + setThreadStatus(SessionKeys.THREAD_SUCCESS); + } + return; + } +} diff --git a/src/src/org/ultramonkey/l7/view/L7guiServletBase.java b/src/src/org/ultramonkey/l7/view/L7guiServletBase.java new file mode 100644 index 0000000..d32e55a --- /dev/null +++ b/src/src/org/ultramonkey/l7/view/L7guiServletBase.java @@ -0,0 +1,152 @@ +package org.ultramonkey.l7.view; + +import java.io.IOException; +import javax.servlet.*; +import javax.servlet.http.*; + +import org.apache.log4j.Logger; +import org.ultramonkey.l7.model.*; + +/** + * servlet base class + * + * @author nakai + * @version 1.0 + * @since 1.0 + */ +public class L7guiServletBase extends HttpServlet { + static final long serialVersionUID = 1L; + protected static final String USERPARAM = "uid"; + protected static final String PASSWDPARAM = "passwd"; + protected boolean login = false; + + private Logger logger = Logger.getLogger(LogCategorySet.GUI_IO); + + public L7guiServletBase() { + super(); + + // --- debug log (constructor) --- + if (logger.isDebugEnabled()) { + logger.debug("11339 class L7guiServletBase created."); + } + // --- debug log (constructor) --- + } + + /* (non-Java-doc) + * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("L7guiServletBase::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in "); + buf.append("request=(" + request + "), "); + buf.append("response=(" + response + ")"); + logger.debug("11340 " + buf.toString()); + } + // --- debug log (in method) --- + + doPost(request, response); + + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11341 L7guiServletBase::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + } + + /* (non-Java-doc) + * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) + * + * ex. child class + * public class childServlet extends L7guiServletBase { + * protected void doPost(HttpServletRequest req, HttpServletResponse res) { + * super.doPost(req, res); + * if ( login == false ) return; + * : + * : + * : + * } + * } + */ + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("L7guiServletBase::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in "); + buf.append("request=(" + request + "), "); + buf.append("response=(" + response + ")"); + logger.debug("11342 " + buf.toString()); + } + // --- debug log (in method) --- + + HttpSession session = request.getSession(false); + login = this.checkSession(session); + + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11343 L7guiServletBase::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + } + + /* + * + *

checkSession method

+ * + * @param session + * @return + */ + public boolean checkSession(HttpSession session){ + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("L7guiServletBase::checkSession(HttpSession session) in "); + buf.append("session=(" + session + ")"); + logger.debug("11344 " + buf.toString()); + } + // --- debug log (in method) --- + + // session check. + if (session == null) { + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11345 L7guiServletBase::checkSession(HttpSession session) out return=false"); + } + // --- debug log (out method) --- + return false; + } + + UserData sessionUserData = (UserData) session.getAttribute(SessionKeys.LOGIN_SESSION); + UserManager userManager = UserManager.getInstance(); + + try { + UserData serverUserData = userManager.authUser(sessionUserData.userName, sessionUserData.passwd); + if (serverUserData == null) { + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11346 L7guiServletBase::checkSession(HttpSession session) out return=false"); + } + // --- debug log (out method) --- + return false; + } + } catch (NullPointerException e) { + logger.error("41086 Exception occured: " + e.getMessage()); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11347 L7guiServletBase::checkSession(HttpSession session) out return=false"); + } + // --- debug log (out method) --- + return false; + } + + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11348 L7guiServletBase::checkSession(HttpSession session) out return=true"); + } + // --- debug log (out method) --- + return true; + } +} diff --git a/src/src/org/ultramonkey/l7/view/LogLevelServlet.java b/src/src/org/ultramonkey/l7/view/LogLevelServlet.java new file mode 100644 index 0000000..1caad32 --- /dev/null +++ b/src/src/org/ultramonkey/l7/view/LogLevelServlet.java @@ -0,0 +1,618 @@ +package org.ultramonkey.l7.view; + +import java.io.IOException; +import java.util.*; + +import javax.servlet.*; +import javax.servlet.http.*; + +import org.apache.log4j.Logger; +import org.ultramonkey.l7.controller.*; +import org.ultramonkey.l7.model.*; + + +/** + *

class LogLevelServlet

+ *

Copyright(c) NTT COMWARE 2008

+ * @author tsubone + */ +public class LogLevelServlet extends L7guiServletBase { + static final long serialVersionUID = 1L; + + private Logger logger = Logger.getLogger(LogCategorySet.GUI_IO); + + /* (non-Java-doc) + * @see javax.servlet.http.HttpServlet#HttpServlet() + */ + public LogLevelServlet() { + super(); + // --- debug log (constructor) --- + if (logger.isDebugEnabled()) { + logger.debug("11467 class LogLevelServlet created."); + } + // --- debug log (constructor) --- + } + + /* (non-Java-doc) + * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("LogLevelServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in "); + buf.append("request=(" + request + "), "); + buf.append("response=(" + response + ")"); + logger.debug("11468 " + buf.toString()); + request.setCharacterEncoding("UTF-8"); + logger.debug("11469 QueryString=\"" + request.getQueryString() + "\""); + } + // --- debug log (in method) --- + + response.sendRedirect(RedirectPages.LOGIN); + + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11470 LogLevelServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + /* (non-Java-doc) + * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("LogLevelServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in "); + buf.append("request=(" + request + "), "); + buf.append("response=(" + response + ")"); + logger.debug("11471 " + buf.toString()); + request.setCharacterEncoding("UTF-8"); + Enumeration keys = request.getParameterNames(); + String post = ""; + while (keys.hasMoreElements()) { + if (post.length() != 0) + post += "&"; + String key = (String) keys.nextElement(); + post += key + "=" + request.getParameter(key); + } + logger.debug("11472 PostData=\"" + post + "\""); + } + // --- debug log (in method) --- + + /* + * check login session + */ + super.doPost(request, response); + + HttpSession session = request.getSession(false); + if (login == false || session == null) { + if (session != null) { + MessageView error = new MessageView(41203, LogCategorySet.GUI_USER_AUTHENTICATION, Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + } + response.sendRedirect(RedirectPages.LOGIN); + + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11473 LogLevelServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + /* + * get logSetInfo + */ + request.setCharacterEncoding("UTF-8"); + HashMap tmpMap = (HashMap) request + .getParameterMap(); + if (tmpMap == null) { + MessageView error = new MessageView(41204, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11474 LogLevelServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + HashMap inputLogLevelMap = new HashMap(); + Iterator i = tmpMap.keySet().iterator(); + while (i.hasNext()) { + String key = (String) i.next(); + inputLogLevelMap.put(key, tmpMap.get(key)[0]); + } + + String logType = (String) inputLogLevelMap.get("type"); + if (logType == null) { + MessageView error = new MessageView(41205, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11475 LogLevelServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + HashMap logLevelList = null; + + L7guiFramework frame = new L7guiFramework(); + LogData logInfo = frame.getLogData(); + if (logInfo == null) { + MessageView error = new MessageView(41206, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11476 LogLevelServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + SessionTransData pagetrans = new SessionTransData(); + String level = null; + LogData.LogLevel logLevel = null; + boolean levelCheckFlag = true; + + try { + if (logType.equals(LogCategorySet.L7VSD)) { + logLevelList = logInfo.lbLog.logLevel; + pagetrans.sourceURI = RedirectPages.LOG_L7VSD; + pagetrans.destURI = RedirectPages.LOG_L7VSD; + pagetrans.errorURI = RedirectPages.LOG_L7VSD; + session.setAttribute(SessionKeys.PAGE_TRANSDATA, pagetrans); + + level = inputLogLevelMap.get("L7VSD_NETWORK"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.L7VSD_NETWORK, logLevel); + } else { + levelCheckFlag = false; + } + level = inputLogLevelMap.get("L7VSD_NETWORK_BANDWIDTH"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.L7VSD_NETWORK_BANDWIDTH, + logLevel); + } else { + levelCheckFlag = false; + } + level = inputLogLevelMap.get("L7VSD_NETWORK_NUM_CONNECTION"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.L7VSD_NETWORK_NUM_CONNECTION, + logLevel); + } else { + levelCheckFlag = false; + } + level = inputLogLevelMap.get("L7VSD_NETWORK_QOS"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.L7VSD_NETWORK_QOS, logLevel); + } else { + levelCheckFlag = false; + } + level = inputLogLevelMap.get("L7VSD_VIRTUAL_SERVICE"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.L7VSD_VIRTUAL_SERVICE, logLevel); + } else { + levelCheckFlag = false; + } + level = inputLogLevelMap.get("L7VSD_REAL_SERVER"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.L7VSD_REAL_SERVER, logLevel); + } else { + levelCheckFlag = false; + } + level = inputLogLevelMap.get("L7VSD_SORRY_SERVER"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.L7VSD_SORRY_SERVER, logLevel); + } else { + levelCheckFlag = false; + } + level = inputLogLevelMap.get("L7VSD_REAL_SERVER_BALANCING"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.L7VSD_REAL_SERVER_BALANCING, + logLevel); + } else { + levelCheckFlag = false; + } + level = inputLogLevelMap.get("L7VSD_REPLICATION"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.L7VSD_REPLICATION, logLevel); + } else { + levelCheckFlag = false; + } + level = inputLogLevelMap.get("L7VSD_START_STOP"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.L7VSD_START_STOP, logLevel); + } else { + levelCheckFlag = false; + } + level = inputLogLevelMap.get("L7VSD_SYSTEM"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.L7VSD_SYSTEM, logLevel); + } else { + levelCheckFlag = false; + } + level = inputLogLevelMap.get("L7VSD_SYSTEM_MEMORY"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.L7VSD_SYSTEM_MEMORY, logLevel); + } else { + levelCheckFlag = false; + } + level = inputLogLevelMap.get("L7VSD_SYSTEM_SOCKET"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.L7VSD_SYSTEM_SOCKET, logLevel); + } else { + levelCheckFlag = false; + } + level = inputLogLevelMap.get("L7VSD_SYSTEM_SIGNAL"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.L7VSD_SYSTEM_SIGNAL, logLevel); + } else { + levelCheckFlag = false; + } + level = inputLogLevelMap.get("L7VSD_ENVIRONMENT"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.L7VSD_ENVIRONMENT, logLevel); + } else { + levelCheckFlag = false; + } + level = inputLogLevelMap.get("L7VSD_ENVIRONMENT_PARAMETER"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.L7VSD_ENVIRONMENT_PARAMETER, + logLevel); + } else { + levelCheckFlag = false; + } + level = inputLogLevelMap.get("L7VSD_LOGGER"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.L7VSD_LOGGER, logLevel); + } else { + levelCheckFlag = false; + } + level = inputLogLevelMap.get("L7VSD_PARAMETER"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.L7VSD_PARAMETER, logLevel); + } else { + levelCheckFlag = false; + } + level = inputLogLevelMap.get("L7VSD_EVENT"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.L7VSD_EVENT, logLevel); + } else { + levelCheckFlag = false; + } + level = inputLogLevelMap.get("L7VSD_SCHEDULE"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.L7VSD_SCHEDULE, logLevel); + } else { + levelCheckFlag = false; + } + level = inputLogLevelMap.get("L7VSD_PROGRAM"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.L7VSD_PROGRAM, logLevel); + } else { + levelCheckFlag = false; + } + level = inputLogLevelMap.get("L7VSD_PROTOCOL"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.L7VSD_PROTOCOL, logLevel); + } else { + levelCheckFlag = false; + } + level = inputLogLevelMap.get("L7VSD_MODULE"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.L7VSD_MODULE, logLevel); + } else { + levelCheckFlag = false; + } + } else if (logType.equals(LogCategorySet.L7VSADM)) { + logLevelList = logInfo.admLog.logLevel; + pagetrans.sourceURI = RedirectPages.LOG_L7VSADM; + pagetrans.destURI = RedirectPages.LOG_L7VSADM; + pagetrans.errorURI = RedirectPages.LOG_L7VSADM; + session.setAttribute(SessionKeys.PAGE_TRANSDATA, pagetrans); + + level = inputLogLevelMap.get("L7VSADM_PARSE"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.L7VSADM_PARSE, logLevel); + } else { + levelCheckFlag = false; + } + level = inputLogLevelMap.get("L7VSADM_OPERATE"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.L7VSADM_OPERATE, logLevel); + } else { + levelCheckFlag = false; + } + level = inputLogLevelMap.get("L7VSADM_COMMUNICATE"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.L7VSADM_COMMUNICATE, logLevel); + } else { + levelCheckFlag = false; + } + level = inputLogLevelMap.get("L7VSADM_CONFIG_RESULT"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.L7VSADM_CONFIG_RESULT, logLevel); + } else { + levelCheckFlag = false; + } + level = inputLogLevelMap.get("L7VSADM_COMMON"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.L7VSADM_COMMON, logLevel); + } else { + levelCheckFlag = false; + } + level = inputLogLevelMap.get("L7VSADM_LOGGER"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.L7VSADM_LOGGER, logLevel); + } else { + levelCheckFlag = false; + } + level = inputLogLevelMap.get("L7VSADM_PARAMETER"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.L7VSADM_PARAMETER, logLevel); + } else { + levelCheckFlag = false; + } + level = inputLogLevelMap.get("L7VSADM_PROTOCOL"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.L7VSADM_PROTOCOL, logLevel); + } else { + levelCheckFlag = false; + } + level = inputLogLevelMap.get("L7VSADM_MODULE"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.L7VSADM_MODULE, logLevel); + } else { + levelCheckFlag = false; + } + } else if (logType.equals(LogCategorySet.SNMPAGENT)) { + logLevelList = logInfo.snmpLog.logLevel; + pagetrans.sourceURI = RedirectPages.LOG_SNMPAGENT; + pagetrans.destURI = RedirectPages.LOG_SNMPAGENT; + pagetrans.errorURI = RedirectPages.LOG_SNMPAGENT; + session.setAttribute(SessionKeys.PAGE_TRANSDATA, pagetrans); + + level = inputLogLevelMap.get("SNMPAGENT_START_STOP"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.SNMPAGENT_START_STOP, logLevel); + } else { + levelCheckFlag = false; + } + level = inputLogLevelMap.get("SNMPAGENT_MANAGER_RECEIVE"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.SNMPAGENT_MANAGER_RECEIVE, + logLevel); + } else { + levelCheckFlag = false; + } + level = inputLogLevelMap.get("SNMPAGENT_MANAGER_SEND"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.SNMPAGENT_MANAGER_SEND, + logLevel); + } else { + levelCheckFlag = false; + } + level = inputLogLevelMap.get("SNMPAGENT_L7VSD_RECEIVE"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.SNMPAGENT_L7VSD_RECEIVE, + logLevel); + } else { + levelCheckFlag = false; + } + level = inputLogLevelMap.get("SNMPAGENT_L7VSD_SEND"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.SNMPAGENT_L7VSD_SEND, logLevel); + } else { + levelCheckFlag = false; + } + level = inputLogLevelMap.get("SNMPAGENT_LOGGER"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.SNMPAGENT_LOGGER, logLevel); + } else { + levelCheckFlag = false; + } + level = inputLogLevelMap.get("SNMPAGENT_PARAMETER"); + logLevel = levelCheck(level); + if (logLevel != null) { + logLevelList.put(LogData.LogCategory.SNMPAGENT_PARAMETER, logLevel); + } else { + levelCheckFlag = false; + } + } else if (logType.equals(LogCategorySet.L7GUI)) { + logLevelList = logInfo.guiLog.logLevel; + pagetrans.sourceURI = RedirectPages.LOG_L7GUI; + pagetrans.destURI = RedirectPages.LOG_L7GUI; + pagetrans.errorURI = RedirectPages.LOG_L7GUI; + session.setAttribute(SessionKeys.PAGE_TRANSDATA, pagetrans); + } else if (logType.equals(LogCategorySet.GUI_SYNC)) { + logLevelList = logInfo.syncLog.logLevel; + pagetrans.sourceURI = RedirectPages.LOG_SYNC; + pagetrans.destURI = RedirectPages.LOG_SYNC; + pagetrans.errorURI = RedirectPages.LOG_SYNC; + session.setAttribute(SessionKeys.PAGE_TRANSDATA, pagetrans); + } else { + MessageView error = new MessageView(41207, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11477 LogLevelServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + } catch (NullPointerException e) { + MessageView error = new MessageView(41208, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11478 LogLevelServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + if (levelCheckFlag == false) { + MessageView error = new MessageView(21090, LogCategorySet.GUI_LOG, Message.VALIDATION_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + session.setAttribute(SessionKeys.INPUT_LOGLEVEL, logInfo); + response.sendRedirect(pagetrans.sourceURI); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11479 LogLevelServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + /* + * choice button mode, commandExecute mode + */ + CommandExecuter thread = new CommandExecuter(session); + + String redirectPage; + ExecuteMode mode; + String button_mode = inputLogLevelMap.get("button"); + + // button mode : apply + if (button_mode != null && button_mode.equals(ButtonMode.APPLY)) { + mode = ExecuteMode.LOGLEVEL_CHANGE_APPLY; + redirectPage = RedirectPages.LOG_LEVEL_EXECUTIVE; + } + + // button mode : save + else if (button_mode != null && button_mode.equals(ButtonMode.SAVE)) { + mode = ExecuteMode.LOGLEVEL_CHANGE_SAVE; + redirectPage = RedirectPages.LOG_LEVEL_EXECUTIVE; + } + + // button mode : save and sync + else if (button_mode != null && button_mode.equals(ButtonMode.SAVESYNC)) { + mode = ExecuteMode.LOGLEVEL_CHANGE_SAVESYNC; + redirectPage = RedirectPages.SAVE_SYNC_EXECUTIVE; + } else { + MessageView error = new MessageView(41209, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11480 LogLevelServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + try { + thread.setExecute(mode, logInfo); + thread.start(); + } catch (Exception e) { + MessageView error = new MessageView(41210, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11481 LogLevelServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + response.sendRedirect(redirectPage); + + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11482 LogLevelServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + + } + + /** + * + *

levelCheck method

+ * + * @param level + * @return + */ + private LogData.LogLevel levelCheck(String level) { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + logger.debug("11483 LogLevelServlet::levelCheck(String level) in level=\"" + level + "\""); + } + // --- debug log (in method) --- + + LogData.LogLevel ret = null; + if (level == null) { + ret = null; + } else if (level.equals("NONE")) { + ret = LogData.LogLevel.NONE; + } else if (level.equals("DEBUG")) { + ret = LogData.LogLevel.DEBUG; + } else if (level.equals("ERROR")) { + ret = LogData.LogLevel.ERROR; + } else if (level.equals("WARN")) { + ret = LogData.LogLevel.WARN; + } else if (level.equals("FATAL")) { + ret = LogData.LogLevel.FATAL; + } else if (level.equals("INFO")) { + ret = LogData.LogLevel.INFO; + } + + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11484 LogLevelServlet::levelCheck(String level) out return=" + ret); + } + // --- debug log (out method) --- + return ret; + } + +} diff --git a/src/src/org/ultramonkey/l7/view/LogOutputServlet.java b/src/src/org/ultramonkey/l7/view/LogOutputServlet.java new file mode 100644 index 0000000..df750d6 --- /dev/null +++ b/src/src/org/ultramonkey/l7/view/LogOutputServlet.java @@ -0,0 +1,266 @@ +package org.ultramonkey.l7.view; + +import java.io.*; +import java.net.HttpURLConnection; +import java.net.SocketException; +import java.util.Enumeration; +import java.util.Vector; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.log4j.Logger; +import org.ultramonkey.l7.model.*; +import org.ultramonkey.l7.controller.*; + +/** + * + *

+ * class LogOutputServlet + *

+ *

+ * Copyright(c) NTT COMWARE 2008 + *

+ * + * @author kubota + */ +public class LogOutputServlet extends org.ultramonkey.l7.view.L7guiServletBase { + static final long serialVersionUID = 1L; + + private Logger logger = Logger.getLogger(LogCategorySet.GUI_IO); + + /* + * (non-Java-doc) + * + * @see javax.servlet.http.HttpServlet#HttpServlet() + */ + public LogOutputServlet() { + super(); + // --- debug log (constructor) --- + if (logger.isDebugEnabled()) { + logger.debug("11363 class LoginServlet created."); + } + // --- debug log (constructor) --- + } + + /* + * (non-Java-doc) + * + * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, + * HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, + HttpServletResponse response) throws ServletException, IOException { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("LogOutputServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in "); + buf.append("request=(" + request + "), "); + buf.append("response=(" + response + ")"); + logger.debug("11364 " + buf.toString()); + request.setCharacterEncoding("UTF-8"); + logger.debug("11365 QueryString=\"" + request.getQueryString() + "\""); + } + // --- debug log (in method) --- + + // check login session + super.doPost(request, response); + + HttpSession session = request.getSession(false); + if (login == false || session == null) { + if (session != null) { + MessageView error = new MessageView(41093, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + } + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11366 LogOutputServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + request.setCharacterEncoding("UTF-8"); + String logType = request.getParameter("type"); + String logFile = request.getParameter("log"); + + if (logType == null || logFile == null) { + MessageView error = new MessageView(41094, LogCategorySet.GUI_LOG, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11367 LogOutputServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + Vector logList = null; + + L7guiFramework frameWork = new L7guiFramework(); + LogData log = frameWork.getLogData(); + + try { + if (logType.equals(LogCategorySet.L7VSD)) { + logList = log.lbLog.logFiles; + } else if (logType.equals(LogCategorySet.L7VSADM)) { + logList = log.admLog.logFiles; + } else if (logType.equals(LogCategorySet.L7DIRECTORD)) { + logList = log.directorLog.logFiles; + } else if (logType.equals(LogCategorySet.SNMPAGENT)) { + logList = log.snmpLog.logFiles; + } else if (logType.equals(LogCategorySet.L7GUI)) { + logList = log.guiLog.logFiles; + } else if (logType.equals(LogCategorySet.SYNC)) { + logList = log.syncLog.logFiles; + } else if (logType.equals(LogCategorySet.HA)) { + logList = log.haLog.logFiles; + } else { + MessageView error = new MessageView(41095, LogCategorySet.GUI_LOG, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11368 LogOutputServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + } catch (NullPointerException e) { + MessageView error = new MessageView(41096, LogCategorySet.GUI_LOG, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11369 LogOutputServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + if (logList == null) { + MessageView error = new MessageView(41097, LogCategorySet.GUI_LOG, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11370 LogOutputServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + String dwLogFilePath = null; + boolean matchFlag = false; + + for (int i = 0; i < logList.size(); i++) { + if (logList.get(i).fileName.equals(logFile)) { + dwLogFilePath = logList.get(i).filePath; + matchFlag = true; + break; + } + } + if ((matchFlag == false) || (dwLogFilePath == null)) { + MessageView error = new MessageView(41098, LogCategorySet.GUI_LOG, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11371 LogOutputServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + // Log File DownLoad + File file = new File(dwLogFilePath); + BufferedInputStream in = null; + BufferedOutputStream out = null; + try { + // HTTP HEADER OUT + response.setContentType("application/octet-stream"); + response.setHeader("Content-Disposition", "attachment; filename=\"" + + file.getName() + "\""); + response.setContentLength((int) file.length()); + + in = new BufferedInputStream(new FileInputStream(file)); + out = new BufferedOutputStream(response.getOutputStream()); + + byte buf[] = new byte[1024]; + int len; + + while ((len = in.read(buf)) != -1) { + out.write(buf, 0, len); + } + } catch (SocketException e) { + // nothing to do + } catch (Exception e) { + // HTTP HEADER RESET + response.reset(); + response.sendError(HttpURLConnection.HTTP_INTERNAL_ERROR, e.toString()); + } finally { + if (in != null) { + in.close(); + } + if (out != null) { + out.flush(); + out.close(); + } + } + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11372 LogOutputServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + + } + + /* + * (non-Java-doc) + * + * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, + * HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, + HttpServletResponse response) throws ServletException, IOException { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("LogOutputServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in "); + buf.append("request=(" + request + "), "); + buf.append("response=(" + response + ")"); + logger.debug("11373 " + buf.toString()); + request.setCharacterEncoding("UTF-8"); + Enumeration keys = request.getParameterNames(); + String post = ""; + while (keys.hasMoreElements()) { + if (post.length() != 0) + post += "&"; + String key = (String) keys.nextElement(); + post += key + "=" + request.getParameter(key); + } + logger.debug("11374 PostData=\"" + post + "\""); + } + // --- debug log (in method) --- + + response.sendRedirect(RedirectPages.LOGIN); + + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11375 LogOutputServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } +} \ No newline at end of file diff --git a/src/src/org/ultramonkey/l7/view/LoginServlet.java b/src/src/org/ultramonkey/l7/view/LoginServlet.java new file mode 100644 index 0000000..a438779 --- /dev/null +++ b/src/src/org/ultramonkey/l7/view/LoginServlet.java @@ -0,0 +1,343 @@ +package org.ultramonkey.l7.view; + +import java.io.IOException; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import javax.servlet.*; +import javax.servlet.http.*; +import org.apache.log4j.Logger; +import org.ultramonkey.l7.model.*; +import org.ultramonkey.l7.controller.*; + +/** + * Servlet implementation class for Servlet: Login + * + */ +public final class LoginServlet extends L7guiServletBase implements Servlet { + static final long serialVersionUID = 1L; + + private Logger logger = Logger.getLogger(LogCategorySet.GUI_IO); + + /* + * (non-Java-doc) + * + * @see javax.servlet.http.HttpServlet#HttpServlet() + */ + public LoginServlet() { + super(); + // --- debug log (constructor) --- + if (logger.isDebugEnabled()) { + logger.debug("11279 class LoginServlet created."); + } + // --- debug log (constructor) --- + } + + /* + * (non-Java-doc) + * + * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, + * HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, + HttpServletResponse response) throws ServletException, IOException { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("LoginServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in "); + buf.append("request=(" + request + "), "); + buf.append("response=(" + response + ")"); + logger.debug("11280 " + buf.toString()); + request.setCharacterEncoding("UTF-8"); + logger.debug("11281 QueryString=\"" + request.getQueryString() + "\""); + } + // --- debug log (in method) --- + + response.sendRedirect(RedirectPages.LOGIN); + + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11282 LoginServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + /* + * (non-Java-doc) + * + * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, + * HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, + HttpServletResponse response) throws ServletException, IOException { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("LoginServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in "); + buf.append("request=(" + request + "), "); + buf.append("response=(" + response + ")"); + logger.debug("11283 " + buf.toString()); + request.setCharacterEncoding("UTF-8"); + Enumeration keys = request.getParameterNames(); + String post = ""; + while (keys.hasMoreElements()) { + if (post.length() != 0) + post += "&"; + String key = (String) keys.nextElement(); + post += key + "=" + request.getParameter(key); + } + logger.debug("11284 PostData=\"" + post + "\""); + } + // --- debug log (in method) --- + + boolean validationFlag = true; + HttpSession session = request.getSession(true); + if (session == null) { + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11285 LoginServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + request.setCharacterEncoding("UTF-8"); + String userName = request.getParameter("uid"); + String userPass = request.getParameter("passwd"); + + if ( (userName == null) || (userPass == null) ){ + MessageView error = new MessageView(41066, LogCategorySet.GUI_USER_MANAGE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11286 LoginServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + + // UserID,Password validationCheck + validationFlag = validationCheck(userName, userPass); + if (false == validationFlag) { + MessageView error = new MessageView(21039, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.USERID_PASSWORD_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11287 LoginServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + UserManager manager = UserManager.getInstance(); + if (manager == null) { + MessageView error = new MessageView(41067, LogCategorySet.GUI_START_STOP, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11288 LoginServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + UserData user = manager.authUser(userName, userPass); + if (user != null) { + Parameter param = Parameter.getInstance(); + if (param == null) { + MessageView error = new MessageView(41068, LogCategorySet.GUI_START_STOP, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11289 LoginServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + String sessionTimeout = param.getValue(Parameter.SESSION_TIMEOUT); + if (sessionTimeout != null) { + try{ + session.setMaxInactiveInterval(Integer + .parseInt(sessionTimeout)); + }catch(Exception e){ + MessageView error = new MessageView(41069, LogCategorySet.GUI_START_STOP, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11290 LoginServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + } + + session.setAttribute(SessionKeys.LOGIN_SESSION, user); + } else { + MessageView error = new MessageView(41070, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.USER_AUTH_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11291 LoginServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + // Session Key Initialize + session.setAttribute(SessionKeys.LOG_SYNC_STATE, SessionKeys.SYNC); + session.setAttribute(SessionKeys.VS_SYNC_STATE, SessionKeys.SYNC); + session.setAttribute(SessionKeys.MONITOR_SYNC_STATE, SessionKeys.SYNC); + session.setAttribute(SessionKeys.REP_SYNC_STATE, SessionKeys.SYNC); + session.setAttribute(SessionKeys.SNMP_SYNC_STATE, SessionKeys.SYNC); + session.setAttribute(SessionKeys.GUI_SYNC_STATE, SessionKeys.SYNC); + + // Get Data + L7guiFramework framework = new L7guiFramework(); + L7vsAdmData admDataList = framework.getAdmData(); + DirectorData directorData = framework.getDirectorData(); + L7vsConfData confData = framework.getL7vsConfData(); + + + if (admDataList == null || directorData == null || confData == null) { + MessageView error = new MessageView(41071, LogCategorySet.GUI_IO, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11292 LoginServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + boolean vsSave = false; + if (admDataList.virtualSettings.size() == directorData.virtualSettings.size()) { + for (int i = 0; i < admDataList.virtualSettings.size(); i++) { + VirtualSetting admVs = admDataList.virtualSettings.elementAt(i); + for (int j = 0; j < directorData.virtualSettings.size(); j++) { + VirtualSetting directorVs = directorData.virtualSettings.elementAt(j); + if (vsSave = directorVs.equalsAdm(admVs)) + break; + } + if (vsSave == false) + break; + } + if (admDataList.virtualSettings.size() == 0) + vsSave = true; + } + if (vsSave == true) { + session.setAttribute(SessionKeys.VS_SAVE_STATE, SessionKeys.SAVE); + } else { + session.setAttribute(SessionKeys.VS_SAVE_STATE, SessionKeys.NO_SAVE); + } + + try{ + boolean logL7vsdSave = true; + boolean logSnmpSave = true; + + // l7vsdLog compare + HashMap admL7vsdLogLevel = admDataList.l7vsdLogLevel; + HashMap confL7vsdLogLevel = confData.logger.lbLog.logLevel; + logL7vsdSave = admL7vsdLogLevel.equals(confL7vsdLogLevel); + + // SNMPLog compare + HashMap admSnmpLogLevel = admDataList.snmpLogLevel; + HashMap confSnmpLogLevel = confData.logger.snmpLog.logLevel; + logSnmpSave = admSnmpLogLevel.equals(confSnmpLogLevel); + + // compare logData + if ((logL7vsdSave == true) && (logSnmpSave == true)) { + session.setAttribute(SessionKeys.LOG_SAVE_STATE, SessionKeys.SAVE); + } else { + session.setAttribute(SessionKeys.LOG_SAVE_STATE, + SessionKeys.NO_SAVE); + } + }catch(NullPointerException e){ + MessageView error = new MessageView(41072, LogCategorySet.GUI_USER_MANAGE, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11293 LoginServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + response.sendRedirect(RedirectPages.TOPMENU); + + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11294 LoginServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + /** + * + *

+ * validationCheck method + *

+ * + * @param userName + * @param userPass + * @return validationFlag : true/false + */ + private boolean validationCheck(String userName, String userPass) { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("LoginServlet::validationCheck(String userName, String userPass) in "); + buf.append("userName=\"" + userName + "\", "); + buf.append("userPass=\"" + userPass + "\""); + logger.debug("11295 " + buf.toString()); + } + // --- debug log (in method) --- + + boolean validationFlag = true; + final int MIN_LENGTH = 1; + final int MAX_LENGTH = 16; + final int MIN_PASS_LENGTH = 6; + + if ((userName.length() < MIN_LENGTH) + || (userName.length() > MAX_LENGTH)) { + validationFlag = false; + } else if ((userPass.length() < MIN_PASS_LENGTH) + || (userPass.length() > MAX_LENGTH)) { + validationFlag = false; + } + + else { + Pattern pattern = Pattern.compile("([^\\x20-\\x7e])"); + Matcher userNameMatcher = pattern.matcher(userName); + Matcher userPassMatcher = pattern.matcher(userPass); + + if (userNameMatcher.find() || userPassMatcher.find()) { + validationFlag = false; + } + } + + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11296 LoginServlet::validationCheck(String userName, String userPass) out return=" + validationFlag); + } + // --- debug log (in method) --- + return validationFlag; + } + +} diff --git a/src/src/org/ultramonkey/l7/view/MonitorSetServlet.java b/src/src/org/ultramonkey/l7/view/MonitorSetServlet.java new file mode 100644 index 0000000..0fdc56b --- /dev/null +++ b/src/src/org/ultramonkey/l7/view/MonitorSetServlet.java @@ -0,0 +1,460 @@ +package org.ultramonkey.l7.view; + +import java.io.IOException; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.servlet.*; +import javax.servlet.http.*; + +import org.apache.log4j.Logger; +import org.ultramonkey.l7.controller.*; +import org.ultramonkey.l7.model.*; + +/** + *

+ * class MonitorSetServlet + *

+ *

+ * Copyright(c) NTT COMWARE 2008 + *

+ *

+ * Servlet implementation class for Servlet: MonitorSet + *

+ * + * @author tsubone + */ +public class MonitorSetServlet extends L7guiServletBase { + static final long serialVersionUID = 1L; + + private Logger logger = Logger.getLogger(LogCategorySet.GUI_IO); + + /* + * (non-Java-doc) + * + * @see javax.servlet.http.HttpServlet#HttpServlet() + */ + public MonitorSetServlet() { + super(); + // --- debug log (constructor) --- + if (logger.isDebugEnabled()) { + logger.debug("11485 class MonitorSetServlet created."); + } + // --- debug log (constructor) --- + } + + /* + * (non-Java-doc) + * + * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, + * HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, + HttpServletResponse response) throws ServletException, IOException { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("MonitorServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in "); + buf.append("request=(" + request + "), "); + buf.append("response=(" + response + ")"); + logger.debug("11486 " + buf.toString()); + request.setCharacterEncoding("UTF-8"); + logger.debug("11487 QueryString=\"" + request.getQueryString() + "\""); + } + // --- debug log (in method) --- + + response.sendRedirect(RedirectPages.LOGIN); + + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger + .debug("11488 MonitorServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + /* + * (non-Java-doc) + * + * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, + * HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, + HttpServletResponse response) throws ServletException, IOException { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("MonitorServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in "); + buf.append("request=(" + request + "), "); + buf.append("response=(" + response + ")"); + logger.debug("11489 " + buf.toString()); + request.setCharacterEncoding("UTF-8"); + Enumeration keys = request.getParameterNames(); + String post = ""; + while (keys.hasMoreElements()) { + if (post.length() != 0) + post += "&"; + String key = (String) keys.nextElement(); + post += key + "=" + request.getParameter(key); + } + logger.debug("11490 PostData=\"" + post + "\""); + } + // --- debug log (in method) --- + + /* + * check login session + */ + super.doPost(request, response); + + HttpSession session = request.getSession(false); + if (login == false || session == null) { + if (session != null) { + MessageView error = new MessageView(41211, + LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + } + response.sendRedirect(RedirectPages.LOGIN); + + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger + .debug("11491 MonitorServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + /* + * get MonitorInfo + */ + request.setCharacterEncoding("UTF-8"); + HashMap tmpMap = (HashMap) request + .getParameterMap(); + if (tmpMap == null) { + MessageView error = new MessageView(41212, LogCategorySet.GUI_IO_FILE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger + .debug("11492 MonitorServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + HashMap inputMonitorMap = new HashMap(); + Iterator i = tmpMap.keySet().iterator(); + while (i.hasNext()) { + String key = (String) i.next(); + inputMonitorMap.put(key, tmpMap.get(key)[0]); + } + + L7guiFramework frame = new L7guiFramework(); + DirectorData monitorInfo = frame.getDirectorData(); + + if (monitorInfo == null) { + MessageView error = new MessageView(41213, LogCategorySet.GUI_IO_FILE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger + .debug("11493 MonitorServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + /* + * validation check + */ + boolean validationFlag = true; + HashMap invalidMap = new HashMap(); + + validationFlag = validationCheck(inputMonitorMap, invalidMap, + monitorInfo); + + if (validationFlag == false) { + MessageView error = new MessageView(21091, LogCategorySet.GUI_MONITOR, + Message.VALIDATION_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + session.setAttribute(SessionKeys.INPUT_MONITOR, monitorInfo); + session.setAttribute(SessionKeys.INVALID_MESSAGE, invalidMap); + + response.sendRedirect(RedirectPages.MONITOR_MODIFY); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger + .debug("11494 MonitorServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + /* + * choice button mode, commandExecute mode + */ + CommandExecuter thread = new CommandExecuter(session); + + ExecuteMode mode; + String redirectPage; + + String button_mode = inputMonitorMap.get("button"); + + // button mode : save + if (button_mode != null && button_mode.equals(ButtonMode.SAVE)) { + mode = ExecuteMode.DIRECTOR_SAVE; + redirectPage = RedirectPages.MONITOR_MODIFY_EXECUTIVE; + } + + // button mode : save and sync + else if (button_mode != null && button_mode.equals(ButtonMode.SAVESYNC)) { + mode = ExecuteMode.DIRECTOR_SAVESYNC; + redirectPage = RedirectPages.SAVE_SYNC_EXECUTIVE; + + SessionTransData trans = new SessionTransData(); + trans.sourceURI = RedirectPages.MONITOR_MODIFY; + trans.destURI = RedirectPages.MONITOR_INFO; + trans.errorURI = RedirectPages.MONITOR_MODIFY_NG; + session.setAttribute(SessionKeys.PAGE_TRANSDATA, trans); + } else { + MessageView error = new MessageView(41214, LogCategorySet.GUI_MONITOR, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger + .debug("11495 MonitorServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + try { + thread.setExecute(mode, monitorInfo); + thread.start(); + } catch (Exception e) { + MessageView error = new MessageView(41215, LogCategorySet.GUI_MONITOR, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger + .debug("11496 MonitorServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + response.sendRedirect(redirectPage); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger + .debug("11497 MonitorServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + /** + * + *

+ * validationCheck method + *

+ * + * @param inputMonitorMap + * @param invalidMap + * @param monitorInfo + * @return + */ + + protected boolean validationCheck(HashMap inputMonitorMap, + HashMap invalidMap, DirectorData monitorInfo) { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf + .append("MonitorSetServlet::validationCheck(HashMap inputMonitorMap, HashMap invalidMap, DirectorData monitorInfo) in "); + buf.append("inputMonitorMap=(" + inputMonitorMap + "), "); + buf.append("invalidMap=(" + invalidMap + "), "); + buf.append("monitorInfo=(" + monitorInfo + ")"); + logger.debug("11498 " + buf.toString()); + } + // --- debug log (in method) --- + + boolean validationFrag = true; + + final int MIN_CHECK_TIME_OUT = 1; + final int MAX_CHECK_TIME_OUT = Integer.MAX_VALUE; + final int MIN_NEGOTIATE_TIME_OUT = 1; + final int MAX_NEGOTIATE_TIME_OUT = Integer.MAX_VALUE; + final int MIN_CHECK_INTERVAL = 1; + final int MAX_CHECK_INTERVAL = Integer.MAX_VALUE; + final int MIN_CHECK_COUNT = 1; + final int MAX_CHECK_COUNT = Integer.MAX_VALUE; + final int CALLBACK_LENGTH = 127; + final int FALLBACK_LENGTH = 127; + final int LOGFILE_LENGTH = 127; + final int EXECUTE_LENGTH = 127; + + // checkTimeOut validationCheck + String checkTimeOut = inputMonitorMap.get("checkTimeOut"); + if (checkTimeOut != null && checkTimeOut.length() > 0) { + int int_checkTimeOut = 0; + try { + int_checkTimeOut = Integer.parseInt(checkTimeOut); + if ((int_checkTimeOut < MIN_CHECK_TIME_OUT) + || (int_checkTimeOut > MAX_CHECK_TIME_OUT)) { + invalidMap.put("checkTimeOut", Message.INVALID_VALUE); + validationFrag = false; + } + } catch (NumberFormatException e) { + invalidMap.put("checkTimeOut", Message.INVALID_VALUE); + validationFrag = false; + } + } + monitorInfo.checkTimeOut = checkTimeOut; + + // negotiateTimeOut validationCheck + String negotiateTimeOut = inputMonitorMap.get("negotiateTimeOut"); + if (negotiateTimeOut != null && negotiateTimeOut.length() > 0) { + int int_negotiateTimeOut = 0; + try { + int_negotiateTimeOut = Integer.parseInt(negotiateTimeOut); + if ((int_negotiateTimeOut < MIN_NEGOTIATE_TIME_OUT) + || (int_negotiateTimeOut > MAX_NEGOTIATE_TIME_OUT)) { + invalidMap.put("negotiateTimeOut", Message.INVALID_VALUE); + validationFrag = false; + } + } catch (NumberFormatException e) { + invalidMap.put("negotiateTimeOut", Message.INVALID_VALUE); + validationFrag = false; + } + } + monitorInfo.negotiateTimeOut = negotiateTimeOut; + + // CheckInterval validationCheck + String checkInterval = inputMonitorMap.get("checkInterval"); + if (checkInterval != null && checkInterval.length() > 0) { + int int_checkInterval = 0; + try { + int_checkInterval = Integer.parseInt(checkInterval); + if ((int_checkInterval < MIN_CHECK_INTERVAL) + || (int_checkInterval > MAX_CHECK_INTERVAL)) { + invalidMap.put("checkInterval", Message.INVALID_VALUE); + validationFrag = false; + } + } catch (NumberFormatException e) { + invalidMap.put("checkInterval", Message.INVALID_VALUE); + validationFrag = false; + } + } + monitorInfo.checkInterval = checkInterval; + + // checkCount validationCheck + String checkCount = inputMonitorMap.get("checkCount"); + if (checkCount != null && checkCount.length() > 0) { + int int_checkCount = 0; + try { + int_checkCount = Integer.parseInt(checkCount); + if ((int_checkCount < MIN_CHECK_COUNT) + || (int_checkCount > MAX_CHECK_COUNT)) { + invalidMap.put("checkCount", Message.INVALID_VALUE); + validationFrag = false; + } + } catch (NumberFormatException e) { + invalidMap.put("checkCount", Message.INVALID_VALUE); + validationFrag = false; + } + } + monitorInfo.checkCount = checkCount; + + // callback validationCheck + String callback = inputMonitorMap.get("callback"); + if (callback != null && callback.length() > 0) { + Pattern pattern = Pattern.compile("[^\\x20-\\x7e]"); + Matcher matcher = pattern.matcher(callback); + + if (callback.length() > CALLBACK_LENGTH || matcher.find()) { + invalidMap.put("callback", Message.INVALID_VALUE); + validationFrag = false; + } + } + monitorInfo.callback = callback; + + // fallback validationCheck + String fallback = inputMonitorMap.get("fallback"); + if (fallback != null && fallback.length() > 0) { + Pattern pattern = Pattern.compile("[^\\x20-\\x7e]"); + Matcher matcher = pattern.matcher(fallback); + + if (fallback.length() > FALLBACK_LENGTH || matcher.find()) { + invalidMap.put("fallback", Message.INVALID_VALUE); + validationFrag = false; + } + } + monitorInfo.fallback = fallback; + + // logfile validationCheck + String logfile = inputMonitorMap.get("logfile"); + if (logfile != null && logfile.length() > 0) { + Pattern pattern = Pattern.compile("[^\\x20-\\x7e]"); + Matcher matcher = pattern.matcher(logfile); + + if (logfile.length() > LOGFILE_LENGTH || matcher.find()) { + invalidMap.put("logfile", Message.INVALID_VALUE); + validationFrag = false; + } + } + monitorInfo.logfile = logfile; + + // execute validationCheck + String execute = inputMonitorMap.get("execute"); + if (execute != null && execute.length() > 0) { + Pattern pattern = Pattern.compile("[^\\x20-\\x7e]"); + Matcher matcher = pattern.matcher(execute); + + if (execute.length() > EXECUTE_LENGTH || matcher.find()) { + invalidMap.put("execute", Message.INVALID_VALUE); + validationFrag = false; + } + } + monitorInfo.execute = execute; + + // supervised validationCheck + String supervised = inputMonitorMap.get("supervised"); + if (supervised != null && supervised.length() > 0) { + if (!supervised.equals("yes") && !supervised.equals("no")) { + invalidMap.put("supervised", Message.INVALID_VALUE); + validationFrag = false; + } + } + monitorInfo.supervised = supervised; + + // quiescent validationCheck + String quiescent = inputMonitorMap.get("quiescent"); + if (quiescent != null && quiescent.length() > 0) { + if (!quiescent.equals("yes") && !quiescent.equals("no")) { + invalidMap.put("quiescent", Message.INVALID_VALUE); + validationFrag = false; + } + } + monitorInfo.quiescent = quiescent; + + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11499 MonitorSetServlet::validationCheck(HashMap inputMonitorMap, HashMap invalidMap, DirectorData monitorInfo) return=" + validationFrag); + } + // --- debug log (out method) --- + return validationFrag; + } + +} diff --git a/src/src/org/ultramonkey/l7/view/RedirectPages.java b/src/src/org/ultramonkey/l7/view/RedirectPages.java new file mode 100644 index 0000000..477d94d --- /dev/null +++ b/src/src/org/ultramonkey/l7/view/RedirectPages.java @@ -0,0 +1,110 @@ +package org.ultramonkey.l7.view; + +public interface RedirectPages { + public static final String REFRESH_TIME = "3"; + + public static final String NOSCRIPT_TIME = "0"; + + public static final String LOGIN = "index.jsp"; + + public static final String TOPMENU = "top.jsp"; + + public static final String STATE_INFO = "um7state_info.jsp"; + + public static final String VS_ADD = "vs_add.jsp"; + + public static final String VS_ADD_NG = "vs_add_fail.jsp"; + + public static final String VS_ADD_EXECUTIVE = "vs_add_executive.jsp"; + + public static final String VS_MODIFY = "vs_modify.jsp"; + + public static final String VS_MODIFY_EXECUTIVE = "vs_modify_executive.jsp"; + + public static final String VS_MODIFY_NG = "vs_modify_fail.jsp"; + + public static final String VS_REMOVE_SUCCESS = "vs_remove.jsp"; + + public static final String VS_REMOVE_NG = "vs_remove_fail.jsp"; + + public static final String VS_REMOVE_EXECUTIVE = "vs_remove_executive.jsp"; + + public static final String LOG_LEVEL_EXECUTIVE = "log_level_executive.jsp"; + + public static final String LOG_L7VSD = "log_lb.jsp"; + + public static final String LOG_L7VSADM = "log_adm.jsp"; + + public static final String LOG_SNMPAGENT = "log_snmp.jsp"; + + public static final String LOG_L7GUI = "log_gui.jsp"; + + public static final String LOG_SYNC = "log_sync.jsp"; + + public static final String MONITOR_INFO = "monitor_info.jsp"; + + public static final String MONITOR_MODIFY = "monitor_modify.jsp"; + + public static final String MONITOR_MODIFY_EXECUTIVE = "monitor_modify_executive.jsp"; + + public static final String MONITOR_MODIFY_NG = "monitor_modify_fail.jsp"; + + public static final String SAVE_SYNC_EXECUTIVE = "savesync_executive.jsp"; + + public static final String SNMP_MODIFY = "snmp.jsp"; + + public static final String SNMP_MODIFY_EXECUTIVE = "snmp_modify_executive.jsp"; + + public static final String SNMP_MODIFY_NG = "snmp_modify_fail.jsp"; + + public static final String REPLICATION_INFO = "replication.jsp"; + + public static final String REPLICATION_MODIFY = "replication_modify.jsp"; + + public static final String REPLICATION_INFO_EXECUTIVE = "replication_modify_executive.jsp"; + + public static final String REPLICATION_MODIFY_NG = "replication_modify_fail.jsp"; + + public static final String REPLICATION_MODE_NG = "replication_mode_fail.jsp"; + + public static final String REPLICATION_MODE_EXECUTIVE = "replication_mode_executive.jsp"; + + public static final String REPLICATION_NG = "replication_fail.jsp"; + + public static final String REPLICATION_EXECUTIVE = "replication_executive.jsp"; + + public static final String SO_OK = "so_success.jsp"; + + public static final String SO_NG = "so_fail.jsp"; + + public static final String SO_EXECUTIVE = "so_executive.jsp"; + + public static final String SYNC = "sync.jsp"; + + public static final String SYNC_EXECUTIVE = "sync_executive.jsp"; + + public static final String SYNC_NG = "sync_fail.jsp"; + + public static final String USER_MODIFY = "user_modify.jsp"; + + /** + * @deprecated {@link #USER_MODIFY} �̑�p + */ + public static final String PW_CHANGE = USER_MODIFY; + + public static final String USER_MODIFY_SUCCESS = "user_modify_success.jsp"; + + public static final String USER_MODIFY_FAIL = "user_modify_fail.jsp"; + + public static final String USER_ADD = "user_add.jsp"; + + public static final String USER_MANAGE = "user_manage.jsp"; + + public static final String USER_ADD_FAIL = "user_add_fail.jsp"; + + public static final String USER_DELETE_FAIL = "user_delete_fail.jsp"; + + public static final String SAVE = "save.jsp"; + + public static final String SAVE_FAIL = "save_fail.jsp"; +} diff --git a/src/src/org/ultramonkey/l7/view/ReplicationInfoChangeServlet.java b/src/src/org/ultramonkey/l7/view/ReplicationInfoChangeServlet.java new file mode 100644 index 0000000..8186d39 --- /dev/null +++ b/src/src/org/ultramonkey/l7/view/ReplicationInfoChangeServlet.java @@ -0,0 +1,274 @@ +package org.ultramonkey.l7.view; + +import java.io.IOException; +import java.util.Enumeration; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.log4j.Logger; +import org.ultramonkey.l7.model.ExecuteMode; +import org.ultramonkey.l7.model.L7guiFramework; +import org.ultramonkey.l7.model.LogCategorySet; +import org.ultramonkey.l7.model.Message; +import org.ultramonkey.l7.model.MessageView; +import org.ultramonkey.l7.model.SessionTransData; +import org.ultramonkey.l7.controller.*; + + +/** + * + *

class ReplicationInfoChangeServlet

+ *

Copyright(c) NTT COMWARE 2008

+ * @author kubota + */ + +public class ReplicationInfoChangeServlet extends org.ultramonkey.l7.view.L7guiServletBase{ + static final long serialVersionUID = 1L; + + private Logger logger = Logger.getLogger(LogCategorySet.GUI_IO); + + /* (non-Java-doc) + * @see javax.servlet.http.HttpServlet#HttpServlet() + */ + public ReplicationInfoChangeServlet() { + super(); + // --- debug log (constructor) --- + if (logger.isDebugEnabled()) { + logger.debug("11297 class ReplicationInfoChangeServlet created."); + } + // --- debug log (constructor) --- + } + + /* (non-Java-doc) + * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("ReplicationInfoChangeServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in "); + buf.append("request=(" + request + "), "); + buf.append("response=(" + response + ")"); + logger.debug("11298 " + buf.toString()); + request.setCharacterEncoding("UTF-8"); + logger.debug("11299 QueryString=\"" + request.getQueryString() + "\""); + } + // --- debug log (in method) --- + + response.sendRedirect(RedirectPages.LOGIN); + + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11300 ReplicationInfoChangeServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + + /* (non-Java-doc) + * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("ReplicationInfoChangeServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in "); + buf.append("request=(" + request + "), "); + buf.append("response=(" + response + ")"); + logger.debug("11301 " + buf.toString()); + request.setCharacterEncoding("UTF-8"); + Enumeration keys = request.getParameterNames(); + String post = ""; + while (keys.hasMoreElements()) { + if (post.length() != 0) + post += "&"; + String key = (String) keys.nextElement(); + post += key + "=" + request.getParameter(key); + } + logger.debug("11302 PostData=\"" + post + "\""); + } + // --- debug log (in method) --- + + // check login session + super.doPost(request, response); + + HttpSession session = request.getSession(false); + if (login == false || session == null) { + if (session != null) { + MessageView error = new MessageView(41073, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + } + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11303 ReplicationInfoChangeServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + L7guiFramework framework = new L7guiFramework(); + ReplicationData rep = framework.getReplicationData(); + if ( rep == null ){ + MessageView error = new MessageView(41074, LogCategorySet.GUI_IO_FILE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11304 ReplicationInfoChangeServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + request.setCharacterEncoding("UTF-8"); + String str_repInterval = request.getParameter("rep_interval"); + String str_beforeRepData = Integer.toString(rep.interval); + + boolean validationFrag = validationCheck(session, str_repInterval, rep); + if (validationFrag == false ){ + session.setAttribute(SessionKeys.INPUT_REP, rep); + MessageView error = new MessageView(21040, LogCategorySet.GUI_REPLICATION, + Message.INVALID_VALUE); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.REPLICATION_MODIFY); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11305 ReplicationInfoChangeServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + CommandExecuter thread = new CommandExecuter(session); + + ExecuteMode mode; + String redirectPage; + + String button_mode = request.getParameter("button"); + + // button mode : save + if (button_mode != null && button_mode.equals(ButtonMode.SAVE)) { + mode = ExecuteMode.REP_INFO_SAVE; + redirectPage = RedirectPages.REPLICATION_INFO_EXECUTIVE; + } + // button mode : save and sync + else if (button_mode != null && button_mode.equals(ButtonMode.SAVESYNC)) { + mode = ExecuteMode.REP_INFO_SAVESYNC; + redirectPage = RedirectPages.SAVE_SYNC_EXECUTIVE; + + SessionTransData trans = new SessionTransData(); + trans.sourceURI = RedirectPages.REPLICATION_MODIFY; + trans.destURI = RedirectPages.REPLICATION_INFO; + trans.errorURI = RedirectPages.REPLICATION_MODIFY_NG; + session.setAttribute(SessionKeys.PAGE_TRANSDATA, trans); + } + else { + MessageView error = new MessageView(41075, LogCategorySet.GUI_REPLICATION, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11306 ReplicationInfoChangeServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + try { + thread.setExecute(mode, rep); + thread.start(); + } + catch(Exception e) + { + MessageView error = new MessageView(41076, LogCategorySet.GUI_REPLICATION, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11307 ReplicationInfoChangeServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + session.setAttribute(SessionKeys.BEFORE_REP_TIME, str_beforeRepData); + String str_afterRepData = Integer.toString(rep.interval); + session.setAttribute(SessionKeys.AFTER_REP_TIME, str_afterRepData); + response.sendRedirect(redirectPage); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11308 ReplicationInfoChangeServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + /** + * + *

validationCheck method

+ * + * @param session + * @param str_repInterval + * @param rep + * @return + */ + protected boolean validationCheck(HttpSession session, String str_repInterval, ReplicationData rep ){ + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("ReplicationInfoChangeServlet::validationCheck(HttpSession session, String str_repInterval, ReplicationData rep) in "); + buf.append("session=(" + session + "), "); + buf.append("str_repInterval=(" + str_repInterval + "), "); + buf.append("rep=(" + rep + ")"); + logger.debug("11309 " + buf.toString()); + } + // --- debug log (in method) --- + + boolean validationFlag = true; + + final int MIN_REP_INTERVAL = 10; + final int MAX_REP_INTERVAL = 10000; + int repInterval = 0; + + if (session == null || rep == null) { + validationFlag = false; + } else if ( (str_repInterval == null) || str_repInterval.length() == 0){ + session.setAttribute(SessionKeys.INVALID_MESSAGE, Message.REQUIED_ITEM); + validationFlag = false; + } + else { + try { + repInterval = Integer.parseInt(str_repInterval); + if ( (repInterval < MIN_REP_INTERVAL) || (repInterval > MAX_REP_INTERVAL) ) { + session.setAttribute(SessionKeys.INVALID_MESSAGE, Message.VALIDATION_ERROR); + validationFlag = false; + } else { + rep.interval = repInterval; + } + } + catch (NumberFormatException e) { + session.setAttribute(SessionKeys.INVALID_MESSAGE, Message.VALIDATION_ERROR); + validationFlag = false; + } + } + + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11310 ReplicationInfoChangeServlet::validationCheck(HttpSession session, String str_repInterval, ReplicationData rep) out return=" + validationFlag); + } + // --- debug log (out method) --- + return validationFlag; + } +} \ No newline at end of file diff --git a/src/src/org/ultramonkey/l7/view/ReplicationModeChangeServlet.java b/src/src/org/ultramonkey/l7/view/ReplicationModeChangeServlet.java new file mode 100644 index 0000000..e96cd19 --- /dev/null +++ b/src/src/org/ultramonkey/l7/view/ReplicationModeChangeServlet.java @@ -0,0 +1,167 @@ +package org.ultramonkey.l7.view; + +import java.io.IOException; +import java.util.Enumeration; + +import javax.servlet.*; +import javax.servlet.http.*; + +import org.apache.log4j.Logger; +import org.ultramonkey.l7.model.*; + +/** + * Servlet implementation class for Servlet: ReplicationModeChangeServlet + * + */ + +public class ReplicationModeChangeServlet extends L7guiServletBase { + static final long serialVersionUID = 1L; + + private Logger logger = Logger.getLogger(LogCategorySet.GUI_IO); + + /* (non-Java-doc) + * @see javax.servlet.http.HttpServlet#HttpServlet() + */ + public ReplicationModeChangeServlet() { + super(); + // --- debug log (constructor) --- + if (logger.isDebugEnabled()) { + logger.debug("11389 class ReplicationModeChangeServlet created."); + } + // --- debug log (constructor) --- + } + + /* (non-Java-doc) + * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("ReplicationModeChangeServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in "); + buf.append("request=(" + request + "), "); + buf.append("response=(" + response + ")"); + logger.debug("11390 " + buf.toString()); + request.setCharacterEncoding("UTF-8"); + logger.debug("11391 QueryString=\"" + request.getQueryString() + "\""); + } + // --- debug log (in method) --- + + response.sendRedirect(RedirectPages.LOGIN); + + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11392 ReplicationModeChangeServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + /* (non-Java-doc) + * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("ReplicationModeChangeServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in "); + buf.append("request=(" + request + "), "); + buf.append("response=(" + response + ")"); + logger.debug("11393 " + buf.toString()); + request.setCharacterEncoding("UTF-8"); + Enumeration keys = request.getParameterNames(); + String post = ""; + while (keys.hasMoreElements()) { + if (post.length() != 0) + post += "&"; + String key = (String) keys.nextElement(); + post += key + "=" + request.getParameter(key); + } + logger.debug("11394 PostData=\"" + post + "\""); + } + // --- debug log (in method) --- + + // check login session + super.doPost(request, response); + + HttpSession session = request.getSession(false); + if (login == false || session == null) { + if (session != null) { + MessageView error = new MessageView(41174, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + } + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11395 ReplicationModeChangeServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + ExecuteMode mode; + request.setCharacterEncoding("UTF-8"); + String buttonMode = request.getParameter("button"); + if (buttonMode == null){ + MessageView error = new MessageView(41175, LogCategorySet.GUI_REPLICATION, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11396 ReplicationModeChangeServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + if (buttonMode.equals(ButtonMode.REP_MASTER_RUNNING)) + mode = ExecuteMode.REP_MASTER; + else if (buttonMode.equals(ButtonMode.REP_MASTER_STOPPING)) + mode = ExecuteMode.REP_MASTER_STOP; + else if (buttonMode.equals(ButtonMode.REP_SLAVE_RUNNING)) + mode = ExecuteMode.REP_SLAVE; + else if (buttonMode.equals(ButtonMode.REP_SLAVE_STOPPING)) + mode = ExecuteMode.REP_SLAVE_STOP; + else{ + MessageView error = new MessageView(41176, LogCategorySet.GUI_REPLICATION, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11397 ReplicationModeChangeServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + CommandExecuter thread = new CommandExecuter(session); + try { + thread.setExecute(mode); + thread.start(); + } + catch(Exception e) { + MessageView error = new MessageView(41177, LogCategorySet.GUI_REPLICATION, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11398 ReplicationModeChangeServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + response.sendRedirect(RedirectPages.REPLICATION_MODE_EXECUTIVE); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11399 ReplicationModeChangeServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } +} diff --git a/src/src/org/ultramonkey/l7/view/ReplicationRunServlet.java b/src/src/org/ultramonkey/l7/view/ReplicationRunServlet.java new file mode 100644 index 0000000..8609b8f --- /dev/null +++ b/src/src/org/ultramonkey/l7/view/ReplicationRunServlet.java @@ -0,0 +1,151 @@ +package org.ultramonkey.l7.view; + +import java.io.IOException; +import java.util.Enumeration; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.log4j.Logger; +import org.ultramonkey.l7.model.ExecuteMode; +import org.ultramonkey.l7.model.LogCategorySet; +import org.ultramonkey.l7.model.Message; +import org.ultramonkey.l7.model.MessageView; + +/** + * Servlet implementation class for Servlet: ReplicationRunServlet + * + */ + public class ReplicationRunServlet extends L7guiServletBase { + static final long serialVersionUID = 1L; + + private Logger logger = Logger.getLogger(LogCategorySet.GUI_IO); + + /* (non-Java-doc) + * @see javax.servlet.http.HttpServlet#HttpServlet() + */ + public ReplicationRunServlet() { + super(); + // --- debug log (constructor) --- + if (logger.isDebugEnabled()) { + logger.debug("11457 class ReplicationRunServlet created."); + } + // --- debug log (constructor) --- + } + + /* (non-Java-doc) + * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("ReplicationRunServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in "); + buf.append("request=(" + request + "), "); + buf.append("response=(" + response + ")"); + logger.debug("11458 " + buf.toString()); + request.setCharacterEncoding("UTF-8"); + logger.debug("11459 QueryString=\"" + request.getQueryString() + "\""); + } + // --- debug log (in method) --- + + response.sendRedirect(RedirectPages.LOGIN); + + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11460 ReplicationRunServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + /* (non-Java-doc) + * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("ReplicationRunServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in "); + buf.append("request=(" + request + "), "); + buf.append("response=(" + response + ")"); + logger.debug("11461 " + buf.toString()); + request.setCharacterEncoding("UTF-8"); + Enumeration keys = request.getParameterNames(); + String post = ""; + while (keys.hasMoreElements()) { + if (post.length() != 0) + post += "&"; + String key = (String) keys.nextElement(); + post += key + "=" + request.getParameter(key); + } + logger.debug("11462 PostData=\"" + post + "\""); + } + // --- debug log (in method) --- + + // check login session + super.doPost(request, response); + + HttpSession session = request.getSession(false); + if (login == false || session == null) { + if (session != null) { + MessageView error = new MessageView(41200, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + } + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11463 ReplicationRunServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + request.setCharacterEncoding("UTF-8"); + String buttonMode = request.getParameter("button_immediate"); + if ((buttonMode != null) && (buttonMode.equals(ButtonMode.REP_EXECUTE))) { + CommandExecuter thread = new CommandExecuter(session); + try { + thread.setExecute(ExecuteMode.REP_START); + thread.start(); + } + catch(Exception e) { + MessageView error = new MessageView(41201, LogCategorySet.GUI_REPLICATION, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11464 ReplicationRunServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + } + else { + MessageView error = new MessageView(41202, LogCategorySet.GUI_REPLICATION, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11465 ReplicationRunServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + response.sendRedirect(RedirectPages.REPLICATION_EXECUTIVE); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11466 ReplicationRunServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } +} diff --git a/src/src/org/ultramonkey/l7/view/SaveStateServlet.java b/src/src/org/ultramonkey/l7/view/SaveStateServlet.java new file mode 100644 index 0000000..d9f2500 --- /dev/null +++ b/src/src/org/ultramonkey/l7/view/SaveStateServlet.java @@ -0,0 +1,253 @@ +package org.ultramonkey.l7.view; + +import java.io.IOException; +import java.util.Enumeration; +import java.util.HashSet; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.log4j.Logger; +import org.ultramonkey.l7.model.L7guiFramework; +import org.ultramonkey.l7.model.LogCategorySet; +import org.ultramonkey.l7.model.Message; +import org.ultramonkey.l7.model.MessageView; +import org.ultramonkey.l7.model.SaveCategoryIdSet; + +/** + * Servlet implementation class for Servlet: SaveStateServlet + * + */ +public class SaveStateServlet extends org.ultramonkey.l7.view.L7guiServletBase { + static final long serialVersionUID = 1L; + + private Logger logger = Logger.getLogger(LogCategorySet.GUI_IO); + + private enum status { + NO_SAVE, SAVE_OK, SAVE_NG + } + + /* + * (non-Java-doc) + * + * @see javax.servlet.http.HttpServlet#HttpServlet() + */ + public SaveStateServlet() { + super(); + // --- debug log (constructor) --- + if (logger.isDebugEnabled()) { + logger.debug("11249 class SaveStateServlet created."); + } + // --- debug log (constructor) --- + } + + /* + * (non-Java-doc) + * + * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, + * HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, + HttpServletResponse response) throws ServletException, IOException { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("SaveStateServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in "); + buf.append("request=(" + request + "), "); + buf.append("response=(" + response + ")"); + logger.debug("11250 " + buf.toString()); + request.setCharacterEncoding("UTF-8"); + logger.debug("11251 QueryString=\"" + request.getQueryString() + "\""); + } + // --- debug log (in method) --- + + response.sendRedirect(RedirectPages.LOGIN); + + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11252 SaveStateServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + /* + * (non-Java-doc) + * + * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, + * HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, + HttpServletResponse response) throws ServletException, IOException { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("SaveStateServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in "); + buf.append("request=(" + request + "), "); + buf.append("response=(" + response + ")"); + logger.debug("11253 " + buf.toString()); + request.setCharacterEncoding("UTF-8"); + Enumeration keys = request.getParameterNames(); + String post = ""; + while (keys.hasMoreElements()) { + if (post.length() != 0) + post += "&"; + String key = (String) keys.nextElement(); + post += key + "=" + request.getParameter(key); + } + logger.debug("11254 PostData=\"" + post + "\""); + } + // --- debug log (in method) --- + + // check login session + super.doPost(request, response); + + HttpSession session = request.getSession(false); + if (login == false || session == null) { + if (session != null) { + MessageView error = new MessageView(41050, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + } + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11255 SaveStateServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + // get checkbox Category Data & button Mode + request.setCharacterEncoding("UTF-8"); + String selectCheck[] = request.getParameterValues("save_category"); + String button_mode = request.getParameter("button"); + if (button_mode == null || button_mode.equals(ButtonMode.SAVE) == false) { + MessageView error = new MessageView(41051, LogCategorySet.GUI_SAVE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11256 SaveStateServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + if (selectCheck == null) { + MessageView error = new MessageView(21033, LogCategorySet.GUI_SAVE, + Message.SAVE_CATEGORY_SELECT_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.SAVE); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11257 SaveStateServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + status saveLogResult = status.NO_SAVE; + status saveVsResult = status.NO_SAVE; + String resultPage = RedirectPages.SAVE; + + L7guiFramework framework = new L7guiFramework(); + + for (int i = 0; i < selectCheck.length; i++) { + if (selectCheck[i].equals("save_log")) { + HashSet saveCategory = new HashSet(); + saveCategory.add(SaveCategoryIdSet.LOG_ID); + + if (framework.saveExecute(saveCategory)) { + session.setAttribute(SessionKeys.LOG_SAVE_STATE, + SessionKeys.SAVE); + saveLogResult = status.SAVE_OK; + } else { + saveLogResult = status.SAVE_NG; + resultPage = RedirectPages.SAVE_FAIL; + } + } else if (selectCheck[i].equals("save_service")) { + HashSet saveCategory = new HashSet(); + + saveCategory.add(SaveCategoryIdSet.VS_ID); + if (framework.saveExecute(saveCategory)) { + session.setAttribute(SessionKeys.VS_SAVE_STATE, + SessionKeys.SAVE); + saveVsResult = status.SAVE_OK; + } else { + saveVsResult = status.SAVE_NG; + resultPage = RedirectPages.SAVE_FAIL; + } + } else { + MessageView error = new MessageView(41052, LogCategorySet.GUI_SAVE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11258 SaveStateServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + } + + if (saveLogResult == status.SAVE_OK && + saveVsResult == status.SAVE_OK) { + MessageView success = new MessageView(21034, LogCategorySet.GUI_SAVE, + Message.SAVE_LOG_VS_SUCCESS); + session.setAttribute(SessionKeys.COMMAND_MESSAGE, success); + } else if (saveLogResult == status.SAVE_OK + && saveVsResult == status.SAVE_NG) { + MessageView error = new MessageView(41053, LogCategorySet.GUI_SAVE, Message.SAVE_LOG_SUCCESS + + "
\n" + Message.SAVE_VS_FAIL); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + } else if (saveLogResult == status.SAVE_OK + && saveVsResult == status.NO_SAVE) { + MessageView success = new MessageView(21035, LogCategorySet.GUI_SAVE, Message.SAVE_LOG_SUCCESS); + session.setAttribute(SessionKeys.COMMAND_MESSAGE, success); + } else if (saveLogResult == status.SAVE_NG + && saveVsResult == status.SAVE_OK) { + MessageView error = new MessageView(41054, LogCategorySet.GUI_SAVE, Message.SAVE_LOG_FAIL + + "
\n" + Message.SAVE_VS_SUCCESS); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + } else if (saveLogResult == status.SAVE_NG + && saveVsResult == status.SAVE_NG) { + MessageView error = new MessageView(41055, LogCategorySet.GUI_SAVE, Message.SAVE_LOG_VS_FAIL); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + } else if (saveLogResult == status.SAVE_NG + && saveVsResult == status.NO_SAVE) { + MessageView error = new MessageView(41056, LogCategorySet.GUI_SAVE, Message.SAVE_LOG_FAIL); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + } else if (saveLogResult == status.NO_SAVE + && saveVsResult == status.SAVE_OK) { + MessageView success = new MessageView(21036, LogCategorySet.GUI_SAVE, Message.SAVE_VS_SUCCESS); + session.setAttribute(SessionKeys.COMMAND_MESSAGE, success); + } else if (saveLogResult == status.NO_SAVE + && saveVsResult == status.SAVE_NG) { + MessageView error = new MessageView(41057, LogCategorySet.GUI_SAVE, Message.SAVE_VS_FAIL); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + } else { + MessageView error = new MessageView(41058, LogCategorySet.GUI_SAVE, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11259 SaveStateServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + response.sendRedirect(resultPage); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11260 SaveStateServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } +} diff --git a/src/src/org/ultramonkey/l7/view/SessionKeys.java b/src/src/org/ultramonkey/l7/view/SessionKeys.java new file mode 100644 index 0000000..e97311c --- /dev/null +++ b/src/src/org/ultramonkey/l7/view/SessionKeys.java @@ -0,0 +1,39 @@ +package org.ultramonkey.l7.view; + +public interface SessionKeys { + public static final String LOGIN_SESSION = "onLogin"; + public static final String RESULT_MESSAGE = "resultMessage"; + public static final String COMMAND_MESSAGE = "commandMessage"; + public static final String PAGE_TRANSDATA = "pageTrans"; + public static final String OLD_VS = "oldVsData"; + public static final String INPUT_VS = "inputVsData"; + public static final String INPUT_REP = "inputRepData"; + public static final String INPUT_SNMP = "inputSnmpAgentData"; + public static final String INPUT_SNMP_UNIT = "unit_snmpInterval"; + public static final String INPUT_LOGLEVEL = "inputLogLebel"; + public static final String INPUT_MONITOR = "inputMonitorData"; + public static final String INVALID_MESSAGE = "invalidMessage"; + public static final String INPUT_USERDATA = "inputUserData"; + public static final String VS_NAME = "vsName"; + public static final String BEFORE_REP_TIME = "beforeRepTime"; + public static final String AFTER_REP_TIME = "afterRepTime"; + + public static final String THREAD_STATUS = "threadStatus"; + public static final String THREAD_SUCCESS = "success"; + public static final String THREAD_FAIL = "fail"; + public static final String THREAD_RUNNING = "running"; + + public static final String LOG_SAVE_STATE = "logSaveState"; + public static final String VS_SAVE_STATE = "vsSaveState"; + public static final String SAVE = "save"; + public static final String NO_SAVE = "noSave"; + + public static final String LOG_SYNC_STATE = "logSyncState"; + public static final String VS_SYNC_STATE = "vsSyncState"; + public static final String MONITOR_SYNC_STATE = "monitorSyncState"; + public static final String REP_SYNC_STATE = "repSyncState"; + public static final String SNMP_SYNC_STATE = "snmpSyncState"; + public static final String GUI_SYNC_STATE = "guiSyncState"; + public static final String SYNC = "sync"; + public static final String NO_SYNC = "noSync"; +} diff --git a/src/src/org/ultramonkey/l7/view/SnmpAgentServlet.java b/src/src/org/ultramonkey/l7/view/SnmpAgentServlet.java new file mode 100644 index 0000000..9a71f93 --- /dev/null +++ b/src/src/org/ultramonkey/l7/view/SnmpAgentServlet.java @@ -0,0 +1,352 @@ +package org.ultramonkey.l7.view; + +import java.io.IOException; +import java.util.Enumeration; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.log4j.Logger; +import org.ultramonkey.l7.controller.SnmpAgentData; +import org.ultramonkey.l7.model.ExecuteMode; +import org.ultramonkey.l7.model.L7guiFramework; +import org.ultramonkey.l7.model.LogCategorySet; +import org.ultramonkey.l7.model.Message; +import org.ultramonkey.l7.model.MessageView; +import org.ultramonkey.l7.model.SessionTransData; + +/** + *

+ * class VSModServlet + *

+ *

+ * Copyright(c) NTT COMWARE 2008 + *

+ * + * @author kobayashi + */ +public class SnmpAgentServlet extends org.ultramonkey.l7.view.L7guiServletBase { + static final long serialVersionUID = 1L; + + private Logger logger = Logger.getLogger(LogCategorySet.GUI_IO); + + /* + * (non-Java-doc) + * + * @see javax.servlet.http.HttpServlet#HttpServlet() + */ + public SnmpAgentServlet() { + super(); + // --- debug log (constructor) --- + if (logger.isDebugEnabled()) { + logger.debug("11261 class SnmpAgentServlet created."); + } + // --- debug log (constructor) --- + } + + /* + * (non-Java-doc) + * + * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, + * HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, + HttpServletResponse response) throws ServletException, IOException { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("SnmpAgentServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in "); + buf.append("request=(" + request + "), "); + buf.append("response=(" + response + ")"); + logger.debug("11262 " + buf.toString()); + request.setCharacterEncoding("UTF-8"); + logger.debug("11263 QueryString=\"" + request.getQueryString() + "\""); + } + // --- debug log (in method) --- + + response.sendRedirect(RedirectPages.LOGIN); + + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11264 SnmpAgentServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + /* + * (non-Java-doc) + * + * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, + * HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, + HttpServletResponse response) throws ServletException, IOException { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("SnmpAgentServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in "); + buf.append("request=(" + request + "), "); + buf.append("response=(" + response + ")"); + logger.debug("11265 " + buf.toString()); + request.setCharacterEncoding("UTF-8"); + Enumeration keys = request.getParameterNames(); + String post = ""; + while (keys.hasMoreElements()) { + if (post.length() != 0) + post += "&"; + String key = (String) keys.nextElement(); + post += key + "=" + request.getParameter(key); + } + logger.debug("11266 PostData=\"" + post + "\""); + } + // --- debug log (in method) --- + + // check login session + super.doPost(request, response); + + HttpSession session = request.getSession(false); + if (login == false || session == null) { + if (session != null) { + MessageView error = new MessageView(41059, + LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + } + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11267 SnmpAgentServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + /* + * get SnmpAgentData + */ + request.setCharacterEncoding("UTF-8"); + String str_snmpInterval = request.getParameter("snmp_interval"); + if (str_snmpInterval == null) { + MessageView error = new MessageView(41060, LogCategorySet.GUI_SNMP, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11268 SnmpAgentServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + // unit_snmpInterval + String unit_snmpInterval = request.getParameter("unit_interval"); + if (unit_snmpInterval == null) { + MessageView error = new MessageView(41061, LogCategorySet.GUI_SNMP, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11269 SnmpAgentServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + // SnmpAgetData + L7guiFramework frameWork = new L7guiFramework(); + SnmpAgentData snmp = frameWork.getSnmpAgentData(); + if (snmp == null) { + MessageView error = new MessageView(41062, LogCategorySet.GUI_SNMP, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11270 SnmpAgentServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + /* + * validationCheck + */ + boolean validationFlag = validationcheck(session, str_snmpInterval, + snmp); + if (validationFlag == false) { + session.setAttribute(SessionKeys.INPUT_SNMP, snmp); + session + .setAttribute(SessionKeys.INPUT_SNMP_UNIT, + unit_snmpInterval); + MessageView error = new MessageView(21037, LogCategorySet.GUI_SNMP, + Message.INVALID_VALUE); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.SNMP_MODIFY); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11271 SnmpAgentServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + /* + * set unit_snmpInterval + */ + if (unit_snmpInterval.equals("ms")) { + // + } else if (unit_snmpInterval.equals("s")) { + snmp.interval *= 1000; + } else { + session.setAttribute(SessionKeys.INPUT_SNMP, snmp); + session + .setAttribute(SessionKeys.INPUT_SNMP_UNIT, + unit_snmpInterval); + MessageView error = new MessageView(21038, LogCategorySet.GUI_SNMP, + Message.INVALID_VALUE); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.SNMP_MODIFY); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11272 SnmpAgentServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + CommandExecuter thread = new CommandExecuter(session); + + ExecuteMode mode; + String redirectPage; + + String button_mode = request.getParameter("button"); + // button mode : null + if (button_mode == null) { + MessageView error = new MessageView(41063, LogCategorySet.GUI_SNMP, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11273 SnmpAgentServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + // button mode : save + else if (button_mode.equals(ButtonMode.SAVE)) { + mode = ExecuteMode.SNMP_INFO_SAVE; + redirectPage = RedirectPages.SNMP_MODIFY_EXECUTIVE; + } + // button mode : save and sync + else if (button_mode.equals(ButtonMode.SAVESYNC)) { + mode = ExecuteMode.SNMP_INFO_SAVESYNC; + redirectPage = RedirectPages.SAVE_SYNC_EXECUTIVE; + + SessionTransData trans = new SessionTransData(); + trans.sourceURI = RedirectPages.SNMP_MODIFY; + trans.destURI = RedirectPages.SNMP_MODIFY; + trans.errorURI = RedirectPages.SNMP_MODIFY_NG; + session.setAttribute(SessionKeys.PAGE_TRANSDATA, trans); + } else { + MessageView error = new MessageView(41064, LogCategorySet.GUI_SNMP, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11274 SnmpAgentServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + try { + thread.setExecute(mode, snmp); + thread.start(); + } catch (Exception e) { + MessageView error = new MessageView(41065, LogCategorySet.GUI_SNMP, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11275 SnmpAgentServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + response.sendRedirect(redirectPage); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11276 SnmpAgentServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + /** + * + *

+ * validationCheck method + *

+ * + * @param session + * @param str_snmpInterval + * @param snmp + * @return + */ + + private boolean validationcheck(HttpSession session, + String str_SnmpInterval, SnmpAgentData snmp) { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("SnmpAgentServlet::validationCheck(HttpSession session, String str_SnmpInterval, SnmpAgentData snmp) in "); + buf.append("session=(" + session + "), "); + buf.append("str_SnmpInterval=(" + str_SnmpInterval + "), "); + buf.append("snmp=(" + snmp + ")"); + logger.debug("11277 " + buf.toString()); + } + // --- debug log (in method) --- + + boolean validationFlag = true; + + int MIN_SNMP_INTERVAL = 1; + int MAX_SNMP_INTERVAL = 999; + int int_SnmpInterval = 1; + + if (str_SnmpInterval.length() == 0) { + session.setAttribute(SessionKeys.INVALID_MESSAGE, + Message.REQUIED_ITEM); + validationFlag = false; + } else { + try { + int_SnmpInterval = Integer.parseInt(str_SnmpInterval); + if ((int_SnmpInterval < MIN_SNMP_INTERVAL) + || (int_SnmpInterval > MAX_SNMP_INTERVAL)) { + session.setAttribute(SessionKeys.INVALID_MESSAGE, + Message.VALIDATION_ERROR); + validationFlag = false; + } + } catch (NumberFormatException e) { + session.setAttribute(SessionKeys.INVALID_MESSAGE, + Message.VALIDATION_ERROR); + validationFlag = false; + } + } + snmp.interval = int_SnmpInterval; + + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11278 SnmpAgentServlet::validationCheck(HttpSession session, String str_SnmpInterval, SnmpAgentData snmp) out return=" + validationFlag); + } + // --- debug log (out method) --- + return validationFlag; + } +} \ No newline at end of file diff --git a/src/src/org/ultramonkey/l7/view/SoRunServlet.java b/src/src/org/ultramonkey/l7/view/SoRunServlet.java new file mode 100644 index 0000000..3cdb27e --- /dev/null +++ b/src/src/org/ultramonkey/l7/view/SoRunServlet.java @@ -0,0 +1,148 @@ +package org.ultramonkey.l7.view; + +import java.io.IOException; +import java.util.Enumeration; + +import javax.servlet.*; +import javax.servlet.http.*; + +import org.apache.log4j.Logger; +import org.ultramonkey.l7.model.*; + + +/** + * + *

class SoRunServlet

+ *

Copyright(c) NTT COMWARE 2008

+ *

Servlet implementation class for Servlet: SoRun

+ * @author kubota + */ +public class SoRunServlet extends L7guiServletBase { + static final long serialVersionUID = 1L; + + private Logger logger = Logger.getLogger(LogCategorySet.GUI_IO); + + /* (non-Java-doc) + * @see javax.servlet.http.HttpServlet#HttpServlet() + */ + public SoRunServlet() { + super(); + // --- debug log (constructor) --- + if (logger.isDebugEnabled()) { + logger.debug("11311 class SoRunServlet created."); + } + // --- debug log (constructor) --- + } + + /* (non-Java-doc) + * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("SoRunServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in "); + buf.append("request=(" + request + "), "); + buf.append("response=(" + response + ")"); + logger.debug("11312 " + buf.toString()); + request.setCharacterEncoding("UTF-8"); + logger.debug("11313 QueryString=\"" + request.getQueryString() + "\""); + } + // --- debug log (in method) --- + + response.sendRedirect(RedirectPages.LOGIN); + + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11314 SoRunServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + + /* (non-Java-doc) + * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("SoRunServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in "); + buf.append("request=(" + request + "), "); + buf.append("response=(" + response + ")"); + logger.debug("11315 " + buf.toString()); + request.setCharacterEncoding("UTF-8"); + Enumeration keys = request.getParameterNames(); + String post = ""; + while (keys.hasMoreElements()) { + if (post.length() != 0) + post += "&"; + String key = (String) keys.nextElement(); + post += key + "=" + request.getParameter(key); + } + logger.debug("11316 PostData=\"" + post + "\""); + } + // --- debug log (in method) --- + + // check login session + super.doPost(request, response); + + HttpSession session = request.getSession(false); + if (login == false || session == null) { + if (session != null) { + MessageView error = new MessageView(41077, LogCategorySet.GUI_USER_AUTHENTICATION, Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + } + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11317 SoRunServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + request.setCharacterEncoding("UTF-8"); + String buttonMode = request.getParameter("button"); + if ((buttonMode != null) && (buttonMode.equals(ButtonMode.SWITCH_OVER))) { + CommandExecuter thread = new CommandExecuter(session); + try { + thread.setExecute(ExecuteMode.CLUSTER_SWITCHORVER); + thread.start(); + } + catch(Exception e) { + MessageView error = new MessageView(41078, LogCategorySet.GUI_REDUNDANT, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11318 SoRunServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + } + else { + MessageView error = new MessageView(41079, LogCategorySet.GUI_REDUNDANT, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11319 SoRunServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + response.sendRedirect(RedirectPages.SO_EXECUTIVE); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11320 SoRunServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } +} \ No newline at end of file diff --git a/src/src/org/ultramonkey/l7/view/SyncStateServlet.java b/src/src/org/ultramonkey/l7/view/SyncStateServlet.java new file mode 100644 index 0000000..7ec9d64 --- /dev/null +++ b/src/src/org/ultramonkey/l7/view/SyncStateServlet.java @@ -0,0 +1,200 @@ +package org.ultramonkey.l7.view; + +import java.io.IOException; +import java.util.Enumeration; +import java.util.HashSet; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.log4j.Logger; +import org.ultramonkey.l7.model.ExecuteMode; +import org.ultramonkey.l7.model.LogCategorySet; +import org.ultramonkey.l7.model.Message; +import org.ultramonkey.l7.model.MessageView; +import org.ultramonkey.l7.model.SyncCategoryIdSet; + +/** + * + *

+ * class SaveStateServlet + *

+ *

+ * Copyright(c) NTT COMWARE 2008 + *

+ * + * @author kubota + */ +public class SyncStateServlet extends org.ultramonkey.l7.view.L7guiServletBase { + static final long serialVersionUID = 1L; + + private Logger logger = Logger.getLogger(LogCategorySet.GUI_IO); + + /* + * (non-Java-doc) + * + * @see javax.servlet.http.HttpServlet#HttpServlet() + */ + public SyncStateServlet() { + super(); + // --- debug log (constructor) --- + if (logger.isDebugEnabled()) { + logger.debug("11431 class SyncStateServlet created."); + } + // --- debug log (constructor) --- + } + + /* + * (non-Java-doc) + * + * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, + * HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, + HttpServletResponse response) throws ServletException, IOException { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("SyncStateServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in "); + buf.append("request=(" + request + "), "); + buf.append("response=(" + response + ")"); + logger.debug("11432 " + buf.toString()); + request.setCharacterEncoding("UTF-8"); + logger.debug("11433 QueryString=\"" + request.getQueryString() + "\""); + } + // --- debug log (in method) --- + + response.sendRedirect(RedirectPages.LOGIN); + + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11434 SyncStateServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + /* + * (non-Java-doc) + * + * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, + * HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, + HttpServletResponse response) throws ServletException, IOException { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("SyncStateServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in "); + buf.append("request=(" + request + "), "); + buf.append("response=(" + response + ")"); + logger.debug("11435 " + buf.toString()); + request.setCharacterEncoding("UTF-8"); + Enumeration keys = request.getParameterNames(); + String post = ""; + while (keys.hasMoreElements()) { + if (post.length() != 0) + post += "&"; + String key = (String) keys.nextElement(); + post += key + "=" + request.getParameter(key); + } + logger.debug("11436 PostData=\"" + post + "\""); + } + // --- debug log (in method) --- + + // check login session + super.doPost(request, response); + + HttpSession session = request.getSession(false); + if (login == false || session == null) { + if (session != null) { + MessageView error = new MessageView(41191, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + } + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11437 SyncStateServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + // get checkbox Category Data & button Mode + request.setCharacterEncoding("UTF-8"); + String selectCheck[] = request.getParameterValues("sync_category"); + String button_mode = request.getParameter("button"); + if (button_mode == null || button_mode.equals(ButtonMode.SAVESYNC) == false) { + MessageView error = new MessageView(41192, LogCategorySet.GUI_SYNC, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11438 SyncStateServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + if (selectCheck == null) { + MessageView error = new MessageView(21084, LogCategorySet.GUI_SYNC, + Message.SYNC_CATEGORY_SELECT_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.SYNC); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11439 SyncStateServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + HashSet syncCategory = new HashSet(); + + for (int i = 0; i < selectCheck.length; i++) { + try { + int categoryNum = SyncCategoryIdSet + .toCategoryId(selectCheck[i]); + syncCategory.add(categoryNum); + } catch (MessageView mem) { + MessageView error = new MessageView(21085, LogCategorySet.GUI_SYNC, + Message.SYNC_CATEGORY_SELECT_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.SYNC); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11440 SyncStateServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + } + + CommandExecuter thread = new CommandExecuter(session); + + try { + thread.setExecute(ExecuteMode.SYNC, syncCategory); + thread.start(); + } catch (Exception e) { + MessageView error = new MessageView(41193, LogCategorySet.GUI_SYNC, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11441 SyncStateServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + response.sendRedirect(RedirectPages.SYNC_EXECUTIVE); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11442 SyncStateServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } +} diff --git a/src/src/org/ultramonkey/l7/view/UserAddServlet.java b/src/src/org/ultramonkey/l7/view/UserAddServlet.java new file mode 100644 index 0000000..9f4dffb --- /dev/null +++ b/src/src/org/ultramonkey/l7/view/UserAddServlet.java @@ -0,0 +1,325 @@ +package org.ultramonkey.l7.view; + +import java.io.IOException; +import java.util.Enumeration; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.*; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.log4j.Logger; +import org.ultramonkey.l7.model.FileNotWriteException; +import org.ultramonkey.l7.model.LogCategorySet; +import org.ultramonkey.l7.model.Message; +import org.ultramonkey.l7.model.MessageView; +import org.ultramonkey.l7.model.UserData; +import org.ultramonkey.l7.model.UserManager; + +/** + * + *

+ * class UserAddServlet + *

+ *

+ * Copyright(c) NTT COMWARE 2008 + *

+ * + * @author kubota + */ +public class UserAddServlet extends org.ultramonkey.l7.view.L7guiServletBase { + static final long serialVersionUID = 1L; + + private Logger logger = Logger.getLogger(LogCategorySet.GUI_IO); + + /* + * (non-Java-doc) + * + * @see javax.servlet.http.HttpServlet#HttpServlet() + */ + public UserAddServlet() { + super(); + // --- debug log (constructor) --- + if (logger.isDebugEnabled()) { + logger.debug("11321 class UserAddServlet created."); + } + // --- debug log (constructor) --- + } + + /* + * (non-Java-doc) + * + * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, + * HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, + HttpServletResponse response) throws ServletException, IOException { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("UserAddServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in "); + buf.append("request=(" + request + "), "); + buf.append("response=(" + response + ")"); + logger.debug("11322 " + buf.toString()); + request.setCharacterEncoding("UTF-8"); + logger.debug("11323 QueryString=\"" + request.getQueryString() + "\""); + } + // --- debug log (in method) --- + + response.sendRedirect(RedirectPages.LOGIN); + + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11324 UserAddServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + /* + * (non-Java-doc) + * + * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, + * HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, + HttpServletResponse response) throws ServletException, IOException { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("UserAddServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in "); + buf.append("request=(" + request + "), "); + buf.append("response=(" + response + ")"); + logger.debug("11325 " + buf.toString()); + request.setCharacterEncoding("UTF-8"); + Enumeration keys = request.getParameterNames(); + String post = ""; + while (keys.hasMoreElements()) { + if (post.length() != 0) + post += "&"; + String key = (String) keys.nextElement(); + post += key + "=" + request.getParameter(key); + } + logger.debug("11326 PostData=\"" + post + "\""); + } + // --- debug log (in method) --- + + // check login session + super.doPost(request, response); + + HttpSession session = request.getSession(false); + if (login == false || session == null) { + if (session != null) { + MessageView error = new MessageView(41080, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + } + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11327 UserAddServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + request.setCharacterEncoding("UTF-8"); + String userId = request.getParameter("userId"); + String description = request.getParameter("description"); + String newPass1 = request.getParameter("new1_passwd"); + String newPass2 = request.getParameter("new2_passwd"); + String button_mode = request.getParameter("button"); + + if ((userId == null) || (description == null) || (newPass1 == null) + || (newPass2 == null) || (button_mode == null) + || (button_mode.equals(ButtonMode.ADD) == false)) { + MessageView error = new MessageView(41081, LogCategorySet.GUI_USER_MANAGE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11328 UserAddServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + boolean validationFlag = true; + validationFlag = validationCheck(session, userId, description, + newPass1, newPass2); + if (validationFlag == false) { + UserData inputUser = new UserData(); + inputUser.userName = userId; + inputUser.description = description; + session.setAttribute(SessionKeys.INPUT_USERDATA, inputUser); + response.sendRedirect(RedirectPages.USER_ADD); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11329 UserAddServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + UserManager user = UserManager.getInstance(); + + Vector userList; + boolean addUser = false; + try { + userList = user.getUserList(); + int userCount = userList.size(); + if (userCount >= 16){ + MessageView error = new MessageView(41082, LogCategorySet.GUI_IO_FILE, + Message.USER_MAX); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.USER_ADD_FAIL); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11330 UserAddServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + addUser = user.addUser(userId, newPass1, 0, description); + } + catch (FileNotWriteException e) { + MessageView error = new MessageView(41083, LogCategorySet.GUI_IO_FILE, Message.WRITE_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11331 UserAddServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + catch(Exception e){ + MessageView error = new MessageView(41084, LogCategorySet.GUI_START_STOP, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11332 UserAddServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + if (addUser == true) { + MessageView message = new MessageView(21041, LogCategorySet.GUI_USER_MANAGE, + Message.USER_ADD_SUCCESS); + session.setAttribute(SessionKeys.RESULT_MESSAGE, message); + session.setAttribute(SessionKeys.GUI_SYNC_STATE, SessionKeys.NO_SYNC); + response.sendRedirect(RedirectPages.USER_MANAGE); + } else { + MessageView error = new MessageView(41085, LogCategorySet.GUI_USER_MANAGE, + Message.SAME_USER_EXISTS); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.USER_ADD_FAIL); + } + + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11333 UserAddServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + /** + * + *

+ * validationCheck method + *

+ * + * @param session + * @param userId + * @param description + * @param curPass + * @param newPass1 + * @param newPass2 + * @return + */ + protected boolean validationCheck(HttpSession session, String userId, + String description, String newPass1, String newPass2) { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("UserAddServlet::validationCheck(HttpSession session, String userId, String description, String newPass1, String newPass2) in "); + buf.append("session=(" + session + "), "); + buf.append("userId=\"" + userId + "\", "); + buf.append("description=\"" + description + "\", "); + buf.append("newPass1=\"" + newPass1 + "\", "); + buf.append("newPass2=\"" + newPass2); + logger.debug("11334 " + buf.toString()); + } + // --- debug log (in method) --- + + boolean validationFlag = true; + final int MAX_USER_LENGTH = 16; + final int MAX_DESCRIPTION_LENGTH = 64; + final int MIN_PASS_LENGTH = 6; + final int MAX_PASS_LENGTH = 16; + + Pattern pattern = Pattern.compile("[^\\x20-\\x7e]"); + + if (session == null) { + validationFlag = false; + } else if (userId == null || description == null || newPass1 == null || newPass2 == null) { + MessageView error = new MessageView(21042, LogCategorySet.GUI_USER_MANAGE, Message.INVALID_VALUE); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + validationFlag = false; + } else if ((userId.length() == 0) && (description.length() == 0) + && (newPass1.length() == 0) && (newPass2.length() == 0)) { + MessageView error = new MessageView(21043, LogCategorySet.GUI_USER_MANAGE, Message.NOT_EXIST); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + validationFlag = false; + } else if ((userId.length() == 0) || (newPass1.length() == 0) + || (newPass2.length() == 0)) { + MessageView error = new MessageView(21044, LogCategorySet.GUI_USER_MANAGE, + Message.NOT_INPUT_ITEM); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + validationFlag = false; + } + else { + Matcher matcherUserId = pattern.matcher(userId); + Matcher matcherNewPass1 = pattern.matcher(newPass1); + Matcher matcherNewPass2 = pattern.matcher(newPass2); + Matcher matcherDescription = pattern.matcher(description); + + if (matcherUserId.find() || matcherNewPass1.find() + || matcherNewPass2.find() || matcherDescription.find()) { + MessageView error = new MessageView(21045, LogCategorySet.GUI_USER_MANAGE, + "Input item : " + Message.INVALID_VALUE); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + validationFlag = false; + } else if (false == newPass1.equals(newPass2)) { + MessageView error = new MessageView(21046, LogCategorySet.GUI_USER_MANAGE, + Message.NOT_EQUAL); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + validationFlag = false; + } else if ((userId.length() > MAX_USER_LENGTH) + || (newPass1.length() < MIN_PASS_LENGTH) + || (newPass1.length() > MAX_PASS_LENGTH) + || (description.length() > MAX_DESCRIPTION_LENGTH)) { + MessageView error = new MessageView(21047, LogCategorySet.GUI_USER_MANAGE, + Message.INVALID_VALUE); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + validationFlag = false; + } + } + + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11335 UserAddServlet::validationCheck(HttpSession session, String userId, String description, String newPass1, String newPass2) out return=" + validationFlag); + } + // --- debug log (out method) --- + return validationFlag; + } +} \ No newline at end of file diff --git a/src/src/org/ultramonkey/l7/view/UserModServlet.java b/src/src/org/ultramonkey/l7/view/UserModServlet.java new file mode 100644 index 0000000..c069cb3 --- /dev/null +++ b/src/src/org/ultramonkey/l7/view/UserModServlet.java @@ -0,0 +1,353 @@ +package org.ultramonkey.l7.view; + +import java.io.IOException; +import java.util.Enumeration; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.log4j.Logger; +import org.ultramonkey.l7.model.*; + +/** + * + *

+ * class PwChangeServlet + *

+ *

+ * Copyright(c) NTT COMWARE 2008 + *

+ * + * @author kubota + */ + +public class UserModServlet extends org.ultramonkey.l7.view.L7guiServletBase { + static final long serialVersionUID = 1L; + + private Logger logger = Logger.getLogger(LogCategorySet.GUI_IO); + + /* + * (non-Java-doc) + * + * @see javax.servlet.http.HttpServlet#HttpServlet() + */ + public UserModServlet() { + super(); + // --- debug log (constructor) --- + if (logger.isDebugEnabled()) { + logger.debug("11414 class UserModServlet created."); + } + // --- debug log (constructor) --- + } + + /* + * (non-Java-doc) + * + * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, + * HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, + HttpServletResponse response) throws ServletException, IOException { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("UserModServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in "); + buf.append("request=(" + request + "), "); + buf.append("response=(" + response + ")"); + logger.debug("11415 " + buf.toString()); + request.setCharacterEncoding("UTF-8"); + logger.debug("11416 QueryString=\"" + request.getQueryString() + "\""); + } + // --- debug log (in method) --- + + response.sendRedirect(RedirectPages.LOGIN); + + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11417 UserModServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + /* + * (non-Java-doc) + * + * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, + * HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, + HttpServletResponse response) throws ServletException, IOException { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("UserModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in "); + buf.append("request=(" + request + "), "); + buf.append("response=(" + response + ")"); + logger.debug("11418 " + buf.toString()); + request.setCharacterEncoding("UTF-8"); + Enumeration keys = request.getParameterNames(); + String post = ""; + while (keys.hasMoreElements()) { + if (post.length() != 0) + post += "&"; + String key = (String) keys.nextElement(); + post += key + "=" + request.getParameter(key); + } + logger.debug("11419 PostData=\"" + post + "\""); + } + // --- debug log (in method) --- + + // check login session + super.doPost(request, response); + + HttpSession session = request.getSession(false); + if (login == false || session == null) { + if (session != null) { + MessageView error = new MessageView(41184, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + } + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11420 UserModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + UserData currentUser = (UserData) session + .getAttribute(SessionKeys.LOGIN_SESSION); + if (currentUser == null) { + MessageView error = new MessageView(41185, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11421 UserModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + // post Data check + request.setCharacterEncoding("UTF-8"); + String description = request.getParameter("description"); + String curPass = request.getParameter("password"); + String newPass1 = request.getParameter("new1_passwd"); + String newPass2 = request.getParameter("new2_passwd"); + String button_mode = request.getParameter("button"); + if ((description == null) || (curPass == null) || (newPass1 == null) + || (newPass2 == null) || (button_mode == null) + || (button_mode.equals(ButtonMode.CHANGE) == false)) { + MessageView error = new MessageView(41186, LogCategorySet.GUI_USER_MANAGE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11422 UserModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + boolean validationFlag = true; + validationFlag = validationCheck(session, description, curPass, + newPass1, newPass2); + if (validationFlag == false) { + UserData inputUser = new UserData(); + inputUser.description = description; + session.setAttribute(SessionKeys.INPUT_USERDATA, inputUser); + response.sendRedirect(RedirectPages.USER_MODIFY); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11423 UserModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + // User authentication + UserManager user = UserManager.getInstance(); + UserData authCheck = null; + try { + authCheck = user.authUser(currentUser.userName, curPass); + } catch (Exception e) { + MessageView error = new MessageView(41187, LogCategorySet.GUI_START_STOP, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11424 UserModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + if (authCheck == null) { + MessageView error = new MessageView(21076, LogCategorySet.GUI_USER_MANAGE, + Message.PASSWORD_INVALID); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.USER_MODIFY); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11425 UserModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + // Password Change + UserData modUser = new UserData(); + modUser.userName = currentUser.userName; + modUser.description = description; + modUser.passwd = newPass1; + + boolean passChange = true; + try { + passChange = user.changeUser(modUser); + } catch (FileNotWriteException e) { + MessageView error = new MessageView(41188,LogCategorySet.GUI_IO_FILE, + Message.WRITE_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11426 UserModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } catch (Exception e) { + MessageView error = new MessageView(41189, LogCategorySet.GUI_USER_MANAGE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11427 UserModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + if (passChange == true) { + session.setAttribute(SessionKeys.LOGIN_SESSION, modUser); + MessageView error = new MessageView(21077, LogCategorySet.GUI_USER_MANAGE, + Message.USER_CHANGE_SUCCESS); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + session.setAttribute(SessionKeys.GUI_SYNC_STATE, SessionKeys.NO_SYNC); + response.sendRedirect(RedirectPages.USER_MODIFY_SUCCESS); + } else { + session.setAttribute(SessionKeys.LOGIN_SESSION, authCheck); + MessageView error = new MessageView(41190, LogCategorySet.GUI_USER_MANAGE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.USER_MODIFY_FAIL); + } + + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11428 UserModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + /** + * + *

+ * validationCheck method + *

+ * + * @param session + * @param description + * @param curPass + * @param newPass1 + * @param newPass2 + * @return + */ + boolean validationCheck(HttpSession session, String description, + String curPass, String newPass1, String newPass2) { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("UserModServlet::validationCheck(HttpSession session, String description, String newPass1, String newPass2) in "); + buf.append("session=(" + session + "), "); + buf.append("description=\"" + description + "\", "); + buf.append("newPass1=\"" + newPass1 + "\", "); + buf.append("newPass2=\"" + newPass2); + logger.debug("11429 " + buf.toString()); + } + // --- debug log (in method) --- + + boolean validationFlag = true; + final int MAX_DESCRIPTION_LENGTH = 64; + final int MIN_PASS_LENGTH = 6; + final int MAX_PASS_LENGTH = 16; + + Pattern pattern = Pattern.compile("[^\\x20-\\x7e]"); + + if ((description.length() == 0) && (curPass.length() == 0) + && (newPass1.length() == 0) && (newPass2.length() == 0)) { + MessageView error = new MessageView(21078, LogCategorySet.GUI_USER_MANAGE, + Message.NOT_EXIST); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + validationFlag = false; + } + + else if (description.length() != 0) { + Matcher matcher = pattern.matcher(description); + if ((description.length() > MAX_DESCRIPTION_LENGTH) || matcher.find() ){ + MessageView error = new MessageView(21079, LogCategorySet.GUI_USER_MANAGE, + "Description : " + Message.INVALID_VALUE); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + validationFlag = false; + } + } + + if ( (curPass.length() == 0 ) || (newPass1.length() == 0) || (newPass2.length() == 0) ){ + MessageView error = new MessageView(21080, LogCategorySet.GUI_USER_MANAGE, + "Password : " + Message.REQUIED_ITEM); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + validationFlag = false; + } else { + Matcher matcherCurPass = pattern.matcher(curPass); + Matcher matcherNewPass1 = pattern.matcher(newPass1); + Matcher matcherNewPass2 = pattern.matcher(newPass2); + + if (matcherCurPass.find() || matcherNewPass1.find() + || matcherNewPass2.find()) { + MessageView error = new MessageView(21081, LogCategorySet.GUI_USER_MANAGE, + "Input item : "+ Message.INVALID_VALUE); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + validationFlag = false; + } else if (false == newPass1.equals(newPass2)) { + MessageView error = new MessageView(21082, LogCategorySet.GUI_USER_MANAGE, + Message.NOT_EQUAL); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + validationFlag = false; + } + else if ((newPass1.length() < MIN_PASS_LENGTH) || (newPass1.length() > MAX_PASS_LENGTH)){ + MessageView error = new MessageView(21083, LogCategorySet.GUI_USER_MANAGE, + Message.INVALID_VALUE); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + validationFlag = false; + } + } + + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11430 UserModServlet::validationCheck(HttpSession session, String description, String newPass1, String newPass2) out return=" + validationFlag); + } + // --- debug log (out method) --- + return validationFlag; + } +} \ No newline at end of file diff --git a/src/src/org/ultramonkey/l7/view/UserRemoveServlet.java b/src/src/org/ultramonkey/l7/view/UserRemoveServlet.java new file mode 100644 index 0000000..1f08723 --- /dev/null +++ b/src/src/org/ultramonkey/l7/view/UserRemoveServlet.java @@ -0,0 +1,254 @@ +package org.ultramonkey.l7.view; + +import java.io.IOException; +import java.util.Enumeration; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.log4j.Logger; +import org.ultramonkey.l7.model.FileNotWriteException; +import org.ultramonkey.l7.model.LogCategorySet; +import org.ultramonkey.l7.model.Message; +import org.ultramonkey.l7.model.MessageView; +import org.ultramonkey.l7.model.UserData; +import org.ultramonkey.l7.model.UserManager; + +/** + * + *

+ * class UserRemoveServlet + *

+ *

+ * Copyright(c) NTT COMWARE 2008 + *

+ * + * @author kubota + */ +public class UserRemoveServlet extends org.ultramonkey.l7.view.L7guiServletBase { + static final long serialVersionUID = 1L; + + private Logger logger = Logger.getLogger(LogCategorySet.GUI_IO); + + /* + * (non-Java-doc) + * + * @see javax.servlet.http.HttpServlet#HttpServlet() + */ + public UserRemoveServlet() { + super(); + // --- debug log (constructor) --- + if (logger.isDebugEnabled()) { + logger.debug("11443 class UserModServlet created."); + } + // --- debug log (constructor) --- + } + + /* + * (non-Java-doc) + * + * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, + * HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, + HttpServletResponse response) throws ServletException, IOException { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("UserModServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in "); + buf.append("request=(" + request + "), "); + buf.append("response=(" + response + ")"); + logger.debug("11444 " + buf.toString()); + request.setCharacterEncoding("UTF-8"); + logger.debug("11445 QueryString=\"" + request.getQueryString() + "\""); + } + // --- debug log (in method) --- + + response.sendRedirect(RedirectPages.LOGIN); + + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11446 UserModServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + /* + * (non-Java-doc) + * + * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, + * HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, + HttpServletResponse response) throws ServletException, IOException { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("UserModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in "); + buf.append("request=(" + request + "), "); + buf.append("response=(" + response + ")"); + logger.debug("11447 " + buf.toString()); + request.setCharacterEncoding("UTF-8"); + Enumeration keys = request.getParameterNames(); + String post = ""; + while (keys.hasMoreElements()) { + if (post.length() != 0) + post += "&"; + String key = (String) keys.nextElement(); + post += key + "=" + request.getParameter(key); + } + logger.debug("11448 PostData=\"" + post + "\""); + } + // --- debug log (in method) --- + + // check login session + super.doPost(request, response); + + HttpSession session = request.getSession(false); + if (login == false || session == null) { + if (session != null) { + MessageView error = new MessageView(41194, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + } + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11449 UserModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + UserData currentUser = (UserData) session + .getAttribute(SessionKeys.LOGIN_SESSION); + if (currentUser == null) { + MessageView error = new MessageView(41195, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11450 UserModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + // get checkbox UserName Data & button Mode + request.setCharacterEncoding("UTF-8"); + String selectCheck[] = request.getParameterValues("ck_user"); + String button_mode = request.getParameter("button"); + if (button_mode == null + || button_mode.equals(ButtonMode.DELETE) == false) { + MessageView error = new MessageView(41196, LogCategorySet.GUI_USER_MANAGE, Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11451 UserModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + if (selectCheck == null) { + MessageView error = new MessageView(21086, LogCategorySet.GUI_USER_MANAGE, + Message.USER_REMOVE_SELECT_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.USER_MANAGE); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11452 UserModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + UserManager user = UserManager.getInstance(); + boolean removeUser = true; + boolean removeFlag = true; + String successRemoveUser = ""; + String failRemoveUser = ""; + for (int i = 0; i < selectCheck.length; i++) { + if (true == selectCheck[i].equals(currentUser.userName)) { + MessageView error = new MessageView(21087, LogCategorySet.GUI_USER_MANAGE, + Message.SELF_USER_DELETE); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.USER_MANAGE); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11453 UserModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + } + + for (int i = 0; i < selectCheck.length; i++) { + try { + removeUser = user.delUser(selectCheck[i]); + } catch (FileNotWriteException e) { + MessageView error = new MessageView(41197, LogCategorySet.GUI_IO_FILE, + Message.WRITE_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11454 UserModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } catch (Exception e) { + MessageView error = new MessageView(41198, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11455 UserModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + if (true == removeUser) { + successRemoveUser += selectCheck[i] + " "; + } else { + removeFlag = false; + failRemoveUser += selectCheck[i] + " "; + } + } + + if (removeFlag == true) { + MessageView message = new MessageView(21088, LogCategorySet.GUI_USER_MANAGE, + "UserName : " + successRemoveUser + Message.USER_DELETE_SUCCESS); + session.setAttribute(SessionKeys.RESULT_MESSAGE, message); + session.setAttribute(SessionKeys.GUI_SYNC_STATE, SessionKeys.NO_SYNC); + response.sendRedirect(RedirectPages.USER_MANAGE); + } else { + if (successRemoveUser.length() != 0) { + MessageView error = new MessageView(21089, LogCategorySet.GUI_USER_MANAGE, + "UserName : " + successRemoveUser + Message.USER_DELETE_SUCCESS + + "
\n" + "UserName : " + failRemoveUser + + Message.USER_DELETE_FAIL); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + } else { + MessageView message = new MessageView(41199, LogCategorySet.GUI_USER_MANAGE, + "UserName : " + failRemoveUser + Message.USER_DELETE_FAIL); + session.setAttribute(SessionKeys.RESULT_MESSAGE, message); + } + response.sendRedirect(RedirectPages.USER_DELETE_FAIL); + } + + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11456 UserModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } +} diff --git a/src/src/org/ultramonkey/l7/view/VSAddServlet.java b/src/src/org/ultramonkey/l7/view/VSAddServlet.java new file mode 100644 index 0000000..62a2e9a --- /dev/null +++ b/src/src/org/ultramonkey/l7/view/VSAddServlet.java @@ -0,0 +1,285 @@ +package org.ultramonkey.l7.view; + +import java.io.IOException; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.servlet.*; +import javax.servlet.http.*; + +import org.apache.log4j.Logger; +import org.ultramonkey.l7.model.*; +import org.ultramonkey.l7.controller.*; + + + /** + *

class VSAddServlet

+ *

Copyright(c) NTT COMWARE 2008

+ * @author kubota + */ +public class VSAddServlet extends org.ultramonkey.l7.view.L7guiServletBase { + static final long serialVersionUID = 1L; + + private Logger logger = Logger.getLogger(LogCategorySet.GUI_IO); + + /* (non-Java-doc) + * @see javax.servlet.http.HttpServlet#HttpServlet() + */ + public VSAddServlet() { + super(); + // --- debug log (constructor) --- + if (logger.isDebugEnabled()) { + logger.debug("11376 class VSAddServlet created."); + } + // --- debug log (constructor) --- + } + + /* (non-Java-doc) + * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("VSAddServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in "); + buf.append("request=(" + request + "), "); + buf.append("response=(" + response + ")"); + logger.debug("11377 " + buf.toString()); + request.setCharacterEncoding("UTF-8"); + logger.debug("11378 QueryString=\"" + request.getQueryString() + "\""); + } + // --- debug log (in method) --- + + response.sendRedirect(RedirectPages.LOGIN); + + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11379 VSAddServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + + /* (non-Java-doc) + * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("VSAddServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in "); + buf.append("request=(" + request + "), "); + buf.append("response=(" + response + ")"); + logger.debug("11380 " + buf.toString()); + request.setCharacterEncoding("UTF-8"); + Enumeration keys = request.getParameterNames(); + String post = ""; + while (keys.hasMoreElements()) { + if (post.length() != 0) + post += "&"; + String key = (String) keys.nextElement(); + post += key + "=" + request.getParameter(key); + } + logger.debug("11381 PostData=\"" + post + "\""); + } + // --- debug log (in method) --- + + // check login session + super.doPost(request, response); + + HttpSession session = request.getSession(false); + if (login == false || session == null) { + if (session != null) { + MessageView error = new MessageView(41169, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + } + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11382 VSAddServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + request.setCharacterEncoding("UTF-8"); + HashMap tmpMap = (HashMap) request.getParameterMap(); + if (tmpMap == null){ + MessageView error = new MessageView(41170, LogCategorySet.GUI_VIRTUALSERVICE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11383 VSAddServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + HashMap inputVsMap = new HashMap(); + ArrayList realRemoveKey = new ArrayList(); + if (tmpMap != null) { + Iterator i = tmpMap.keySet().iterator(); + while (i.hasNext()) { + String key = (String) i.next(); + + Pattern p = Pattern.compile("rs(\\d+)_remove"); + Matcher m = p.matcher(key); + if (m.matches()) + realRemoveKey.add(Integer.parseInt(m.group(1))); + + inputVsMap.put(key, tmpMap.get(key)[0]); + } + + if (inputVsMap.containsKey(ButtonMode.REMOVE) && realRemoveKey.size() > 0) { + for (int key : realRemoveKey) { + try { + inputVsMap.remove("rs" + key + "_ip"); + inputVsMap.remove("rs" + key + "_port"); + inputVsMap.remove("rs" + key + "_weight"); + } catch (Exception e) { } + } + } + } + HashMap invalidMap = new HashMap(); + + boolean validationFlag = true; + VirtualSetting vs = new VirtualSetting(); + + // validation check + ValidationCheck val = new ValidationCheck(); + validationFlag = val.vsCheck(inputVsMap, invalidMap, vs); + + if (inputVsMap.containsKey(ButtonMode.ADD)) { + String new_ip = inputVsMap.get("new_ip"); + String new_port = inputVsMap.get("new_port"); + String new_weight = inputVsMap.get("new_weight"); + + if (new_ip != null && new_port != null && new_weight != null && + new_ip.length() != 0 && new_ip.length() != 0 && new_weight.length() != 0) { + try { + EndPoint new_real = new EndPoint(new_ip, new_port, Integer.parseInt(new_weight), 0, 0); + for (EndPoint real : vs.real) { + if (real.equals(new_real)) { + new_real = null; + MessageView error = new MessageView(41171, LogCategorySet.GUI_VIRTUALSERVICE, + Message.REAL_SERVER_EXIST); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + break; + } + } + if (new_real != null) + vs.real.add(new_real); + } catch (Exception e) { } + } + } + + if (inputVsMap.containsKey(ButtonMode.REMOVE) || inputVsMap.containsKey(ButtonMode.ADD)) { + session.setAttribute(SessionKeys.INPUT_VS, vs); + response.sendRedirect(RedirectPages.VS_ADD); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11384 VSAddServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + if (validationFlag == false) { + MessageView error = new MessageView(21074, LogCategorySet.GUI_VIRTUALSERVICE, + Message.VALIDATION_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + session.setAttribute(SessionKeys.INPUT_VS, vs); + session.setAttribute(SessionKeys.INVALID_MESSAGE, invalidMap); + + response.sendRedirect(RedirectPages.VS_ADD); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11385 VSAddServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + String vip = inputVsMap.get("vip"); + String port = inputVsMap.get("port"); + String protomod = inputVsMap.get("protomod"); + String option = inputVsMap.get("option"); + String vsName = ""; + + if ( (vip != null) && (port != null) && (protomod != null) && (option != null)){ + vsName = vip + ":" + port + " " + protomod + " " + option; + session.setAttribute(SessionKeys.VS_NAME, vsName); + } + + CommandExecuter thread = new CommandExecuter(session); + + ExecuteMode mode = ExecuteMode.NONE; + String redirectPage = ""; + + String button_mode = inputVsMap.get("button"); + // button mode : apply + if (button_mode != null && button_mode.equals(ButtonMode.APPLY)) { + mode = ExecuteMode.VS_ADD_APPLY; + redirectPage = RedirectPages.VS_ADD_EXECUTIVE; + } + // button mode : save + else if (button_mode != null && button_mode.equals(ButtonMode.SAVE)) { + mode = ExecuteMode.VS_ADD_SAVE; + redirectPage = RedirectPages.VS_ADD_EXECUTIVE; + } + // button mode : save and sync + else if (button_mode != null && button_mode.equals(ButtonMode.SAVESYNC)) { + mode = ExecuteMode.VS_ADD_SAVESYNC; + redirectPage = RedirectPages.SAVE_SYNC_EXECUTIVE; + + SessionTransData trans = new SessionTransData(); + trans.sourceURI = RedirectPages.VS_ADD; + trans.destURI = RedirectPages.STATE_INFO; + trans.errorURI = RedirectPages.VS_ADD_NG; + session.setAttribute(SessionKeys.PAGE_TRANSDATA, trans); + } + else { + MessageView error = new MessageView(41172, LogCategorySet.GUI_VIRTUALSERVICE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11386 VSAddServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + try { + thread.setExecute(mode, vs); + thread.start(); + } + catch(Exception e) { + MessageView error = new MessageView(41173, LogCategorySet.GUI_VIRTUALSERVICE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11387 VSAddServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + response.sendRedirect(redirectPage); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11388 VSAddServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } +} diff --git a/src/src/org/ultramonkey/l7/view/VSModServlet.java b/src/src/org/ultramonkey/l7/view/VSModServlet.java new file mode 100644 index 0000000..b0e70f8 --- /dev/null +++ b/src/src/org/ultramonkey/l7/view/VSModServlet.java @@ -0,0 +1,292 @@ +package org.ultramonkey.l7.view; + +import java.io.IOException; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.servlet.*; +import javax.servlet.http.*; + +import org.apache.log4j.Logger; +import org.ultramonkey.l7.model.*; +import org.ultramonkey.l7.controller.*; + +/** + *

class VSModServlet

+ *

Copyright(c) NTT COMWARE 2008

+ * @author kubota + */ +public class VSModServlet extends L7guiServletBase { + static final long serialVersionUID = 1L; + + private Logger logger = Logger.getLogger(LogCategorySet.GUI_IO); + + /* (non-Java-doc) + * @see javax.servlet.http.HttpServlet#HttpServlet() + */ + public VSModServlet() { + super(); + // --- debug log (constructor) --- + if (logger.isDebugEnabled()) { + logger.debug("11349 class VSModServlet created."); + } + // --- debug log (constructor) --- + } + + /* (non-Java-doc) + * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("VSModServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in "); + buf.append("request=(" + request + "), "); + buf.append("response=(" + response + ")"); + logger.debug("11350 " + buf.toString()); + request.setCharacterEncoding("UTF-8"); + logger.debug("11351 QueryString=\"" + request.getQueryString() + "\""); + } + // --- debug log (in method) --- + + response.sendRedirect(RedirectPages.LOGIN); + + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11352 VSModServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + + /* (non-Java-doc) + * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("VSModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in "); + buf.append("request=(" + request + "), "); + buf.append("response=(" + response + ")"); + logger.debug("11353 " + buf.toString()); + request.setCharacterEncoding("UTF-8"); + Enumeration keys = request.getParameterNames(); + String post = ""; + while (keys.hasMoreElements()) { + if (post.length() != 0) + post += "&"; + String key = (String) keys.nextElement(); + post += key + "=" + request.getParameter(key); + } + logger.debug("11354 PostData=\"" + post + "\""); + } + // --- debug log (in method) --- + + // check login session + super.doPost(request, response); + + HttpSession session = request.getSession(false); + if (login == false || session == null) { + if (session != null) { + MessageView error = new MessageView(41087, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + } + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11355 VSModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + request.setCharacterEncoding("UTF-8"); + HashMap tmpMap = (HashMap) request.getParameterMap(); + if (tmpMap == null){ + MessageView error = new MessageView(41088, LogCategorySet.GUI_VIRTUALSERVICE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11356 VSModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + HashMap inputVsMap = new HashMap(); + ArrayList realRemoveKey = new ArrayList(); + + Iterator i = tmpMap.keySet().iterator(); + while (i.hasNext()) { + String key = (String) i.next(); + + Pattern p = Pattern.compile("rs(\\d+)_remove"); + Matcher m = p.matcher(key); + if (m.matches()) + realRemoveKey.add(Integer.parseInt(m.group(1))); + + inputVsMap.put(key, tmpMap.get(key)[0]); + } + + if (inputVsMap.containsKey(ButtonMode.REMOVE) && realRemoveKey.size() > 0) { + for (int key : realRemoveKey) { + try { + inputVsMap.remove("rs" + key + "_ip"); + inputVsMap.remove("rs" + key + "_port"); + inputVsMap.remove("rs" + key + "_weight"); + } catch (Exception e) { } + } + } + + HashMap invalidMap = new HashMap(); + + boolean validationFlag = true; + VirtualSetting vs = new VirtualSetting(); + + // validation check + ValidationCheck val = new ValidationCheck(); + validationFlag = val.vsCheck(inputVsMap, invalidMap, vs); + + if (inputVsMap.containsKey(ButtonMode.ADD)) { + String new_ip = inputVsMap.get("new_ip"); + String new_port = inputVsMap.get("new_port"); + String new_weight = inputVsMap.get("new_weight"); + + if (new_ip != null && new_port != null && new_weight != null && + new_ip.length() != 0 && new_ip.length() != 0 && new_weight.length() != 0) { + try { + EndPoint new_real = new EndPoint(new_ip, new_port, Integer.parseInt(new_weight), 0, 0); + for (EndPoint real : vs.real) { + if (real.equals(new_real)) { + new_real = null; + MessageView error = new MessageView(41089, LogCategorySet.GUI_VIRTUALSERVICE, + Message.REAL_SERVER_EXIST); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + break; + } + } + if (new_real != null) + vs.real.add(new_real); + } catch (Exception e) { } + } + } + + if (inputVsMap.containsKey(ButtonMode.REMOVE) || inputVsMap.containsKey(ButtonMode.ADD)) { + session.setAttribute(SessionKeys.INPUT_VS, vs); + response.sendRedirect(RedirectPages.VS_MODIFY); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11357 VSModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + if (validationFlag == false) { + MessageView error = new MessageView(21048, LogCategorySet.GUI_VIRTUALSERVICE, + Message.VALIDATION_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + session.setAttribute(SessionKeys.INPUT_VS, vs); + session.setAttribute(SessionKeys.INVALID_MESSAGE, invalidMap); + + response.sendRedirect(RedirectPages.VS_MODIFY); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11358 VSModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + VirtualSetting oldVs = (VirtualSetting) session.getAttribute(SessionKeys.OLD_VS); + if (oldVs == null) { + MessageView error = new MessageView(41090, LogCategorySet.GUI_VIRTUALSERVICE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11359 VSModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + String vsName = oldVs.virtual.host + ":" + oldVs.virtual.port + " " + + oldVs.protomod + " " + oldVs.option; + session.setAttribute(SessionKeys.VS_NAME, vsName); + + CommandExecuter thread = new CommandExecuter(session); + + ExecuteMode mode; + String redirectPage; + + String button_mode = inputVsMap.get("button"); + // button mode : apply + if (button_mode != null && button_mode.equals(ButtonMode.APPLY)) { + mode = ExecuteMode.VS_MODIFY_APPLY; + redirectPage = RedirectPages.VS_MODIFY_EXECUTIVE; + } + // button mode : save + else if (button_mode != null && button_mode.equals(ButtonMode.SAVE)) { + mode = ExecuteMode.VS_MODIFY_SAVE; + redirectPage = RedirectPages.VS_MODIFY_EXECUTIVE; + } + // button mode : save and sync + else if (button_mode != null && button_mode.equals(ButtonMode.SAVESYNC)) { + mode = ExecuteMode.VS_MODIFY_SAVESYNC; + redirectPage = RedirectPages.SAVE_SYNC_EXECUTIVE; + + SessionTransData trans = new SessionTransData(); + trans.sourceURI = RedirectPages.VS_MODIFY; + trans.destURI = RedirectPages.STATE_INFO; + trans.errorURI = RedirectPages.VS_MODIFY_NG; + session.setAttribute(SessionKeys.PAGE_TRANSDATA, trans); + } + else { + MessageView error = new MessageView(41091, LogCategorySet.GUI_VIRTUALSERVICE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11360 VSModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + try { + thread.setExecute(mode, oldVs, vs); + thread.start(); + } + catch(Exception e) + { + MessageView error = new MessageView(41092, LogCategorySet.GUI_VIRTUALSERVICE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11361 VSModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + response.sendRedirect(redirectPage); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11362 VSModServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } +} diff --git a/src/src/org/ultramonkey/l7/view/VSRemoveServlet.java b/src/src/org/ultramonkey/l7/view/VSRemoveServlet.java new file mode 100644 index 0000000..9a2d370 --- /dev/null +++ b/src/src/org/ultramonkey/l7/view/VSRemoveServlet.java @@ -0,0 +1,263 @@ +package org.ultramonkey.l7.view; + +import java.io.IOException; +import java.util.Enumeration; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.log4j.Logger; +import org.ultramonkey.l7.controller.L7vsAdmData; +import org.ultramonkey.l7.controller.VirtualSetting; +import org.ultramonkey.l7.model.ExecuteMode; +import org.ultramonkey.l7.model.L7guiFramework; +import org.ultramonkey.l7.model.LogCategorySet; +import org.ultramonkey.l7.model.Message; +import org.ultramonkey.l7.model.MessageView; +import org.ultramonkey.l7.model.SessionTransData; + +/** + * Servlet implementation class for Servlet: VSRemoveServlet + */ + public class VSRemoveServlet extends org.ultramonkey.l7.view.L7guiServletBase{ + static final long serialVersionUID = 1L; + + private Logger logger = Logger.getLogger(LogCategorySet.GUI_IO); + + /* (non-Java-doc) + * @see javax.servlet.http.HttpServlet#HttpServlet() + */ + public VSRemoveServlet() { + super(); + // --- debug log (constructor) --- + if (logger.isDebugEnabled()) { + logger.debug("11400 class VSRemoveServlet created."); + } + // --- debug log (constructor) --- + } + + + /* (non-Java-doc) + * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("VSRemoveServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in "); + buf.append("request=(" + request + "), "); + buf.append("response=(" + response + ")"); + logger.debug("11401 " + buf.toString()); + request.setCharacterEncoding("UTF-8"); + logger.debug("11402 QueryString=\"" + request.getQueryString() + "\""); + } + // --- debug log (in method) --- + + response.sendRedirect(RedirectPages.LOGIN); + + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11403 VSRemoveServlet::doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + + /* (non-Java-doc) + * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("VSRemoveServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException in "); + buf.append("request=(" + request + "), "); + buf.append("response=(" + response + ")"); + logger.debug("11404 " + buf.toString()); + request.setCharacterEncoding("UTF-8"); + Enumeration keys = request.getParameterNames(); + String post = ""; + while (keys.hasMoreElements()) { + if (post.length() != 0) + post += "&"; + String key = (String) keys.nextElement(); + post += key + "=" + request.getParameter(key); + } + logger.debug("11405 PostData=\"" + post + "\""); + } + // --- debug log (in method) --- + + // check login session + super.doPost(request, response); + + HttpSession session = request.getSession(false); + if (login == false || session == null) { + if (session != null) { + MessageView error = new MessageView(41178, LogCategorySet.GUI_USER_AUTHENTICATION, + Message.INVALID_SESSSION); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + } + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11406 VSRemoveServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + /* + * get post data + */ + request.setCharacterEncoding("UTF-8"); + String post = request.getParameter("vs"); // ex. "10.10.10.10:80:cinsert:--cookie-name monkey" + if (post == null) { + MessageView error = new MessageView(21075, LogCategorySet.GUI_VIRTUALSERVICE, + Message.VS_SELECT_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.STATE_INFO); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11407 VSRemoveServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + String params[] = post.split(":", 4); + if (params == null || params.length != 4) { + MessageView error = new MessageView(41179, LogCategorySet.GUI_VIRTUALSERVICE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11408 VSRemoveServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + String vsName = params[0] + ":" + params[1] + " " + params[2] + " " + params[3]; + session.setAttribute(SessionKeys.VS_NAME, vsName); + + + L7guiFramework framework = new L7guiFramework(); + L7vsAdmData admDataList = framework.getAdmData(); + if (admDataList == null){ + MessageView error = new MessageView(41180, LogCategorySet.GUI_VIRTUALSERVICE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11409 VSRemoveServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + VirtualSetting vs = null; + /* + * get l7vsadm data from L7guiFramework + * & compare add l7vsadm data with post data + */ + for (int i = 0; i < admDataList.virtualSettings.size(); i++) { + VirtualSetting v = (VirtualSetting) admDataList.virtualSettings.elementAt(i); + if (v.virtual.host.equals(params[0]) && v.virtual.port.equals(params[1]) && + v.protomod.equals(params[2]) && v.option.equals(params[3])) { + vs = v; + break; + } + } + + /* + * error. no such VirtualService + */ + if (vs == null) { + MessageView error = new MessageView(41181, LogCategorySet.GUI_VIRTUALSERVICE, + Message.NO_VS); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.VS_REMOVE_NG); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11410 VSRemoveServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + + CommandExecuter thread = new CommandExecuter(session); + + ExecuteMode mode; + String redirectPage; + + + String button_mode = request.getParameter("button_remove"); + + // button mode : apply + if (button_mode != null && button_mode.equals(ButtonMode.APPLY)) { + mode = ExecuteMode.VS_REMOVE_APPLY; + redirectPage = RedirectPages.VS_REMOVE_EXECUTIVE; + } + // button mode : save + else if (button_mode != null && button_mode.equals(ButtonMode.SAVE)) { + mode = ExecuteMode.VS_REMOVE_SAVE; + redirectPage = RedirectPages.VS_REMOVE_EXECUTIVE; + } + // button mode : save and sync + else if (button_mode != null && button_mode.equals(ButtonMode.SAVESYNC)) { + mode = ExecuteMode.VS_REMOVE_SAVESYNC; + redirectPage = RedirectPages.SAVE_SYNC_EXECUTIVE; + + SessionTransData trans = new SessionTransData(); + trans.sourceURI = RedirectPages.STATE_INFO; + trans.destURI = RedirectPages.VS_REMOVE_SUCCESS; + trans.errorURI = RedirectPages.VS_REMOVE_NG; + session.setAttribute(SessionKeys.PAGE_TRANSDATA, trans); + } + else { + MessageView error = new MessageView(41182, LogCategorySet.GUI_VIRTUALSERVICE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11411 VSRemoveServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + + try { + thread.setExecute(mode,vs); + thread.start(); + } + catch(Exception e) + { + MessageView error = new MessageView(41183, LogCategorySet.GUI_VIRTUALSERVICE, + Message.UNEXPECTED_ERROR); + session.setAttribute(SessionKeys.RESULT_MESSAGE, error); + response.sendRedirect(RedirectPages.LOGIN); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11412 VSRemoveServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } + response.sendRedirect(redirectPage); + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + logger.debug("11413 VSRemoveServlet::doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException out"); + } + // --- debug log (out method) --- + return; + } +} diff --git a/src/src/org/ultramonkey/l7/view/ValidationCheck.java b/src/src/org/ultramonkey/l7/view/ValidationCheck.java new file mode 100644 index 0000000..d62f689 --- /dev/null +++ b/src/src/org/ultramonkey/l7/view/ValidationCheck.java @@ -0,0 +1,676 @@ +package org.ultramonkey.l7.view; + +import java.util.HashMap; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.log4j.Logger; +import org.ultramonkey.l7.controller.EndPoint; +import org.ultramonkey.l7.controller.VirtualSetting; +import org.ultramonkey.l7.model.LogCategorySet; +import org.ultramonkey.l7.model.Message; + +/** + *

+ * class ValidationCheck + *

+ *

+ * Copyright(c) NTT COMWARE 2008 + *

+ * + * @author kubota + */ +public class ValidationCheck { + + private Logger logger = Logger.getLogger(LogCategorySet.GUI_IO); + + public ValidationCheck() { + // --- debug log (constructor) --- + if (logger.isDebugEnabled()) { + logger.debug("11336 class ValidationCheck created."); + } + // --- debug log (constructor) --- + } + + /** + * + *

+ * validationCheck method + *

+ * + * @param inputVsMap + * @param invalidMap + * @param vs + */ + public boolean vsCheck(HashMap inputVsMap, + HashMap invalidMap, VirtualSetting vs) { + // --- debug log (in method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("ValidationCheck::vsCheck(HashMap inputVsMap, HashMap invalidMap, VirtualSetting vs) in "); + buf.append("inputVsMap=(" + inputVsMap + "), "); + buf.append("invalidMap=(" + invalidMap + "), "); + buf.append("vs=(" + vs + ")"); + logger.debug("11337 " + buf.toString()); + } + // --- debug log (in method) --- + + boolean validationFlag = true; + + final int MIN_IP = 0; + final int MAX_IP = 255; + final int PARTITION = 4; + final int MIN_PORT = 1; + final int MAX_PORT = 65535; + final int MAX_PORT_LENGTH = 10; + final int MAX_OPTION_LENGTH = 127; + final long MIN_QOS_SERVICE = 0L; + final long MAX_QOS_SERVICE = 999L; + final long MIN_QOS_CON = 0L; + final long MAX_QOS_CON = 999L; + final int MIN_CON = 0; + final int MAX_CON = 100000; + final int MIN_TIME_OUT = 1; + final int MAX_TIME_OUT = Integer.MAX_VALUE; + final int MAX_CHECK_TYPE_LENGTH = 10; + final int DOWN_CALLBACK_LENGTH = 127; + final int UP_CALLBACK_LENGTH = 127; + final int MIN_CHECKPORT = 1; + final int MAX_CHECKPORT = 65535; + final int MAX_REQUEST_LENGTH = 127; + final int MAX_RECEIVE_LENGTH = 127; + final int MAX_VIRTUAL_HOST_LENGTH = 127; + final int MAX_LOGIN_USER_LENGTH = 32; + final int MAX_LOGIN_PASS_LENGTH = 32; + final int MAX_DB_LENGTH = 32; + final int MIN_WEIGHT = 0; + final int MAX_WEIGHT = 100; + + // VirtualService IP validationCheck + String vip = inputVsMap.get("vip"); + if (vip == null || vip.length() == 0) { + invalidMap.put("vip", Message.REQUIED_ITEM); + validationFlag = false; + } else { + if (vip.equals("0.0.0.0")) { + invalidMap.put("vip", Message.INVALID_VALUE); + validationFlag = false; + } else { + String tmp_vip[] = vip.split("\\.", PARTITION); + int int_vip = 0; + + if (tmp_vip.length != PARTITION) { + invalidMap.put("vip", Message.INVALID_VALUE); + validationFlag = false; + } else { + for (int i = 0; i < PARTITION; i++) { + try { + int_vip = Integer.parseInt(tmp_vip[i]); + if ((int_vip < MIN_IP) || (int_vip > MAX_IP)) { + invalidMap.put("vip", Message.INVALID_VALUE); + validationFlag = false; + break; + } + } catch (NumberFormatException e) { + invalidMap.put("vip", Message.INVALID_VALUE); + validationFlag = false; + break; + } + } + } + } + } + if (vip != null) + vs.virtual.host = vip; + + // VirtualService Port validationCheck + String port = inputVsMap.get("port"); + if (port == null || port.length() == 0) { + invalidMap.put("port", Message.REQUIED_ITEM); + validationFlag = false; + } else { + try { + int int_port = Integer.parseInt(port); + if ((int_port < MIN_PORT) || ((int_port > MAX_PORT))) { + invalidMap.put("port", Message.INVALID_VALUE); + validationFlag = false; + } + } catch (NumberFormatException e) { + Pattern pattern = Pattern.compile("[^\\x20-\\x7e]"); + Matcher matcher = pattern.matcher(port); + if ((port.length() > MAX_PORT_LENGTH) || matcher.find()) { + invalidMap.put("port", Message.INVALID_VALUE); + validationFlag = false; + } + } + vs.virtual.port = port; + } + + // Protomod validationCheck + String protomod = inputVsMap.get("protomod"); + if (protomod != null && protomod.length() == 0) { + invalidMap.put("protomod", Message.REQUIED_ITEM); + validationFlag = false; + } else if (protomod == null + || (!protomod.equals("cinsert") && !protomod.equals("url") + && !protomod.equals("sslid") && !protomod + .equals("sessionless"))) { + invalidMap.put("protomod", Message.INVALID_VALUE); + validationFlag = false; + } + if (protomod != null) + vs.protomod = protomod; + + // Persistence option validationCheck + String option = inputVsMap.get("option"); + if (option != null && option.length() > 0) { + Pattern pattern = Pattern.compile("[^\\x20-\\x7e]"); + Matcher matcher = pattern.matcher(option); + if ((option.length() > MAX_OPTION_LENGTH) || matcher.find()) { + invalidMap.put("option", Message.INVALID_VALUE); + validationFlag = false; + } + } + if (option != null) + vs.option = option; + if (vs.getKey() == null) { + invalidMap.put("option", Message.INVALID_VALUE); + validationFlag = false; + } + + // Scheduler Type validationCheck + String sched = inputVsMap.get("sched"); + if (sched != null && sched.length() == 0) { + invalidMap.put("sched", Message.REQUIED_ITEM); + validationFlag = false; + } else if (sched == null + || (!sched.equals("rr") && !sched.equals("wrr") && !sched + .equals("lc"))) { + invalidMap.put("sched", Message.INVALID_VALUE); + validationFlag = false; + } + if (sched != null) + vs.sched = sched; + + // QoS (per Virtual Service) validationCheck + String qos_service = inputVsMap.get("qos_service"); + String qos_service_unit = inputVsMap.get("qos_service_unit"); + if (qos_service != null && qos_service.length() > 0) { + long long_qos_service = 0; + try { + long_qos_service = Long.parseLong(qos_service); + if ((long_qos_service < MIN_QOS_SERVICE) + || (long_qos_service > MAX_QOS_SERVICE)) { + invalidMap.put("qos_service", Message.INVALID_VALUE); + validationFlag = false; + } else { + if (qos_service_unit != null && qos_service_unit.equals("bps")) { + } else if (qos_service_unit != null && qos_service_unit.equals("Kbps")) { + long_qos_service = long_qos_service * 1000; + } else if (qos_service_unit != null && qos_service_unit.equals("Mbps")) { + long_qos_service = long_qos_service * 1000000; + } else if (qos_service_unit != null && qos_service_unit.equals("Gbps")) { + long_qos_service = long_qos_service * 1000000000; + } else { + invalidMap.put("qos_service", Message.INVALID_VALUE); + validationFlag = false; + } + } + } catch (NumberFormatException e) { + invalidMap.put("qos_service", Message.INVALID_VALUE); + validationFlag = false; + } + vs.qosservice = long_qos_service; + } + + // QoS (per Client) validationCheck + String qos_conn = inputVsMap.get("qos_conn"); + String qos_conn_unit = inputVsMap.get("qos_conn_unit"); + if (qos_conn != null && qos_conn.length() > 0) { + long long_qos_conn = 0; + try { + long_qos_conn = Long.parseLong(qos_conn); + if ((long_qos_conn < MIN_QOS_CON) + || (long_qos_conn > MAX_QOS_CON)) { + invalidMap.put("qos_conn", Message.INVALID_VALUE); + validationFlag = false; + } else { + if (qos_conn_unit != null && qos_conn_unit.equals("bps")) { + } else if (qos_conn_unit != null && qos_conn_unit.equals("Kbps")) { + long_qos_conn = long_qos_conn * 1000; + } else if (qos_conn_unit != null && qos_conn_unit.equals("Mbps")) { + long_qos_conn = long_qos_conn * 1000000; + } else if (qos_conn_unit != null && qos_conn_unit.equals("Gbps")) { + long_qos_conn = long_qos_conn * 1000000000; + } else { + invalidMap.put("qos_conn", Message.INVALID_VALUE); + validationFlag = false; + } + } + } catch (NumberFormatException e) { + invalidMap.put("qos_conn", Message.INVALID_VALUE); + validationFlag = false; + } + vs.qosclient = long_qos_conn; + } + + // Max Connections validationCheck + String max_conn = inputVsMap.get("max_conn"); + if (max_conn != null && max_conn.length() > 0) { + int int_max_conn = 0; + try { + int_max_conn = Integer.parseInt(max_conn); + if ((int_max_conn < MIN_CON) || (int_max_conn > MAX_CON)) { + invalidMap.put("max_conn", Message.INVALID_VALUE); + validationFlag = false; + } + } catch (NumberFormatException e) { + invalidMap.put("max_conn", Message.INVALID_VALUE); + validationFlag = false; + } + vs.maxconn = int_max_conn; + } + + // Timeout validationCheck + String timeout = inputVsMap.get("timeout"); + if (timeout != null && timeout.length() > 0) { + int int_timeout = 0; + try { + int_timeout = Integer.parseInt(timeout); + if ((int_timeout < MIN_TIME_OUT) + || (int_timeout > MAX_TIME_OUT)) { + invalidMap.put("timeout", Message.INVALID_VALUE); + validationFlag = false; + } + } catch (NumberFormatException e) { + invalidMap.put("timeout", Message.INVALID_VALUE); + validationFlag = false; + } + vs.timeout = int_timeout; + } + + // Check Type validationCheck + String check_type = inputVsMap.get("check_type"); + if (check_type != null && (check_type.length() > 0) + && (check_type.length() < MAX_CHECK_TYPE_LENGTH)) { + Pattern pattern = Pattern.compile("[0-9]"); + Matcher matcher = pattern.matcher(check_type); + if (!matcher.matches() && !check_type.equals("negotiate") + && !check_type.equals("connect") + && !check_type.equals("ping") && !check_type.equals("off") + && !check_type.equals("on")) { + invalidMap.put("check_type", Message.INVALID_VALUE); + validationFlag = false; + } + } + if (check_type != null) + vs.checktype = check_type; + + // Check Service validationCheck + String check_service = inputVsMap.get("check_service"); + if (check_service != null && check_service.length() > 0) { + if (!check_service.equals("ftp") && !check_service.equals("smtp") + && !check_service.equals("dns") + && !check_service.equals("http") + && !check_service.equals("pop") + && !check_service.equals("nntp") + && !check_service.equals("imap") + && !check_service.equals("ldap") + && !check_service.equals("https") + && !check_service.equals("mysql") + && !check_service.equals("pgsql") + && !check_service.equals("dns") + && !check_service.equals("sip") + && !check_service.equals("none")) { + invalidMap.put("check_service", Message.INVALID_VALUE); + validationFlag = false; + } + } + if (check_service != null) + vs.service = check_service; + + // Quiescent validationCheck + String quiescent = inputVsMap.get("quiescent"); + if (quiescent != null && quiescent.length() > 0) { + if (!quiescent.equals("yes") && !quiescent.equals("no")) { + invalidMap.put("quiescent", Message.INVALID_VALUE); + validationFlag = false; + } + } + if (quiescent != null) + vs.quiescent = quiescent; + + // Real Server Down Callback validationCheck + String down_callback = inputVsMap.get("down_callback"); + if ( (down_callback != null) && down_callback.length() > 0){ + Pattern pattern = Pattern.compile("[^\\x20-\\x7e]"); + Matcher matcher = pattern.matcher(down_callback); + if ((down_callback.length() > DOWN_CALLBACK_LENGTH) || matcher.find()){ + invalidMap.put("down_callback", Message.INVALID_VALUE); + validationFlag = false; + } + } + if (down_callback != null) + vs.downcallback = down_callback; + + + // Real Server Up Callback validationCheck + String up_callback = inputVsMap.get("up_callback"); + if ( (up_callback != null) && (up_callback.length() > 0) ){ + Pattern pattern = Pattern.compile("[^\\x20-\\x7e]"); + Matcher matcher = pattern.matcher(up_callback); + if ( (up_callback.length() > UP_CALLBACK_LENGTH) || matcher.find() ) { + invalidMap.put("up_callback", Message.INVALID_VALUE); + validationFlag = false; + } + } + if (up_callback != null) + vs.upcallback = up_callback; + + + // CheckPort validationCheck + String check_port = inputVsMap.get("check_port"); + if (check_port != null && check_port.length() > 0) { + int int_checkport = 0; + try { + int_checkport = Integer.parseInt(check_port); + if ((int_checkport < MIN_CHECKPORT) + || (int_checkport > MAX_CHECKPORT)) { + invalidMap.put("check_port", Message.INVALID_VALUE); + validationFlag = false; + } + } catch (NumberFormatException e) { + invalidMap.put("check_port", Message.INVALID_VALUE); + validationFlag = false; + } + vs.checkport = int_checkport; + } + + + // Request Path validationCheck + String request = inputVsMap.get("request"); + if (request != null && request.length() > 0) { + Pattern pattern = Pattern.compile("[^\\x20-\\x7e]"); + Matcher matcher = pattern.matcher(request); + if ( (request.length() > MAX_REQUEST_LENGTH) || matcher.find() ) { + invalidMap.put("request", Message.INVALID_VALUE); + validationFlag = false; + } + } + if (request != null) + vs.request = request; + + + // Receive String validationCheck + String receive = inputVsMap.get("receive"); + if (receive != null && receive.length() > 0) { + Pattern pattern = Pattern.compile("[^\\x20-\\x7e]"); + Matcher matcher = pattern.matcher(receive); + if ( (receive.length() > MAX_RECEIVE_LENGTH) || matcher.find() ) { + invalidMap.put("receive", Message.INVALID_VALUE); + validationFlag = false; + } + } + if (receive != null) + vs.receive = receive; + + + // HTTP Method validationCheck + String method = inputVsMap.get("method"); + if (method != null && method.length() > 0) { + if (!method.equals("GET") && !method.equals("HEAD")) { + invalidMap.put("method", Message.INVALID_VALUE); + validationFlag = false; + } + } + if (method != null) + vs.httpmethod = method; + + // Virtual Host validationCheck + String virtual_host = inputVsMap.get("virtual_host"); + if (virtual_host != null && virtual_host.length() > 0) { + Pattern pattern = Pattern.compile("[^\\x20-\\x7e]"); + Matcher matcher = pattern.matcher(virtual_host); + if ( (virtual_host.length() > MAX_VIRTUAL_HOST_LENGTH) || matcher.find()) { + invalidMap.put("virtual_host", Message.INVALID_VALUE); + validationFlag = false; + } + } + if (virtual_host != null) + vs.virtualhost = virtual_host; + + + // Login Username validationCheck + String login_user = inputVsMap.get("login_user"); + if ( (login_user != null) && (login_user.length() > 0) ) { + Pattern pattern = Pattern.compile("[^\\x20-\\x7e]"); + Matcher matcher = pattern.matcher(login_user); + + if ( (login_user.length() > MAX_LOGIN_USER_LENGTH) || matcher.find() ) { + invalidMap.put("login_user", Message.INVALID_VALUE); + validationFlag = false; + } + } + if (login_user != null) + vs.login = login_user; + + + // Login Password validationCheck + String login_pass = inputVsMap.get("login_pass"); + if ( (login_pass != null) && (login_pass.length() > 0) ){ + Pattern pattern = Pattern.compile("[^\\x20-\\x7e]"); + Matcher matcher = pattern.matcher(login_pass); + if ( (login_pass.length() > MAX_LOGIN_PASS_LENGTH) || matcher.find() ) { + invalidMap.put("login_pass", Message.INVALID_VALUE); + validationFlag = false; + } + } + if (login_pass != null) + vs.passwd = login_pass; + + + // Database Name validationCheck + String db = inputVsMap.get("db"); + if ( (db != null) && (db.length() > 0) ) { + Pattern pattern = Pattern.compile("[^\\x20-\\x7e]"); + Matcher matcher = pattern.matcher(db); + if ( (db.length() > MAX_DB_LENGTH) || matcher.find() ) { + invalidMap.put("db", Message.INVALID_VALUE); + validationFlag = false; + } + } + if (db != null) + vs.database = db; + + + // RealServer Info(IP,Port.Weight) validationCheck + int num = 1; + while (true) { + // Serch EndPoint + String rs_ip = inputVsMap.get("rs" + num + "_ip"); + if (rs_ip == null) + break; + + String rs_port = inputVsMap.get("rs" + num + "_port"); + if (rs_port == null) + break; + + String rs_weight = inputVsMap.get("rs" + num + "_weight"); + if (rs_weight == null) + break; + + if (rs_ip.length() == 0 && rs_port.length() == 0 + && rs_weight.length() == 0) { + num++; + continue; + } else { + // IP + if (rs_ip.length() == 0) { + invalidMap.put("rs" + num + "_ip", Message.REQUIED_ITEM); + validationFlag = false; + } else { + if (rs_ip.equals("0.0.0.0")) { + invalidMap.put("rs" + num + "_ip", Message.INVALID_VALUE); + validationFlag = false; + } else { + String tmp_rs_addr[] = rs_ip.split("\\.", PARTITION); + int int_rs_addr = 0; + + if (tmp_rs_addr.length != PARTITION) { + invalidMap.put("rs" + num + "_ip", + Message.INVALID_VALUE); + validationFlag = false; + } else { + for (int i = 0; i < PARTITION; i++) { + try { + int_rs_addr = Integer + .parseInt(tmp_rs_addr[i]); + if ((int_rs_addr < MIN_IP) + || (int_rs_addr > MAX_IP)) { + invalidMap.put("rs" + num + "_ip", + Message.INVALID_VALUE); + validationFlag = false; + break; + } + } catch (NumberFormatException e) { + invalidMap.put("rs" + num + "_ip", + Message.INVALID_VALUE); + validationFlag = false; + break; + } + } + } + } + } + + // Port + if (rs_port.length() == 0) { + invalidMap.put("rs" + num + "_port", Message.REQUIED_ITEM); + validationFlag = false; + } else { + try { + int int_rs_port = Integer.parseInt(rs_port); + if ((int_rs_port < MIN_PORT) + || (int_rs_port > MAX_PORT)) { + invalidMap.put("rs" + num + "_port", + Message.INVALID_VALUE); + validationFlag = false; + } + } catch (NumberFormatException e) { + Pattern pattern = Pattern.compile("[^\\x20-\\x7e]"); + Matcher matcher = pattern.matcher(rs_port); + if ((rs_port.length() > MAX_PORT_LENGTH) || matcher.find()) { + invalidMap.put("rs" + num + "_port", Message.INVALID_VALUE); + validationFlag = false; + } + } + } + + // Weight + int int_rs_weight = 1; + if (rs_weight.length() == 0) { + invalidMap + .put("rs" + num + "_weight", Message.REQUIED_ITEM); + validationFlag = false; + } else { + try { + int_rs_weight = Integer.parseInt(rs_weight); + if ((int_rs_weight < MIN_WEIGHT) + || (int_rs_weight > MAX_WEIGHT)) { + invalidMap.put("rs" + num + "_weight", + Message.INVALID_VALUE); + validationFlag = false; + } + } catch (NumberFormatException e) { + invalidMap.put("rs" + num + "_weight", + Message.INVALID_VALUE); + validationFlag = false; + } + } + + EndPoint rs = new EndPoint(rs_ip, rs_port, int_rs_weight, + 0, 0); + vs.real.add(rs); + } + num++; + } + + // SorryServer_IP validationCheck + String sorry_ip = inputVsMap.get("sorry_ip"); + if (sorry_ip != null && sorry_ip.length() > 0) { + if (sorry_ip.equals("0.0.0.0")) { + invalidMap.put("sorry_ip", Message.INVALID_VALUE); + validationFlag = false; + } else { + String tmp_sorry_ip[] = sorry_ip.split("\\.", PARTITION); + int int_sorry_ip = 0; + if (tmp_sorry_ip.length != PARTITION) { + invalidMap.put("sorry_ip", Message.INVALID_VALUE); + validationFlag = false; + } else { + for (int i = 0; i < PARTITION; i++) { + try { + int_sorry_ip = Integer.parseInt(tmp_sorry_ip[i]); + if ((int_sorry_ip < MIN_IP) + || (int_sorry_ip > MAX_IP)) { + invalidMap.put("sorry_ip", + Message.INVALID_VALUE); + validationFlag = false; + break; + } + } catch (NumberFormatException e) { + invalidMap.put("sorry_ip", Message.INVALID_VALUE); + validationFlag = false; + break; + } + } + } + } + vs.sorryserver.host = sorry_ip; + } + + // SorryServer Port validationCheck + String sorry_port = inputVsMap.get("sorry_port"); + if (sorry_port != null && sorry_port.length() > 0) { + try { + int int_sorry_port = Integer.parseInt(sorry_port); + if ((int_sorry_port < MIN_PORT) || (int_sorry_port > MAX_PORT)) { + invalidMap.put("sorry_port", Message.INVALID_VALUE); + validationFlag = false; + } + } catch (NumberFormatException e) { + Pattern pattern = Pattern.compile("[^\\x20-\\x7e]"); + Matcher matcher = pattern.matcher(sorry_port); + if ((sorry_port.length() > MAX_PORT_LENGTH) || matcher.find()) { + invalidMap.put("sorry_port", Message.INVALID_VALUE); + validationFlag = false; + } + } + vs.sorryserver.port = sorry_port; + } + + // SorryFlag validationCheck + String sorry_flag = inputVsMap.get("sorry_flag"); + vs.sorryflag = false; + if (sorry_flag != null && sorry_flag.length() > 0) { + if (sorry_flag.equals("on")) { + vs.sorryflag = true; + } else if (sorry_flag.equals("off")) { + vs.sorryflag = false; + } else { + invalidMap.put("sorry_flag", Message.INVALID_VALUE); + validationFlag = false; + } + } + + // --- debug log (out method) --- + if (logger.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("ValidationCheck::vsCheck(HashMap inputVsMap, HashMap invalidMap, VirtualSetting vs) out "); + buf.append("return=" + validationFlag); + logger.debug("11338 " + buf.toString()); + } + // --- debug log (out method) --- + return validationFlag; + } +}