Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #3222 : improve database management feedback #108

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -309,18 +309,21 @@ case class AutomaticReportsCleaning(

def isIdle : Boolean = currentState == IdleCleaner

private[this] def activeCleaning(date : DateTime, message : DatabaseCleanerMessage) : Unit = {
private[this] def formatDate(date:DateTime) : String = date.toString("yyyy-MM-dd HH:mm")

private[this] def activeCleaning(date : DateTime, message : DatabaseCleanerMessage, kind:String) : Unit = {
val formattedDate = formatDate(date)
cleanaction.act(date) match {
case eb:EmptyBox =>
// Error while cleaning, should launch again
reportLogger.error("Error while processing database %s, cause is : %s ".format(cleanaction.continue.toLowerCase(),eb))
reportLogger.error("Relaunching %s process".format(cleanaction.continue.toLowerCase()))
reportLogger.error("Reports database: Error while processing database %s, cause is: %s ".format(cleanaction.continue.toLowerCase(),eb))
reportLogger.error("Reports database: Relaunching %s %s process for all reports before %s".format(kind.toLowerCase,cleanaction.continue.toLowerCase(), formattedDate))
(this) ! message
case Full(res) =>
if (res==0)
reportLogger.info("reports %s has nothing to do".format(cleanaction.name.toLowerCase()))
reportLogger.info("Reports database: %s %s completed for all reports before %s, no reports to %s".format(kind,cleanaction.name.toLowerCase(), formattedDate,cleanaction.name.toLowerCase()))
else
reportLogger.info("reports %s has %s %d reports".format(cleanaction.name.toLowerCase(),cleanaction.past.toLowerCase(),res))
reportLogger.info("Reports database: %s %s completed for all reports before %s, %d reports %s".format(kind,cleanaction.name.toLowerCase(),formattedDate,res,cleanaction.past.toLowerCase()))
lastRun=DateTime.now
currentState = IdleCleaner
}
Expand Down Expand Up @@ -363,25 +366,27 @@ case class AutomaticReportsCleaning(

case ActiveCleaner =>
val now = DateTime.now
val target = now.minusDays(ttl)
val formattedDate = formatDate(target)
logger.trace("***** %s Database *****".format(cleanaction.name))
reportLogger.info("Automatic start %s".format(cleanaction.continue.toLowerCase()))
activeCleaning(now.minusDays(ttl),CleanDatabase)
reportLogger.info("Reports database: Automatic %s started for all reports before %s".format(cleanaction.name.toLowerCase(),formattedDate))
activeCleaning(target,CleanDatabase,"automatic")

case IdleCleaner => ()
}
}

case ManualLaunch(date) => {

val formattedDate = formatDate(date)
logger.trace("***** Ask to launch manual database %s *****".format(cleanaction.name))
currentState match {
case IdleCleaner =>
currentState = ActiveCleaner
logger.trace("***** Start manual %s database *****".format(cleanaction.name))
reportLogger.info("start manual %s".format(cleanaction.continue.toLowerCase()))
activeCleaning(date,ManualLaunch(date))
reportLogger.info("Reports database: Manual %s started for all reports before %s ".format(cleanaction.name.toLowerCase(), formattedDate))
activeCleaning(date,ManualLaunch(date),"Manual")

case ActiveCleaner => reportLogger.info("A database cleaning is already running, please try later")
case ActiveCleaner => reportLogger.info("Reports database: A database cleaning is already running, please try later")
}
}
case _ =>
Expand Down
2 changes: 1 addition & 1 deletion rudder-web/src/main/scala/bootstrap/liftweb/Boot.scala
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class Boot extends Loggable {
>> LocGroup("administrationGroup")
>> TestAccess ( () => userIsAllowed(Write("administration"),"/secure/administration/eventLogs") )

, Menu("databaseManagement", <span>Database Management</span>) /
, Menu("databaseManagement", <span>Reports Database</span>) /
"secure" / "administration" / "databaseManagement"
>> LocGroup("administrationGroup")
>> TestAccess ( () => userIsAllowed(Write("administration"),"/secure/administration/eventLogs") )
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<lift:surround with="menu/menu-administration" at="content">

<head>
<title>Rudder - Database Management</title>
<title>Rudder - Reports database</title>
<script type="text/javascript">
// <![CDATA[
var initReportDatepickler = function(selector) {
Expand All @@ -19,7 +19,7 @@
</head>

<div class="portlet">
<div class="portlet-header">Database management</div>
<div class="portlet-header">Reports database</div>
<div class="portlet-content">

<div class="intro">
Expand Down Expand Up @@ -174,11 +174,6 @@
<td colspan="2">
<form class="lift:form.ajax">
<div>
<div id="cleanResult" style="display:none">
<img src="/images/icWarn.png" alt="Warning!" height="25" width="25" class="warnicon"
style="vertical-align: middle; padding: 0px 0px 2px 0px;"/>
<b id="cleanResultText"></b>
</div>
<span id="cleanParam">
<span id="modeSelector"/> all reports older than: <input
id="reportFromDate" value="" />
Expand All @@ -190,6 +185,12 @@
<lift:error_msg class="error" />
</lift:Msgs>
</form>
<br/>
<div id="cleanResult" style="display:none; float:left">
<img src="/images/icValid.jpg" alt="Warning!" height="25" width="25" class="warnicon"
style="vertical-align: middle; padding: 0px 0px 2px 0px;"/>
<b id="cleanResultText"></b>
</div>
</td>
</tr>
</table>
Expand Down