Commit ef338606 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

1. Made asynchronic packets auditing. JM-25

2. Fixed bug while starting up AuditManager.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@435 b35dd754-fafc-0310-a699-88a17e54d16e
parent 558b097a
......@@ -88,6 +88,24 @@ public interface AuditManager {
*/
void setMaxFileCount(int count);
/**
* Returns the time in milliseconds between successive executions of the task that will save
* the queued audited packets to a permanent store.
*
* @return the time in milliseconds between successive executions of the task that will save
* the queued audited packets to a permanent store.
*/
int getLogTimeout();
/**
* Sets the time in milliseconds between successive executions of the task that will save
* the queued audited packets to a permanent store.
*
* @param logTimeout the time in milliseconds between successive executions of the task that will save
* the queued audited packets to a permanent store.
*/
void setLogTimeout(int logTimeout);
/**
* <p>Determines if the server will audit all message packets.</p>
* <p>This is a speed optimization and convenience for logging all message packets
......
......@@ -11,9 +11,6 @@
package org.jivesoftware.messenger.audit;
import org.jivesoftware.messenger.IQ;
import org.jivesoftware.messenger.Message;
import org.jivesoftware.messenger.Presence;
import org.jivesoftware.messenger.XMPPPacket;
/**
......@@ -34,44 +31,30 @@ public interface Auditor {
*/
void audit(XMPPPacket packet);
/**
* Audit a message packet.
*
* @param packet the packet being audited.
*/
void audit(Message packet);
/**
* Audit a presence packet.
*
* @param packet the packet being audited.
* @param transition the presence transition type from AuditManager.
*/
void audit(Presence packet, int transition);
/**
* Audit an IQ packet.
*
* @param packet the packet being audited.
*/
void audit(IQ packet);
/**
* Audit any packet that was dropped (undeliverables, etc).
*
* @param packet the packet that was dropped.
*/
void auditDroppedPacket(XMPPPacket packet);
//void auditDroppedPacket(XMPPPacket packet);
/**
* Audit a non-packet event.
*
* @param event the event being audited.
*/
void audit(AuditEvent event);
//void audit(AuditEvent event);
/**
* Prepares the auditor for system shutdown.
*/
void close();
void stop();
/**
* Returns the number of queued packets that are still in memory and need to be saved to a
* permanent store.
*
* @return the number of queued packets that are still in memory.
*/
int getQueuedPacketsNumber();
}
\ No newline at end of file
......@@ -30,8 +30,10 @@ public class AuditManagerImpl extends BasicModule implements AuditManager {
private AuditorImpl auditor = null;
private int maxSize;
private int maxCount;
private int logTimeout;
private static final int MAX_FILE_SIZE = 10;
private static final int MAX_FILE_COUNT = 10;
private static final int DEFAULT_LOG_TIMEOUT = 120000;
public AuditManagerImpl() {
super("Audit Manager");
......@@ -63,6 +65,16 @@ public class AuditManagerImpl extends BasicModule implements AuditManager {
JiveGlobals.setProperty("xmpp.audit.maxsize", Integer.toString(size));
}
public int getLogTimeout() {
return logTimeout;
}
public void setLogTimeout(int logTimeout) {
this.logTimeout = logTimeout;
auditor.setLogTimeout(logTimeout);
JiveGlobals.setProperty("xmpp.audit.logtimeout", Integer.toString(logTimeout));
}
public int getMaxFileCount() {
return maxCount;
}
......@@ -135,11 +147,11 @@ public class AuditManagerImpl extends BasicModule implements AuditManager {
public void initialize(Container container) {
super.initialize(container);
setEnabled(JiveGlobals.getBooleanProperty("xmpp.audit.active"));
setEnabled(JiveGlobals.getBooleanProperty("xmpp.audit.message"));
setEnabled(JiveGlobals.getBooleanProperty("xmpp.audit.presence"));
setEnabled(JiveGlobals.getBooleanProperty("xmpp.audit.iq"));
setEnabled(JiveGlobals.getBooleanProperty("xmpp.audit.xpath"));
enabled = JiveGlobals.getBooleanProperty("xmpp.audit.active");
auditMessage = JiveGlobals.getBooleanProperty("xmpp.audit.message");
auditPresence = JiveGlobals.getBooleanProperty("xmpp.audit.presence");
auditIQ = JiveGlobals.getBooleanProperty("xmpp.audit.iq");
auditXPath = JiveGlobals.getBooleanProperty("xmpp.audit.xpath");
// TODO: load xpath values!
// String[] filters = context.getProperties("xmpp.audit.filter.xpath");
// for (int i = 0; i < filters.length; i++) {
......@@ -147,13 +159,15 @@ public class AuditManagerImpl extends BasicModule implements AuditManager {
// }
maxSize = JiveGlobals.getIntProperty("xmpp.audit.maxsize", MAX_FILE_SIZE);
maxCount = JiveGlobals.getIntProperty("xmpp.audit.maxcount", MAX_FILE_COUNT);
logTimeout = JiveGlobals.getIntProperty("xmpp.audit.logtimeout", DEFAULT_LOG_TIMEOUT);
auditor = new AuditorImpl(this);
auditor.setMaxValues(maxSize, maxCount);
auditor.setLogTimeout(logTimeout);
}
public void stop() {
if (auditor != null) {
auditor.close();
auditor.stop();
}
}
}
......@@ -44,6 +44,7 @@
String[] xpathQuery = ParamUtils.getParameters(request,"xpathQuery");
String maxCount = ParamUtils.getParameter(request,"maxCount");
String maxSize = ParamUtils.getParameter(request,"maxSize");
String logTimeout = ParamUtils.getParameter(request,"logTimeout");
// Get an audit manager:
AuditManager auditManager = (AuditManager)admin.getServiceLookup().lookup(AuditManager.class);
......@@ -73,6 +74,11 @@
} catch (Exception e){
errors.put("maxSize","maxSize");
}
try {
auditManager.setLogTimeout(Integer.parseInt(logTimeout) * 1000);
} catch (Exception e){
errors.put("logTimeout","logTimeout");
}
// All done, redirect
if (errors.size() == 0){
%>
......@@ -101,6 +107,7 @@
auditXPath = auditManager.isAuditXPath();
maxCount = Integer.toString(auditManager.getMaxFileCount());
maxSize = Integer.toString(auditManager.getMaxFileSize());
logTimeout = Integer.toString(auditManager.getLogTimeout() / 1000);
}
%>
......@@ -184,6 +191,24 @@ and IQ packets are primarily useful for tracing and troubleshooting XMPP deploym
</td>
</tr>
<tr valign="top">
<td width="1%" nowrap class="c1">
Flush Interval (seconds):
</td>
<td width="99%">
<input type="text" size="15" maxlength="50" name="logTimeout"
value="<%= ((logTimeout != null) ? logTimeout : "") %>">
<% if (errors.get("logTimeout") != null) { %>
<span class="jive-error-text">
Please enter a valid number.
</span>
<% } %>
</td>
</tr>
<tr valign="top">
<td width="1%" nowrap class="c1">
Packets to audit:
......@@ -230,6 +255,14 @@ and IQ packets are primarily useful for tracing and troubleshooting XMPP deploym
</table>
</td>
</tr>
<tr valign="top">
<td width="1%" nowrap class="c1">
Queued packets:
</td>
<td width="99%">
<%= auditManager.getAuditor().getQueuedPacketsNumber() %>
</td>
</tr>
</table>
</td>
</tr>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment