Commit 0546a6a4 authored by Leon Roy's avatar Leon Roy Committed by leonroy

IN PROGRESS - issue OF-651: Monitoring plugin should have an option to purge and restrict

http://issues.igniterealtime.org/browse/OF-651

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@13652 b35dd754-fafc-0310-a699-88a17e54d16e
parent dd960eeb
......@@ -78,6 +78,7 @@ archive.settings.max.time = Max Time
archive.settings.max.time.description = The maximum number of minutes a conversation can last before it's ended.
archive.settings.max.age = Max Message Age
archive.settings.max.age.description = The maximum number of days to keep messages before purging them from the database.
archive.settings.max.age.warning = NOTE: Setting this value above 0 will PERMANENTLY DELETE any messages older than the specified number of days.
archive.settings.max.retrievable = Retrievable Messages
archive.settings.max.retrievable.description = The number of days worth of messages a user is allowed to retrieve.
archive.settings.index.settings = Index Settings
......
......@@ -52,6 +52,7 @@ archive.settings.max.time = Maxim\u00e1ln\u00ed \u010das
archive.settings.max.time.description = Maxim\u00e1ln\u00ed po\u010det minut trv\u00e1n\u00ed konverzace ne\u017e bude ukon\u010dena.
archive.settings.max.age = Max Message Age
archive.settings.max.age.description = The maximum number of days to keep messages before purging them from the database.
archive.settings.max.age.warning = NOTE: Setting this value above 0 will PERMANENTLY DELETE any messages older than the specified number of days.
archive.settings.max.retrievable = Retrievable Messages
archive.settings.max.retrievable.description = The number of days worth of messages a user is allowed to retrieve.
archive.settings.index.settings = Nastaven\u00ed index\u016f
......
......@@ -52,6 +52,7 @@ archive.settings.max.time = Tiempo M\u00e1ximo
archive.settings.max.time.description = El m\u00e1ximo n\u00famero de minutos una conversacion puede durar antes de ser finalizada.
archive.settings.max.age = Max Message Age
archive.settings.max.age.description = The maximum number of days to keep messages before purging them from the database.
archive.settings.max.age.warning = NOTE: Setting this value above 0 will PERMANENTLY DELETE any messages older than the specified number of days.
archive.settings.max.retrievable = Max Retrievable Messages
archive.settings.max.retrievable.description = The number of days worth of messages a user is allowed to retrieve.
archive.settings.index.settings = Seteos de Indices
......
......@@ -112,6 +112,7 @@ archive.settings.max.time=Temps Max
archive.settings.max.time.description=Le nombre de minutes maximum d'une conversation avant qu'elle ne soit coup\u00e9e automatiquement.
archive.settings.max.age = Max Message Age
archive.settings.max.age.description = The maximum number of days to keep messages before purging them from the database.
archive.settings.max.age.warning = NOTE: Setting this value above 0 will PERMANENTLY DELETE any messages older than the specified number of days.
archive.settings.max.retrievable = Retrievable Messages
archive.settings.max.retrievable.description = The number of days worth of messages a user is allowed to retrieve.
archive.settings.message.count=Nombre de messages archiv\u00e9s
......
......@@ -76,6 +76,7 @@ archive.settings.max.time = Tempo M\u00e1ximo
archive.settings.max.time.description = N\u00famero m\u00e1ximo de minutos que a conversa pode durar antes de ser encerrada.
archive.settings.max.age = Max Message Age
archive.settings.max.age.description = The maximum number of days to keep messages before purging them from the database.
archive.settings.max.age.warning = NOTE: Setting this value above 0 will PERMANENTLY DELETE any messages older than the specified number of days.
archive.settings.max.retrievable = Retrievable Messages
archive.settings.max.retrievable.description = The number of days worth of messages a user is allowed to retrieve.
archive.settings.index.settings = Ajustes de \u00edndice
......
......@@ -73,6 +73,7 @@ archive.settings.max.time = \u6700\u5927\u65f6\u95f4
archive.settings.max.time.description = \u4f1a\u8bdd\u7ed3\u675f\u524d\u53ef\u6301\u7eed\u7684\u6700\u5927\u65f6\u95f4
archive.settings.max.age = Max Message Age
archive.settings.max.age.description = The maximum number of days to keep messages before purging them from the database.
archive.settings.max.age.warning = NOTE: Setting this value above 0 will PERMANENTLY DELETE any messages older than the specified number of days.
archive.settings.max.retrievable = Retrievable Messages
archive.settings.max.retrievable.description = The number of days worth of messages a user is allowed to retrieve.
archive.settings.index.settings = \u7d22\u5f15\u8bbe\u7f6e
......
......@@ -48,6 +48,7 @@ import org.jivesoftware.openfire.archive.cluster.GetConversationsTask;
import org.jivesoftware.openfire.cluster.ClusterManager;
import org.jivesoftware.openfire.component.ComponentEventListener;
import org.jivesoftware.openfire.component.InternalComponentManager;
import org.jivesoftware.openfire.plugin.MonitoringPlugin;
import org.jivesoftware.openfire.reporting.util.TaskEngine;
import org.jivesoftware.openfire.stats.Statistic;
import org.jivesoftware.openfire.stats.StatisticsManager;
......@@ -88,6 +89,9 @@ public class ConversationManager implements Startable, ComponentEventListener {
+ "VALUES (?,?,?,?,?,?,?)";
private static final String CONVERSATION_COUNT = "SELECT COUNT(*) FROM ofConversation";
private static final String MESSAGE_COUNT = "SELECT COUNT(*) FROM ofMessageArchive";
private static final String DELETE_CONVERSATION_1 = "DELETE FROM ofMessageArchive WHERE conversationID=?";
private static final String DELETE_CONVERSATION_2 = "DELETE FROM ofConparticipant WHERE conversationID=?";
private static final String DELETE_CONVERSATION_3 = "DELETE FROM ofConversation WHERE conversationID=?";
private static final int DEFAULT_IDLE_TIME = 10;
private static final int DEFAULT_MAX_TIME = 60;
......@@ -206,11 +210,50 @@ public class ConversationManager implements Startable, ComponentEventListener {
maxAgeTask = new TimerTask() {
@Override
public void run() {
// Delete conversations older than maxAge days
// TODO
if (maxAge > 0) {
// Delete conversations older than maxAge days
Connection con = null;
PreparedStatement pstmt1 = null;
PreparedStatement pstmt2 = null;
PreparedStatement pstmt3 = null;
try {
con = DbConnectionManager.getConnection();
pstmt1 = con.prepareStatement(DELETE_CONVERSATION_1);
pstmt2 = con.prepareStatement(DELETE_CONVERSATION_2);
pstmt3 = con.prepareStatement(DELETE_CONVERSATION_3);
Date now = new Date();
Date maxAgeDate = new Date(now.getTime() - maxAge);
ArchiveSearch search = new ArchiveSearch();
search.setDateRangeMax(maxAgeDate);
MonitoringPlugin plugin = (MonitoringPlugin) XMPPServer.getInstance().getPluginManager().getPlugin(MonitoringConstants.NAME);
ArchiveSearcher archiveSearcher = (ArchiveSearcher) plugin.getModule(ArchiveSearcher.class);
Collection<Conversation> conversations = archiveSearcher.search(search);
int conversationDeleted = 0;
for (Conversation conversation : conversations) {
Log.debug("Deleting: " + conversation.getConversationID() + " with date: " + conversation.getStartDate()
+ " older than: " + maxAgeDate);
pstmt1.setLong(1, conversation.getConversationID());
pstmt1.execute();
pstmt2.setLong(1, conversation.getConversationID());
pstmt2.execute();
pstmt3.setLong(1, conversation.getConversationID());
pstmt3.execute();
conversationDeleted++;
}
if (conversationDeleted > 0) {
Log.info("Deleted " + conversationDeleted + " conversations with date older than: " + maxAgeDate);
}
} catch (Exception e) {
Log.error(e.getMessage(), e);
} finally {
DbConnectionManager.closeConnection(pstmt1, con);
DbConnectionManager.closeConnection(pstmt2, con);
DbConnectionManager.closeConnection(pstmt3, con);
}
}
}
};
taskEngine.scheduleAtFixedRate(maxAgeTask, JiveConstants.MINUTE, JiveConstants.DAY);
taskEngine.scheduleAtFixedRate(maxAgeTask, JiveConstants.MINUTE, JiveConstants.MINUTE);
// Register a statistic.
Statistic conversationStat = new Statistic() {
......
......@@ -205,7 +205,7 @@
errors.put("maxAge", "");
errorMessage = "Max Age must be greater than or equal to 0.";
}
if (maxRetrievable < 1) {
if (maxRetrievable < 0) {
errors.put("maxRetrievable", "");
errorMessage = "Max Retrievable must be greater than or equal to 0.";
}
......@@ -303,7 +303,8 @@
<tr>
<td><label class="jive-label"><fmt:message key="archive.settings.max.age"/>:</label><br>
<fmt:message key="archive.settings.max.age.description"/><br><br></td>
<fmt:message key="archive.settings.max.age.description"/><br><br>
<font color="FF0000"><fmt:message key="archive.settings.max.age.warning"/></font><br><br></td>
<td><input type="text" name="maxAge" size="10" maxlength="10" value="<%= conversationManager.getMaxAge()%>" /></td>
<td></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