Commit 5f4194f7 authored by guus's avatar guus

* Updating 'monitoring' plugin to make use of SLF4J instead of custom logging (OF-53).

* Applied java generics.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@11438 b35dd754-fafc-0310-a699-88a17e54d16e
parent d5445253
...@@ -44,6 +44,14 @@ ...@@ -44,6 +44,14 @@
Monitoring Plugin Changelog Monitoring Plugin Changelog
</h1> </h1>
<p><b>1.2.0</b> -- December 1, 2009</p>
<ul>
<li>Compatible version with Openfire 3.6.5.</li>
<li>Applied Java generics.</li>
<li>[<a href='http://www.igniterealtime.org/issues/browse/OF-53'>OF-53</a>] - Replace custom logging implementation with a third party library.</li>
</ul>
<p><b>1.1.1</b> -- November 14, 2008</p> <p><b>1.1.1</b> -- November 14, 2008</p>
<ul> <ul>
......
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
<name>Monitoring Service</name> <name>Monitoring Service</name>
<description>Monitors conversations and statistics of the server.</description> <description>Monitors conversations and statistics of the server.</description>
<author>Jive Software</author> <author>Jive Software</author>
<version>1.1.1</version> <version>1.2.0</version>
<date>11/14/2008</date> <date>12/1/2009</date>
<minServerVersion>3.6.0</minServerVersion> <minServerVersion>3.6.5</minServerVersion>
<databaseKey>monitoring</databaseKey> <databaseKey>monitoring</databaseKey>
<databaseVersion>0</databaseVersion> <databaseVersion>0</databaseVersion>
......
...@@ -19,7 +19,29 @@ ...@@ -19,7 +19,29 @@
package org.jivesoftware.openfire.archive; package org.jivesoftware.openfire.archive;
import org.jivesoftware.openfire.reporting.util.TaskEngine; import java.io.File;
import java.io.FileWriter;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.Writer;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TimerTask;
import java.util.TreeSet;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.DateTools; import org.apache.lucene.document.DateTools;
import org.apache.lucene.document.Document; import org.apache.lucene.document.Document;
...@@ -34,26 +56,15 @@ import org.dom4j.DocumentFactory; ...@@ -34,26 +56,15 @@ import org.dom4j.DocumentFactory;
import org.dom4j.io.OutputFormat; import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter; import org.dom4j.io.XMLWriter;
import org.jivesoftware.database.DbConnectionManager; import org.jivesoftware.database.DbConnectionManager;
import org.jivesoftware.openfire.reporting.util.TaskEngine;
import org.jivesoftware.util.JiveConstants; import org.jivesoftware.util.JiveConstants;
import org.jivesoftware.util.JiveGlobals; import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.XMLProperties; import org.jivesoftware.util.XMLProperties;
import org.picocontainer.Startable; import org.picocontainer.Startable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import java.io.*;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/** /**
* Indexes archived conversations. If conversation archiving is not enabled, * Indexes archived conversations. If conversation archiving is not enabled,
* this class does nothing. The search index is maintained in the <tt>monitoring/search</tt> * this class does nothing. The search index is maintained in the <tt>monitoring/search</tt>
...@@ -67,6 +78,8 @@ import java.util.concurrent.locks.ReentrantLock; ...@@ -67,6 +78,8 @@ import java.util.concurrent.locks.ReentrantLock;
*/ */
public class ArchiveIndexer implements Startable { public class ArchiveIndexer implements Startable {
private static final Logger Log = LoggerFactory.getLogger(ArchiveIndexer.class);
private static final String ALL_CONVERSATIONS = private static final String ALL_CONVERSATIONS =
"SELECT conversationID, isExternal FROM ofConversation"; "SELECT conversationID, isExternal FROM ofConversation";
private static final String NEW_CONVERSATIONS = private static final String NEW_CONVERSATIONS =
...@@ -124,7 +137,7 @@ public class ArchiveIndexer implements Startable { ...@@ -124,7 +137,7 @@ public class ArchiveIndexer implements Startable {
} }
} }
catch (IOException ioe) { catch (IOException ioe) {
Log.error(ioe); Log.error(ioe.getMessage(), ioe);
} }
writerLock = new ReentrantLock(true); writerLock = new ReentrantLock(true);
...@@ -138,7 +151,7 @@ public class ArchiveIndexer implements Startable { ...@@ -138,7 +151,7 @@ public class ArchiveIndexer implements Startable {
} }
} }
catch (IOException ioe) { catch (IOException ioe) {
Log.error(ioe); Log.error(ioe.getMessage(), ioe);
} }
String modified = indexProperties.getProperty("lastModified"); String modified = indexProperties.getProperty("lastModified");
...@@ -177,7 +190,7 @@ public class ArchiveIndexer implements Startable { ...@@ -177,7 +190,7 @@ public class ArchiveIndexer implements Startable {
searcher.close(); searcher.close();
} }
catch (Exception e) { catch (Exception e) {
Log.error(e); Log.error(e.getMessage(), e);
} }
searcher = null; searcher = null;
} }
...@@ -185,7 +198,7 @@ public class ArchiveIndexer implements Startable { ...@@ -185,7 +198,7 @@ public class ArchiveIndexer implements Startable {
directory.close(); directory.close();
} }
catch (Exception e) { catch (Exception e) {
Log.error(e); Log.error(e.getMessage(), e);
} }
directory = null; directory = null;
indexProperties = null; indexProperties = null;
...@@ -251,7 +264,7 @@ public class ArchiveIndexer implements Startable { ...@@ -251,7 +264,7 @@ public class ArchiveIndexer implements Startable {
} }
} }
catch (SQLException sqle) { catch (SQLException sqle) {
Log.error(sqle); Log.error(sqle.getMessage(), sqle);
} }
finally { finally {
DbConnectionManager.closeConnection(rs, pstmt, con); DbConnectionManager.closeConnection(rs, pstmt, con);
...@@ -276,7 +289,7 @@ public class ArchiveIndexer implements Startable { ...@@ -276,7 +289,7 @@ public class ArchiveIndexer implements Startable {
} }
} }
catch (SQLException sqle) { catch (SQLException sqle) {
Log.error(sqle); Log.error(sqle.getMessage(), sqle);
} }
finally { finally {
DbConnectionManager.closeConnection(rs, pstmt, con); DbConnectionManager.closeConnection(rs, pstmt, con);
...@@ -295,7 +308,7 @@ public class ArchiveIndexer implements Startable { ...@@ -295,7 +308,7 @@ public class ArchiveIndexer implements Startable {
} }
} }
catch (IOException ioe) { catch (IOException ioe) {
Log.error(ioe); Log.error(ioe.getMessage(), ioe);
} }
finally { finally {
if (writer != null) { if (writer != null) {
...@@ -303,7 +316,7 @@ public class ArchiveIndexer implements Startable { ...@@ -303,7 +316,7 @@ public class ArchiveIndexer implements Startable {
writer.close(); writer.close();
} }
catch (Exception e) { catch (Exception e) {
Log.error(e); Log.error(e.getMessage(), e);
} }
} }
writerLock.unlock(); writerLock.unlock();
...@@ -358,7 +371,7 @@ public class ArchiveIndexer implements Startable { ...@@ -358,7 +371,7 @@ public class ArchiveIndexer implements Startable {
} }
} }
catch (SQLException sqle) { catch (SQLException sqle) {
Log.error(sqle); Log.error(sqle.getMessage(), sqle);
} }
finally { finally {
DbConnectionManager.closeConnection(rs, pstmt, con); DbConnectionManager.closeConnection(rs, pstmt, con);
...@@ -381,7 +394,7 @@ public class ArchiveIndexer implements Startable { ...@@ -381,7 +394,7 @@ public class ArchiveIndexer implements Startable {
} }
} }
catch (IOException ioe) { catch (IOException ioe) {
Log.error(ioe); Log.error(ioe.getMessage(), ioe);
} }
finally { finally {
if (writer != null) { if (writer != null) {
...@@ -389,7 +402,7 @@ public class ArchiveIndexer implements Startable { ...@@ -389,7 +402,7 @@ public class ArchiveIndexer implements Startable {
writer.close(); writer.close();
} }
catch (Exception e) { catch (Exception e) {
Log.error(e); Log.error(e.getMessage(), e);
} }
} }
writerLock.unlock(); writerLock.unlock();
...@@ -518,7 +531,7 @@ public class ArchiveIndexer implements Startable { ...@@ -518,7 +531,7 @@ public class ArchiveIndexer implements Startable {
} }
} }
catch (SQLException sqle) { catch (SQLException sqle) {
Log.error(sqle); Log.error(sqle.getMessage(), sqle);
} }
finally { finally {
DbConnectionManager.closeConnection(rs, pstmt, con); DbConnectionManager.closeConnection(rs, pstmt, con);
...@@ -598,7 +611,7 @@ public class ArchiveIndexer implements Startable { ...@@ -598,7 +611,7 @@ public class ArchiveIndexer implements Startable {
outputter.flush(); outputter.flush();
} }
catch (Exception e) { catch (Exception e) {
Log.error(e); Log.error(e.getMessage(), e);
} }
finally { finally {
try { try {
...@@ -617,7 +630,7 @@ public class ArchiveIndexer implements Startable { ...@@ -617,7 +630,7 @@ public class ArchiveIndexer implements Startable {
/** /**
* A Future class to track the status of index rebuilding. * A Future class to track the status of index rebuilding.
*/ */
private class RebuildFuture implements Future { private class RebuildFuture implements Future<Integer> {
private int percentageDone = 0; private int percentageDone = 0;
......
...@@ -19,25 +19,41 @@ ...@@ -19,25 +19,41 @@
package org.jivesoftware.openfire.archive; package org.jivesoftware.openfire.archive;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.AbstractCollection;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.DateTools; import org.apache.lucene.document.DateTools;
import org.apache.lucene.index.Term; import org.apache.lucene.index.Term;
import org.apache.lucene.queryParser.ParseException; import org.apache.lucene.queryParser.ParseException;
import org.apache.lucene.queryParser.QueryParser; import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.search.*; import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.Filter;
import org.apache.lucene.search.Hit;
import org.apache.lucene.search.Hits;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.RangeFilter;
import org.apache.lucene.search.Sort;
import org.apache.lucene.search.TermQuery;
import org.jivesoftware.database.CachedPreparedStatement; import org.jivesoftware.database.CachedPreparedStatement;
import org.jivesoftware.database.DbConnectionManager; import org.jivesoftware.database.DbConnectionManager;
import org.jivesoftware.util.Log;
import org.picocontainer.Startable; import org.picocontainer.Startable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
/** /**
* Searches archived conversations. If conversation archiving is not enabled, * Searches archived conversations. If conversation archiving is not enabled,
* this class does nothing. Searches may or may not include keyword searching. When * this class does nothing. Searches may or may not include keyword searching. When
...@@ -50,6 +66,8 @@ import java.util.*; ...@@ -50,6 +66,8 @@ import java.util.*;
*/ */
public class ArchiveSearcher implements Startable { public class ArchiveSearcher implements Startable {
private static final Logger Log = LoggerFactory.getLogger(ArchiveSearch.class);
private ConversationManager conversationManager; private ConversationManager conversationManager;
private ArchiveIndexer archiveIndexer; private ArchiveIndexer archiveIndexer;
...@@ -196,11 +214,11 @@ public class ArchiveSearcher implements Startable { ...@@ -196,11 +214,11 @@ public class ArchiveSearcher implements Startable {
} }
} }
catch (ParseException pe) { catch (ParseException pe) {
Log.error(pe); Log.error(pe.getMessage(), pe);
return Collections.emptySet(); return Collections.emptySet();
} }
catch (IOException ioe) { catch (IOException ioe) {
Log.error(ioe); Log.error(ioe.getMessage(), ioe);
return Collections.emptySet(); return Collections.emptySet();
} }
} }
...@@ -382,7 +400,7 @@ public class ArchiveSearcher implements Startable { ...@@ -382,7 +400,7 @@ public class ArchiveSearcher implements Startable {
rs.close(); rs.close();
} }
catch (SQLException sqle) { catch (SQLException sqle) {
Log.error(sqle); Log.error(sqle.getMessage(), sqle);
} }
finally { finally {
DbConnectionManager.closeConnection(pstmt, con); DbConnectionManager.closeConnection(pstmt, con);
...@@ -394,7 +412,7 @@ public class ArchiveSearcher implements Startable { ...@@ -394,7 +412,7 @@ public class ArchiveSearcher implements Startable {
* Returns Hits from a database search against archived conversations as a Collection * Returns Hits from a database search against archived conversations as a Collection
* of Conversation objects. * of Conversation objects.
*/ */
private class DatabaseQueryResults extends AbstractCollection { private class DatabaseQueryResults extends AbstractCollection<Conversation> {
private List<Long> conversationIDs; private List<Long> conversationIDs;
...@@ -407,11 +425,11 @@ public class ArchiveSearcher implements Startable { ...@@ -407,11 +425,11 @@ public class ArchiveSearcher implements Startable {
this.conversationIDs = conversationIDs; this.conversationIDs = conversationIDs;
} }
public Iterator iterator() { public Iterator<Conversation> iterator() {
final Iterator<Long> convIterator = conversationIDs.iterator(); final Iterator<Long> convIterator = conversationIDs.iterator();
return new Iterator() { return new Iterator<Conversation>() {
private Object nextElement = null; private Conversation nextElement = null;
public boolean hasNext() { public boolean hasNext() {
if (nextElement == null) { if (nextElement == null) {
...@@ -423,8 +441,8 @@ public class ArchiveSearcher implements Startable { ...@@ -423,8 +441,8 @@ public class ArchiveSearcher implements Startable {
return true; return true;
} }
public Object next() { public Conversation next() {
Object element; Conversation element;
if (nextElement != null) { if (nextElement != null) {
element = nextElement; element = nextElement;
nextElement = null; nextElement = null;
...@@ -442,7 +460,7 @@ public class ArchiveSearcher implements Startable { ...@@ -442,7 +460,7 @@ public class ArchiveSearcher implements Startable {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
private Object getNextElement() { private Conversation getNextElement() {
if (!convIterator.hasNext()) { if (!convIterator.hasNext()) {
return null; return null;
} }
...@@ -452,7 +470,7 @@ public class ArchiveSearcher implements Startable { ...@@ -452,7 +470,7 @@ public class ArchiveSearcher implements Startable {
return new Conversation(conversationManager, conversationID); return new Conversation(conversationManager, conversationID);
} }
catch (Exception e) { catch (Exception e) {
Log.error(e); Log.error(e.getMessage(), e);
} }
} }
return null; return null;
...@@ -469,7 +487,7 @@ public class ArchiveSearcher implements Startable { ...@@ -469,7 +487,7 @@ public class ArchiveSearcher implements Startable {
* Returns Hits from a Lucene search against archived conversations as a Collection * Returns Hits from a Lucene search against archived conversations as a Collection
* of Conversation objects. * of Conversation objects.
*/ */
private class LuceneQueryResults extends AbstractCollection { private class LuceneQueryResults extends AbstractCollection<Conversation> {
private Hits hits; private Hits hits;
private int index; private int index;
...@@ -488,15 +506,15 @@ public class ArchiveSearcher implements Startable { ...@@ -488,15 +506,15 @@ public class ArchiveSearcher implements Startable {
this.endIndex = endIndex; this.endIndex = endIndex;
} }
public Iterator iterator() { public Iterator<Conversation> iterator() {
final Iterator hitsIterator = hits.iterator(); final Iterator<Hit> hitsIterator = hits.iterator();
// Advance the iterator until we hit the index. // Advance the iterator until we hit the index.
for (int i=0; i<index; i++) { for (int i=0; i<index; i++) {
hitsIterator.next(); hitsIterator.next();
} }
return new Iterator() { return new Iterator<Conversation>() {
private Object nextElement = null; private Conversation nextElement = null;
public boolean hasNext() { public boolean hasNext() {
if (nextElement == null) { if (nextElement == null) {
...@@ -508,8 +526,8 @@ public class ArchiveSearcher implements Startable { ...@@ -508,8 +526,8 @@ public class ArchiveSearcher implements Startable {
return true; return true;
} }
public Object next() { public Conversation next() {
Object element; Conversation element;
if (nextElement != null) { if (nextElement != null) {
element = nextElement; element = nextElement;
nextElement = null; nextElement = null;
...@@ -527,7 +545,7 @@ public class ArchiveSearcher implements Startable { ...@@ -527,7 +545,7 @@ public class ArchiveSearcher implements Startable {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
private Object getNextElement() { private Conversation getNextElement() {
if (!hitsIterator.hasNext()) { if (!hitsIterator.hasNext()) {
return null; return null;
} }
...@@ -537,7 +555,7 @@ public class ArchiveSearcher implements Startable { ...@@ -537,7 +555,7 @@ public class ArchiveSearcher implements Startable {
} }
while (hitsIterator.hasNext()) { while (hitsIterator.hasNext()) {
try { try {
Hit hit = (Hit)hitsIterator.next(); Hit hit = hitsIterator.next();
// Advance the index. // Advance the index.
index++; index++;
...@@ -545,7 +563,7 @@ public class ArchiveSearcher implements Startable { ...@@ -545,7 +563,7 @@ public class ArchiveSearcher implements Startable {
return new Conversation(conversationManager, conversationID); return new Conversation(conversationManager, conversationID);
} }
catch (Exception e) { catch (Exception e) {
Log.error(e); Log.error(e.getMessage(), e);
} }
} }
return null; return null;
......
...@@ -19,34 +19,42 @@ ...@@ -19,34 +19,42 @@
package org.jivesoftware.openfire.archive; package org.jivesoftware.openfire.archive;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.jivesoftware.database.DbConnectionManager; import org.jivesoftware.database.DbConnectionManager;
import org.jivesoftware.database.JiveID; import org.jivesoftware.database.JiveID;
import org.jivesoftware.database.SequenceManager; import org.jivesoftware.database.SequenceManager;
import org.jivesoftware.openfire.XMPPServer; import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.muc.MUCRole; import org.jivesoftware.openfire.muc.MUCRole;
import org.jivesoftware.openfire.muc.MUCRoom; import org.jivesoftware.openfire.muc.MUCRoom;
import org.jivesoftware.openfire.plugin.MonitoringPlugin;
import org.jivesoftware.openfire.user.UserNameManager; import org.jivesoftware.openfire.user.UserNameManager;
import org.jivesoftware.openfire.user.UserNotFoundException; import org.jivesoftware.openfire.user.UserNotFoundException;
import org.jivesoftware.util.JiveGlobals; import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.LocaleUtils; import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.NotFoundException; import org.jivesoftware.util.NotFoundException;
import org.jivesoftware.util.cache.ExternalizableUtil; import org.jivesoftware.util.cache.ExternalizableUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import org.jivesoftware.openfire.plugin.MonitoringPlugin;
/** /**
* Represents an IM conversation between two people. A conversation encompasses a * Represents an IM conversation between two people. A conversation encompasses a
* series of messages sent back and forth. It may cover a single topic or several. * series of messages sent back and forth. It may cover a single topic or several.
...@@ -73,6 +81,8 @@ import org.jivesoftware.openfire.plugin.MonitoringPlugin; ...@@ -73,6 +81,8 @@ import org.jivesoftware.openfire.plugin.MonitoringPlugin;
@JiveID(50) @JiveID(50)
public class Conversation implements Externalizable { public class Conversation implements Externalizable {
private static final Logger Log = LoggerFactory.getLogger(Conversation.class);
private static final String INSERT_CONVERSATION = private static final String INSERT_CONVERSATION =
"INSERT INTO ofConversation(conversationID, room, isExternal, startDate, " + "INSERT INTO ofConversation(conversationID, room, isExternal, startDate, " +
"lastActivity, messageCount) VALUES (?,?,?,?,?,0)"; "lastActivity, messageCount) VALUES (?,?,?,?,?,0)";
...@@ -139,7 +149,7 @@ public class Conversation implements Externalizable { ...@@ -139,7 +149,7 @@ public class Conversation implements Externalizable {
insertIntoDb(); insertIntoDb();
} }
catch (Exception e) { catch (Exception e) {
Log.error(e); Log.error(e.getMessage(), e);
} }
} }
} }
...@@ -174,7 +184,7 @@ public class Conversation implements Externalizable { ...@@ -174,7 +184,7 @@ public class Conversation implements Externalizable {
insertIntoDb(); insertIntoDb();
} }
catch (Exception e) { catch (Exception e) {
Log.error(e); Log.error(e.getMessage(), e);
} }
} }
} }
...@@ -315,7 +325,7 @@ public class Conversation implements Externalizable { ...@@ -315,7 +325,7 @@ public class Conversation implements Externalizable {
} }
} }
catch (SQLException sqle) { catch (SQLException sqle) {
Log.error(sqle); Log.error(sqle.getMessage(), sqle);
} }
finally { finally {
DbConnectionManager.closeConnection(rs, pstmt, con); DbConnectionManager.closeConnection(rs, pstmt, con);
...@@ -432,7 +442,7 @@ public class Conversation implements Externalizable { ...@@ -432,7 +442,7 @@ public class Conversation implements Externalizable {
} }
} }
catch (Exception e) { catch (Exception e) {
Log.error(e); Log.error(e.getMessage(), e);
} }
} }
} }
...@@ -574,7 +584,7 @@ public class Conversation implements Externalizable { ...@@ -574,7 +584,7 @@ public class Conversation implements Externalizable {
} }
} }
catch (SQLException sqle) { catch (SQLException sqle) {
Log.error(sqle); Log.error(sqle.getMessage(), sqle);
} }
finally { finally {
DbConnectionManager.closeConnection(rs, pstmt, con); DbConnectionManager.closeConnection(rs, pstmt, con);
......
...@@ -35,6 +35,8 @@ import org.jivesoftware.openfire.stats.StatisticsManager; ...@@ -35,6 +35,8 @@ import org.jivesoftware.openfire.stats.StatisticsManager;
import org.jivesoftware.util.*; import org.jivesoftware.util.*;
import org.jivesoftware.util.cache.CacheFactory; import org.jivesoftware.util.cache.CacheFactory;
import org.picocontainer.Startable; import org.picocontainer.Startable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xmpp.packet.IQ; import org.xmpp.packet.IQ;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import org.xmpp.packet.Message; import org.xmpp.packet.Message;
...@@ -57,15 +59,17 @@ import java.util.concurrent.CopyOnWriteArraySet; ...@@ -57,15 +59,17 @@ import java.util.concurrent.CopyOnWriteArraySet;
* can be enabled by setting "conversation.messageArchiving" to <tt>true</tt>.<p> * can be enabled by setting "conversation.messageArchiving" to <tt>true</tt>.<p>
* *
* When running in a cluster only the senior cluster member will keep track of the active * When running in a cluster only the senior cluster member will keep track of the active
* conversations. Other cluster nodes will forward conversation events that occured in the * conversations. Other cluster nodes will forward conversation events that occurred in the
* local node to the senior cluster member. If the senior cluster member goes down then * local node to the senior cluster member. If the senior cluster member goes down then
* current conversations will be terminated and if users keep sending messages between them * current conversations will be terminated and if users keep sending messages between them
* then new converstions will be created. * then new conversations will be created.
* *
* @author Matt Tucker * @author Matt Tucker
*/ */
public class ConversationManager implements Startable, ComponentEventListener { public class ConversationManager implements Startable, ComponentEventListener {
private static final Logger Log = LoggerFactory.getLogger(ConversationManager.class);
private static final String UPDATE_CONVERSATION = private static final String UPDATE_CONVERSATION =
"UPDATE ofConversation SET lastActivity=?, messageCount=? WHERE conversationID=?"; "UPDATE ofConversation SET lastActivity=?, messageCount=? WHERE conversationID=?";
private static final String UPDATE_PARTICIPANT = private static final String UPDATE_PARTICIPANT =
...@@ -499,7 +503,7 @@ public class ConversationManager implements Startable, ComponentEventListener { ...@@ -499,7 +503,7 @@ public class ConversationManager implements Startable, ComponentEventListener {
} }
} }
catch (SQLException sqle) { catch (SQLException sqle) {
Log.error(sqle); Log.error(sqle.getMessage(), sqle);
} }
finally { finally {
DbConnectionManager.closeConnection(rs, pstmt, con); DbConnectionManager.closeConnection(rs, pstmt, con);
...@@ -526,7 +530,7 @@ public class ConversationManager implements Startable, ComponentEventListener { ...@@ -526,7 +530,7 @@ public class ConversationManager implements Startable, ComponentEventListener {
} }
} }
catch (SQLException sqle) { catch (SQLException sqle) {
Log.error(sqle); Log.error(sqle.getMessage(), sqle);
} }
finally { finally {
DbConnectionManager.closeConnection(rs, pstmt, con); DbConnectionManager.closeConnection(rs, pstmt, con);
...@@ -821,8 +825,8 @@ public class ConversationManager implements Startable, ComponentEventListener { ...@@ -821,8 +825,8 @@ public class ConversationManager implements Startable, ComponentEventListener {
//Check if the component is a gateway //Check if the component is a gateway
boolean gatewayFound = false; boolean gatewayFound = false;
Element childElement = iq.getChildElement(); Element childElement = iq.getChildElement();
for (Iterator it = childElement.elementIterator("identity"); it.hasNext();) { for (Iterator<Element> it = childElement.elementIterator("identity"); it.hasNext();) {
Element identity = (Element)it.next(); Element identity = it.next();
if ("gateway".equals(identity.attributeValue("category"))) { if ("gateway".equals(identity.attributeValue("category"))) {
gatewayFound = true; gatewayFound = true;
} }
...@@ -943,7 +947,7 @@ public class ConversationManager implements Startable, ComponentEventListener { ...@@ -943,7 +947,7 @@ public class ConversationManager implements Startable, ComponentEventListener {
} }
} }
catch (Exception e) { catch (Exception e) {
Log.error(e); Log.error(e.getMessage(), e);
} }
finally { finally {
DbConnectionManager.closeConnection(pstmt, con); DbConnectionManager.closeConnection(pstmt, con);
...@@ -960,7 +964,7 @@ public class ConversationManager implements Startable, ComponentEventListener { ...@@ -960,7 +964,7 @@ public class ConversationManager implements Startable, ComponentEventListener {
*/ */
private class ConversationPropertyListener implements PropertyEventListener { private class ConversationPropertyListener implements PropertyEventListener {
public void propertySet(String property, Map params) { public void propertySet(String property, Map<String, Object> params) {
if (property.equals("conversation.metadataArchiving")) { if (property.equals("conversation.metadataArchiving")) {
String value = (String)params.get("value"); String value = (String)params.get("value");
metadataArchivingEnabled = Boolean.valueOf(value); metadataArchivingEnabled = Boolean.valueOf(value);
...@@ -991,7 +995,7 @@ public class ConversationManager implements Startable, ComponentEventListener { ...@@ -991,7 +995,7 @@ public class ConversationManager implements Startable, ComponentEventListener {
idleTime = Integer.parseInt(value) * JiveConstants.MINUTE; idleTime = Integer.parseInt(value) * JiveConstants.MINUTE;
} }
catch (Exception e) { catch (Exception e) {
Log.error(e); Log.error(e.getMessage(), e);
idleTime = DEFAULT_IDLE_TIME * JiveConstants.MINUTE; idleTime = DEFAULT_IDLE_TIME * JiveConstants.MINUTE;
} }
} }
...@@ -1001,13 +1005,13 @@ public class ConversationManager implements Startable, ComponentEventListener { ...@@ -1001,13 +1005,13 @@ public class ConversationManager implements Startable, ComponentEventListener {
maxTime = Integer.parseInt(value) * JiveConstants.MINUTE; maxTime = Integer.parseInt(value) * JiveConstants.MINUTE;
} }
catch (Exception e) { catch (Exception e) {
Log.error(e); Log.error(e.getMessage(), e);
maxTime = DEFAULT_MAX_TIME * JiveConstants.MINUTE; maxTime = DEFAULT_MAX_TIME * JiveConstants.MINUTE;
} }
} }
} }
public void propertyDeleted(String property, Map params) { public void propertyDeleted(String property, Map<String, Object> params) {
if (property.equals("conversation.metadataArchiving")) { if (property.equals("conversation.metadataArchiving")) {
metadataArchivingEnabled = true; metadataArchivingEnabled = true;
} }
...@@ -1028,11 +1032,11 @@ public class ConversationManager implements Startable, ComponentEventListener { ...@@ -1028,11 +1032,11 @@ public class ConversationManager implements Startable, ComponentEventListener {
} }
} }
public void xmlPropertySet(String property, Map params) { public void xmlPropertySet(String property, Map<String, Object> params) {
// Ignore. // Ignore.
} }
public void xmlPropertyDeleted(String property, Map params) { public void xmlPropertyDeleted(String property, Map<String, Object> params) {
// Ignore. // Ignore.
} }
} }
......
...@@ -18,25 +18,26 @@ ...@@ -18,25 +18,26 @@
*/ */
package org.jivesoftware.openfire.archive; package org.jivesoftware.openfire.archive;
import org.jivesoftware.openfire.XMPPServer; import java.io.ByteArrayOutputStream;
import org.jivesoftware.openfire.plugin.MonitoringPlugin; import java.io.IOException;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.NotFoundException;
import org.jivesoftware.util.ParamUtils;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
/** import org.jivesoftware.openfire.XMPPServer;
* import org.jivesoftware.openfire.plugin.MonitoringPlugin;
*/ import org.jivesoftware.util.NotFoundException;
import org.jivesoftware.util.ParamUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ConversationPDFServlet extends HttpServlet { public class ConversationPDFServlet extends HttpServlet {
private static final Logger Log = LoggerFactory.getLogger(ConversationPDFServlet.class);
public void init() throws ServletException { public void init() throws ServletException {
} }
...@@ -63,7 +64,7 @@ public class ConversationPDFServlet extends HttpServlet { ...@@ -63,7 +64,7 @@ public class ConversationPDFServlet extends HttpServlet {
response.setHeader("Pragma", "public"); response.setHeader("Pragma", "public");
// setting the content type // setting the content type
response.setContentType("application/pdf"); response.setContentType("application/pdf");
// the contentlength is needed for MSIE!!! // the content length is needed for MSIE!!!
response.setContentLength(stream.size()); response.setContentLength(stream.size());
// write ByteArrayOutputStream to the ServletOutputStream // write ByteArrayOutputStream to the ServletOutputStream
ServletOutputStream out = response.getOutputStream(); ServletOutputStream out = response.getOutputStream();
...@@ -71,7 +72,7 @@ public class ConversationPDFServlet extends HttpServlet { ...@@ -71,7 +72,7 @@ public class ConversationPDFServlet extends HttpServlet {
out.flush(); out.flush();
} }
catch (NotFoundException nfe) { catch (NotFoundException nfe) {
Log.error(nfe); Log.error(nfe.getMessage(), nfe);
} }
} }
......
...@@ -19,28 +19,39 @@ ...@@ -19,28 +19,39 @@
package org.jivesoftware.openfire.archive; package org.jivesoftware.openfire.archive;
import com.lowagie.text.*; import java.awt.Color;
import com.lowagie.text.Font; import java.io.ByteArrayOutputStream;
import com.lowagie.text.Image; import java.net.URL;
import com.lowagie.text.pdf.PdfContentByte; import java.util.Arrays;
import com.lowagie.text.pdf.PdfPageEventHelper; import java.util.Collection;
import com.lowagie.text.pdf.PdfWriter; import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Future;
import org.jivesoftware.openfire.XMPPServer; import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.plugin.MonitoringPlugin; import org.jivesoftware.openfire.plugin.MonitoringPlugin;
import org.jivesoftware.openfire.user.UserManager; import org.jivesoftware.openfire.user.UserManager;
import org.jivesoftware.util.JiveGlobals; import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.LocaleUtils; import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.NotFoundException; import org.jivesoftware.util.NotFoundException;
import org.xmpp.component.ComponentManagerFactory; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import java.awt.*; import com.lowagie.text.Chunk;
import java.io.ByteArrayOutputStream; import com.lowagie.text.Document;
import java.net.URL; import com.lowagie.text.DocumentException;
import java.util.*; import com.lowagie.text.Font;
import java.util.List; import com.lowagie.text.FontFactory;
import java.util.concurrent.Future; import com.lowagie.text.Image;
import com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfPageEventHelper;
import com.lowagie.text.pdf.PdfWriter;
/** /**
* Utility class for asynchronous web calls for archiving tasks. * Utility class for asynchronous web calls for archiving tasks.
...@@ -49,6 +60,8 @@ import java.util.concurrent.Future; ...@@ -49,6 +60,8 @@ import java.util.concurrent.Future;
*/ */
public class ConversationUtils { public class ConversationUtils {
private static final Logger Log = LoggerFactory.getLogger(ConversationUtils.class);
/** /**
* Returns the status of the rebuilding of the messaging/metadata archives. This is done * Returns the status of the rebuilding of the messaging/metadata archives. This is done
* asynchronously. * asynchronously.
...@@ -69,7 +82,7 @@ public class ConversationUtils { ...@@ -69,7 +82,7 @@ public class ConversationUtils {
return future.get(); return future.get();
} }
catch (Exception e) { catch (Exception e) {
Log.error(e); Log.error(e.getMessage(), e);
} }
} }
...@@ -93,7 +106,7 @@ public class ConversationUtils { ...@@ -93,7 +106,7 @@ public class ConversationUtils {
info = toConversationInfo(conversation, formatParticipants); info = toConversationInfo(conversation, formatParticipants);
} }
catch (NotFoundException e) { catch (NotFoundException e) {
Log.error(e); Log.error(e.getMessage(), e);
} }
return info; return info;
......
...@@ -19,26 +19,30 @@ ...@@ -19,26 +19,30 @@
package org.jivesoftware.openfire.archive.cluster; package org.jivesoftware.openfire.archive.cluster;
import org.jivesoftware.openfire.archive.ConversationEvent;
import org.jivesoftware.openfire.archive.ConversationManager;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.plugin.MonitoringPlugin;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.cache.ClusterTask;
import org.jivesoftware.util.cache.ExternalizableUtil;
import java.io.IOException; import java.io.IOException;
import java.io.ObjectInput; import java.io.ObjectInput;
import java.io.ObjectOutput; import java.io.ObjectOutput;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.archive.ConversationEvent;
import org.jivesoftware.openfire.archive.ConversationManager;
import org.jivesoftware.openfire.plugin.MonitoringPlugin;
import org.jivesoftware.util.cache.ClusterTask;
import org.jivesoftware.util.cache.ExternalizableUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Task that sends cnoversation events to the senior cluster member. * Task that sends cnoversation events to the senior cluster member.
* *
* @author Gaston Dombiak * @author Gaston Dombiak
*/ */
public class SendConversationEventsTask implements ClusterTask { public class SendConversationEventsTask implements ClusterTask {
private static final Logger Log = LoggerFactory.getLogger(SendConversationEventsTask.class);
private List<ConversationEvent> events; private List<ConversationEvent> events;
/** /**
......
...@@ -21,26 +21,31 @@ ...@@ -21,26 +21,31 @@
package org.jivesoftware.openfire.archive.commands; package org.jivesoftware.openfire.archive.commands;
import java.io.ByteArrayOutputStream;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import org.dom4j.Element; import org.dom4j.Element;
import org.jivesoftware.openfire.XMPPServer; import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.archive.*; import org.jivesoftware.openfire.archive.ArchiveSearch;
import org.jivesoftware.openfire.archive.ArchiveSearcher;
import org.jivesoftware.openfire.archive.Conversation;
import org.jivesoftware.openfire.archive.ConversationManager;
import org.jivesoftware.openfire.archive.ConversationUtils;
import org.jivesoftware.openfire.commands.AdHocCommand; import org.jivesoftware.openfire.commands.AdHocCommand;
import org.jivesoftware.openfire.commands.SessionData; import org.jivesoftware.openfire.commands.SessionData;
import org.jivesoftware.openfire.component.InternalComponentManager; import org.jivesoftware.openfire.component.InternalComponentManager;
import org.jivesoftware.openfire.plugin.MonitoringPlugin; import org.jivesoftware.openfire.plugin.MonitoringPlugin;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.StringUtils; import org.jivesoftware.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xmpp.component.ComponentManagerFactory; import org.xmpp.component.ComponentManagerFactory;
import org.xmpp.forms.DataForm; import org.xmpp.forms.DataForm;
import org.xmpp.forms.FormField; import org.xmpp.forms.FormField;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import java.io.ByteArrayOutputStream;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.List;
/** /**
* Command that allows to retrieve PDF content of group chat transcripts. * Command that allows to retrieve PDF content of group chat transcripts.
* *
...@@ -50,6 +55,8 @@ import java.util.List; ...@@ -50,6 +55,8 @@ import java.util.List;
*/ */
public class GetGroupConversationTranscript extends AdHocCommand { public class GetGroupConversationTranscript extends AdHocCommand {
private static final Logger Log = LoggerFactory.getLogger(GetGroupConversationTranscript.class);
protected void addStageInformation(SessionData data, Element command) { protected void addStageInformation(SessionData data, Element command) {
DataForm form = new DataForm(DataForm.Type.form); DataForm form = new DataForm(DataForm.Type.form);
form.setTitle("Requesting PDF of conversation transcript"); form.setTitle("Requesting PDF of conversation transcript");
......
...@@ -83,7 +83,7 @@ public class MonitoringPlugin implements Plugin { ...@@ -83,7 +83,7 @@ public class MonitoringPlugin implements Plugin {
* @param clazz the module class. * @param clazz the module class.
* @return the instance of the module. * @return the instance of the module.
*/ */
public Object getModule(Class clazz) { public Object getModule(Class<?> clazz) {
return picoContainer.getComponentInstanceOfType(clazz); return picoContainer.getComponentInstanceOfType(clazz);
} }
......
...@@ -19,27 +19,33 @@ ...@@ -19,27 +19,33 @@
*/ */
package org.jivesoftware.openfire.reporting; package org.jivesoftware.openfire.reporting;
import org.jivesoftware.util.Log; import java.io.IOException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import uk.ltd.getahead.dwr.Configuration;
import uk.ltd.getahead.dwr.DWRServlet;
import uk.ltd.getahead.dwr.impl.DefaultInterfaceProcessor;
import javax.servlet.ServletConfig; import javax.servlet.ServletConfig;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletRequestWrapper; import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import uk.ltd.getahead.dwr.Configuration;
import uk.ltd.getahead.dwr.DWRServlet;
import uk.ltd.getahead.dwr.impl.DefaultInterfaceProcessor;
/** /**
* Use the EnterpriseDWR servlet to register your own DWR mappings to Enteprise. * Use the EnterpriseDWR servlet to register your own DWR mappings to Enteprise.
*/ */
public class MonitoringDWR extends DWRServlet { public class MonitoringDWR extends DWRServlet {
private static final Logger Log = LoggerFactory.getLogger(MonitoringDWR.class);
private Document document; private Document document;
public void configure(ServletConfig servletConfig, Configuration configuration) throws ServletException { public void configure(ServletConfig servletConfig, Configuration configuration) throws ServletException {
......
...@@ -22,12 +22,14 @@ package org.jivesoftware.openfire.reporting.stats; ...@@ -22,12 +22,14 @@ package org.jivesoftware.openfire.reporting.stats;
import org.jivesoftware.openfire.cluster.ClusterManager; import org.jivesoftware.openfire.cluster.ClusterManager;
import org.jivesoftware.openfire.stats.Statistic; import org.jivesoftware.openfire.stats.Statistic;
import org.jivesoftware.util.Log;
import org.jrobin.core.RrdDb; import org.jrobin.core.RrdDb;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class DefaultStatsViewer implements StatsViewer { public class DefaultStatsViewer implements StatsViewer {
private static final Logger Log = LoggerFactory.getLogger(DefaultStatsViewer.class);
private StatsEngine engine; private StatsEngine engine;
/** /**
......
...@@ -18,17 +18,18 @@ ...@@ -18,17 +18,18 @@
*/ */
package org.jivesoftware.openfire.reporting.stats; package org.jivesoftware.openfire.reporting.stats;
import org.jivesoftware.openfire.stats.Statistic;
import org.jivesoftware.openfire.stats.StatisticsManager;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.cache.ClusterTask;
import java.io.IOException; import java.io.IOException;
import java.io.ObjectInput; import java.io.ObjectInput;
import java.io.ObjectOutput; import java.io.ObjectOutput;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.jivesoftware.openfire.stats.Statistic;
import org.jivesoftware.openfire.stats.StatisticsManager;
import org.jivesoftware.util.cache.ClusterTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Command that will be executed in each cluster node (except the invoker) to * Command that will be executed in each cluster node (except the invoker) to
* collect samples of statistics that keep track information that is local to * collect samples of statistics that keep track information that is local to
...@@ -38,6 +39,9 @@ import java.util.Map; ...@@ -38,6 +39,9 @@ import java.util.Map;
* @author Gaston Dombiak * @author Gaston Dombiak
*/ */
public class GetStatistics implements ClusterTask { public class GetStatistics implements ClusterTask {
private static final Logger Log = LoggerFactory.getLogger(GetStatistics.class);
private Map<String, Double> samples; private Map<String, Double> samples;
public Object getResult() { public Object getResult() {
......
...@@ -19,10 +19,6 @@ ...@@ -19,10 +19,6 @@
*/ */
package org.jivesoftware.openfire.reporting.stats; package org.jivesoftware.openfire.reporting.stats;
import org.jivesoftware.database.DbConnectionManager;
import org.jivesoftware.util.Log;
import org.jrobin.core.RrdBackend;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
...@@ -30,7 +26,15 @@ import java.sql.Connection; ...@@ -30,7 +26,15 @@ import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import org.jivesoftware.database.DbConnectionManager;
import org.jrobin.core.RrdBackend;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class RrdSqlBackend extends RrdBackend { public class RrdSqlBackend extends RrdBackend {
private static final Logger Log = LoggerFactory.getLogger(RrdSqlBackend.class);
// SQL prepared statements // SQL prepared statements
static final String JDBC_SELECT = "SELECT bytes from ofRRDs where id = ?"; static final String JDBC_SELECT = "SELECT bytes from ofRRDs where id = ?";
static final String JDBC_INSERT = "INSERT INTO ofRRDs (id, updatedDate, bytes) VALUES (?, ?, ?)"; static final String JDBC_INSERT = "INSERT INTO ofRRDs (id, updatedDate, bytes) VALUES (?, ?, ?)";
......
...@@ -47,7 +47,6 @@ import java.util.*; ...@@ -47,7 +47,6 @@ import java.util.*;
*/ */
public class StatsAction { public class StatsAction {
/** /**
* Retrieves a map containing the high / low and current count statistics * Retrieves a map containing the high / low and current count statistics
* for the 'sessions', 'conversations' and 'packet_count' statistics. * for the 'sessions', 'conversations' and 'packet_count' statistics.
...@@ -98,9 +97,9 @@ public class StatsAction { ...@@ -98,9 +97,9 @@ public class StatsAction {
* @param mostRecentConversationID the last conversationID that has been retrieved. * @param mostRecentConversationID the last conversationID that has been retrieved.
* @return a List of Map objects. * @return a List of Map objects.
*/ */
public List getNLatestConversations(int count, long mostRecentConversationID) { public List<Map<String, Long>> getNLatestConversations(int count, long mostRecentConversationID) {
// TODO Fix plugin name 2 lines below and missing classes // TODO Fix plugin name 2 lines below and missing classes
List<Map> cons = new ArrayList<Map>(); List<Map<String, Long>> cons = new ArrayList<Map<String, Long>>();
MonitoringPlugin plugin = (MonitoringPlugin)XMPPServer.getInstance().getPluginManager().getPlugin("monitoring"); MonitoringPlugin plugin = (MonitoringPlugin)XMPPServer.getInstance().getPluginManager().getPlugin("monitoring");
ConversationManager conversationManager = (ConversationManager)plugin.getModule(ConversationManager.class); ConversationManager conversationManager = (ConversationManager)plugin.getModule(ConversationManager.class);
Collection<Conversation> conversations = conversationManager.getConversations(); Collection<Conversation> conversations = conversationManager.getConversations();
...@@ -138,7 +137,7 @@ public class StatsAction { ...@@ -138,7 +137,7 @@ public class StatsAction {
URLEncoder.encode(con.getRoom().getNode(), "UTF-8") + "'>" + con.getRoom().getNode() + URLEncoder.encode(con.getRoom().getNode(), "UTF-8") + "'>" + con.getRoom().getNode() +
"</a></i>)"; "</a></i>)";
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
Log.error(e); Log.error(e.getMessage(), e);
} }
} }
mCon.put("users", users); mCon.put("users", users);
......
...@@ -18,19 +18,35 @@ ...@@ -18,19 +18,35 @@
*/ */
package org.jivesoftware.openfire.reporting.stats; package org.jivesoftware.openfire.reporting.stats;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TimerTask;
import org.jivesoftware.openfire.cluster.ClusterManager; import org.jivesoftware.openfire.cluster.ClusterManager;
import org.jivesoftware.openfire.reporting.util.TaskEngine; import org.jivesoftware.openfire.reporting.util.TaskEngine;
import org.jivesoftware.openfire.stats.Statistic; import org.jivesoftware.openfire.stats.Statistic;
import org.jivesoftware.openfire.stats.StatisticsManager; import org.jivesoftware.openfire.stats.StatisticsManager;
import org.jivesoftware.util.JiveGlobals; import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.cache.CacheFactory; import org.jivesoftware.util.cache.CacheFactory;
import org.jrobin.core.*; import org.jrobin.core.ConsolFuns;
import org.jrobin.core.DsTypes;
import org.jrobin.core.FetchData;
import org.jrobin.core.RrdBackendFactory;
import org.jrobin.core.RrdDb;
import org.jrobin.core.RrdDef;
import org.jrobin.core.RrdException;
import org.jrobin.core.Sample;
import org.picocontainer.Startable; import org.picocontainer.Startable;
import org.slf4j.Logger;
import java.io.File; import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.*;
/** /**
* The stats workhorse. Handles the job of sampling the different statistics existing in * The stats workhorse. Handles the job of sampling the different statistics existing in
...@@ -41,6 +57,8 @@ import java.util.*; ...@@ -41,6 +57,8 @@ import java.util.*;
*/ */
public class StatsEngine implements Startable { public class StatsEngine implements Startable {
private static final Logger Log = LoggerFactory.getLogger(StatsEngine.class);
private static final int STAT_RESOULUTION = 60; private static final int STAT_RESOULUTION = 60;
private final TaskEngine taskEngine; private final TaskEngine taskEngine;
......
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