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 @@
Monitoring Plugin Changelog
</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>
<ul>
......
......@@ -5,9 +5,9 @@
<name>Monitoring Service</name>
<description>Monitors conversations and statistics of the server.</description>
<author>Jive Software</author>
<version>1.1.1</version>
<date>11/14/2008</date>
<minServerVersion>3.6.0</minServerVersion>
<version>1.2.0</version>
<date>12/1/2009</date>
<minServerVersion>3.6.5</minServerVersion>
<databaseKey>monitoring</databaseKey>
<databaseVersion>0</databaseVersion>
......
......@@ -19,7 +19,29 @@
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.document.DateTools;
import org.apache.lucene.document.Document;
......@@ -34,26 +56,15 @@ import org.dom4j.DocumentFactory;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;
import org.jivesoftware.database.DbConnectionManager;
import org.jivesoftware.openfire.reporting.util.TaskEngine;
import org.jivesoftware.util.JiveConstants;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.XMLProperties;
import org.picocontainer.Startable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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,
* 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;
*/
public class ArchiveIndexer implements Startable {
private static final Logger Log = LoggerFactory.getLogger(ArchiveIndexer.class);
private static final String ALL_CONVERSATIONS =
"SELECT conversationID, isExternal FROM ofConversation";
private static final String NEW_CONVERSATIONS =
......@@ -124,7 +137,7 @@ public class ArchiveIndexer implements Startable {
}
}
catch (IOException ioe) {
Log.error(ioe);
Log.error(ioe.getMessage(), ioe);
}
writerLock = new ReentrantLock(true);
......@@ -138,7 +151,7 @@ public class ArchiveIndexer implements Startable {
}
}
catch (IOException ioe) {
Log.error(ioe);
Log.error(ioe.getMessage(), ioe);
}
String modified = indexProperties.getProperty("lastModified");
......@@ -177,7 +190,7 @@ public class ArchiveIndexer implements Startable {
searcher.close();
}
catch (Exception e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
searcher = null;
}
......@@ -185,7 +198,7 @@ public class ArchiveIndexer implements Startable {
directory.close();
}
catch (Exception e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
directory = null;
indexProperties = null;
......@@ -251,7 +264,7 @@ public class ArchiveIndexer implements Startable {
}
}
catch (SQLException sqle) {
Log.error(sqle);
Log.error(sqle.getMessage(), sqle);
}
finally {
DbConnectionManager.closeConnection(rs, pstmt, con);
......@@ -276,7 +289,7 @@ public class ArchiveIndexer implements Startable {
}
}
catch (SQLException sqle) {
Log.error(sqle);
Log.error(sqle.getMessage(), sqle);
}
finally {
DbConnectionManager.closeConnection(rs, pstmt, con);
......@@ -295,7 +308,7 @@ public class ArchiveIndexer implements Startable {
}
}
catch (IOException ioe) {
Log.error(ioe);
Log.error(ioe.getMessage(), ioe);
}
finally {
if (writer != null) {
......@@ -303,7 +316,7 @@ public class ArchiveIndexer implements Startable {
writer.close();
}
catch (Exception e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
}
writerLock.unlock();
......@@ -358,7 +371,7 @@ public class ArchiveIndexer implements Startable {
}
}
catch (SQLException sqle) {
Log.error(sqle);
Log.error(sqle.getMessage(), sqle);
}
finally {
DbConnectionManager.closeConnection(rs, pstmt, con);
......@@ -381,7 +394,7 @@ public class ArchiveIndexer implements Startable {
}
}
catch (IOException ioe) {
Log.error(ioe);
Log.error(ioe.getMessage(), ioe);
}
finally {
if (writer != null) {
......@@ -389,7 +402,7 @@ public class ArchiveIndexer implements Startable {
writer.close();
}
catch (Exception e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
}
writerLock.unlock();
......@@ -518,7 +531,7 @@ public class ArchiveIndexer implements Startable {
}
}
catch (SQLException sqle) {
Log.error(sqle);
Log.error(sqle.getMessage(), sqle);
}
finally {
DbConnectionManager.closeConnection(rs, pstmt, con);
......@@ -598,7 +611,7 @@ public class ArchiveIndexer implements Startable {
outputter.flush();
}
catch (Exception e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
finally {
try {
......@@ -617,7 +630,7 @@ public class ArchiveIndexer implements Startable {
/**
* 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;
......
......@@ -19,25 +19,41 @@
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.document.DateTools;
import org.apache.lucene.index.Term;
import org.apache.lucene.queryParser.ParseException;
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.DbConnectionManager;
import org.jivesoftware.util.Log;
import org.picocontainer.Startable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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,
* this class does nothing. Searches may or may not include keyword searching. When
......@@ -50,6 +66,8 @@ import java.util.*;
*/
public class ArchiveSearcher implements Startable {
private static final Logger Log = LoggerFactory.getLogger(ArchiveSearch.class);
private ConversationManager conversationManager;
private ArchiveIndexer archiveIndexer;
......@@ -196,11 +214,11 @@ public class ArchiveSearcher implements Startable {
}
}
catch (ParseException pe) {
Log.error(pe);
Log.error(pe.getMessage(), pe);
return Collections.emptySet();
}
catch (IOException ioe) {
Log.error(ioe);
Log.error(ioe.getMessage(), ioe);
return Collections.emptySet();
}
}
......@@ -382,7 +400,7 @@ public class ArchiveSearcher implements Startable {
rs.close();
}
catch (SQLException sqle) {
Log.error(sqle);
Log.error(sqle.getMessage(), sqle);
}
finally {
DbConnectionManager.closeConnection(pstmt, con);
......@@ -394,7 +412,7 @@ public class ArchiveSearcher implements Startable {
* Returns Hits from a database search against archived conversations as a Collection
* of Conversation objects.
*/
private class DatabaseQueryResults extends AbstractCollection {
private class DatabaseQueryResults extends AbstractCollection<Conversation> {
private List<Long> conversationIDs;
......@@ -407,11 +425,11 @@ public class ArchiveSearcher implements Startable {
this.conversationIDs = conversationIDs;
}
public Iterator iterator() {
public Iterator<Conversation> 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() {
if (nextElement == null) {
......@@ -423,8 +441,8 @@ public class ArchiveSearcher implements Startable {
return true;
}
public Object next() {
Object element;
public Conversation next() {
Conversation element;
if (nextElement != null) {
element = nextElement;
nextElement = null;
......@@ -442,7 +460,7 @@ public class ArchiveSearcher implements Startable {
throw new UnsupportedOperationException();
}
private Object getNextElement() {
private Conversation getNextElement() {
if (!convIterator.hasNext()) {
return null;
}
......@@ -452,7 +470,7 @@ public class ArchiveSearcher implements Startable {
return new Conversation(conversationManager, conversationID);
}
catch (Exception e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
}
return null;
......@@ -469,7 +487,7 @@ public class ArchiveSearcher implements Startable {
* Returns Hits from a Lucene search against archived conversations as a Collection
* of Conversation objects.
*/
private class LuceneQueryResults extends AbstractCollection {
private class LuceneQueryResults extends AbstractCollection<Conversation> {
private Hits hits;
private int index;
......@@ -488,15 +506,15 @@ public class ArchiveSearcher implements Startable {
this.endIndex = endIndex;
}
public Iterator iterator() {
final Iterator hitsIterator = hits.iterator();
public Iterator<Conversation> iterator() {
final Iterator<Hit> hitsIterator = hits.iterator();
// Advance the iterator until we hit the index.
for (int i=0; i<index; i++) {
hitsIterator.next();
}
return new Iterator() {
return new Iterator<Conversation>() {
private Object nextElement = null;
private Conversation nextElement = null;
public boolean hasNext() {
if (nextElement == null) {
......@@ -508,8 +526,8 @@ public class ArchiveSearcher implements Startable {
return true;
}
public Object next() {
Object element;
public Conversation next() {
Conversation element;
if (nextElement != null) {
element = nextElement;
nextElement = null;
......@@ -527,7 +545,7 @@ public class ArchiveSearcher implements Startable {
throw new UnsupportedOperationException();
}
private Object getNextElement() {
private Conversation getNextElement() {
if (!hitsIterator.hasNext()) {
return null;
}
......@@ -537,7 +555,7 @@ public class ArchiveSearcher implements Startable {
}
while (hitsIterator.hasNext()) {
try {
Hit hit = (Hit)hitsIterator.next();
Hit hit = hitsIterator.next();
// Advance the index.
index++;
......@@ -545,7 +563,7 @@ public class ArchiveSearcher implements Startable {
return new Conversation(conversationManager, conversationID);
}
catch (Exception e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
}
return null;
......
......@@ -19,34 +19,42 @@
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.JiveID;
import org.jivesoftware.database.SequenceManager;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.muc.MUCRole;
import org.jivesoftware.openfire.muc.MUCRoom;
import org.jivesoftware.openfire.plugin.MonitoringPlugin;
import org.jivesoftware.openfire.user.UserNameManager;
import org.jivesoftware.openfire.user.UserNotFoundException;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.NotFoundException;
import org.jivesoftware.util.cache.ExternalizableUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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
* 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;
@JiveID(50)
public class Conversation implements Externalizable {
private static final Logger Log = LoggerFactory.getLogger(Conversation.class);
private static final String INSERT_CONVERSATION =
"INSERT INTO ofConversation(conversationID, room, isExternal, startDate, " +
"lastActivity, messageCount) VALUES (?,?,?,?,?,0)";
......@@ -139,7 +149,7 @@ public class Conversation implements Externalizable {
insertIntoDb();
}
catch (Exception e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
}
}
......@@ -174,7 +184,7 @@ public class Conversation implements Externalizable {
insertIntoDb();
}
catch (Exception e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
}
}
......@@ -315,7 +325,7 @@ public class Conversation implements Externalizable {
}
}
catch (SQLException sqle) {
Log.error(sqle);
Log.error(sqle.getMessage(), sqle);
}
finally {
DbConnectionManager.closeConnection(rs, pstmt, con);
......@@ -432,7 +442,7 @@ public class Conversation implements Externalizable {
}
}
catch (Exception e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
}
}
......@@ -574,7 +584,7 @@ public class Conversation implements Externalizable {
}
}
catch (SQLException sqle) {
Log.error(sqle);
Log.error(sqle.getMessage(), sqle);
}
finally {
DbConnectionManager.closeConnection(rs, pstmt, con);
......
......@@ -35,6 +35,8 @@ import org.jivesoftware.openfire.stats.StatisticsManager;
import org.jivesoftware.util.*;
import org.jivesoftware.util.cache.CacheFactory;
import org.picocontainer.Startable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xmpp.packet.IQ;
import org.xmpp.packet.JID;
import org.xmpp.packet.Message;
......@@ -57,15 +59,17 @@ import java.util.concurrent.CopyOnWriteArraySet;
* 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
* 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
* 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
*/
public class ConversationManager implements Startable, ComponentEventListener {
private static final Logger Log = LoggerFactory.getLogger(ConversationManager.class);
private static final String UPDATE_CONVERSATION =
"UPDATE ofConversation SET lastActivity=?, messageCount=? WHERE conversationID=?";
private static final String UPDATE_PARTICIPANT =
......@@ -499,7 +503,7 @@ public class ConversationManager implements Startable, ComponentEventListener {
}
}
catch (SQLException sqle) {
Log.error(sqle);
Log.error(sqle.getMessage(), sqle);
}
finally {
DbConnectionManager.closeConnection(rs, pstmt, con);
......@@ -526,7 +530,7 @@ public class ConversationManager implements Startable, ComponentEventListener {
}
}
catch (SQLException sqle) {
Log.error(sqle);
Log.error(sqle.getMessage(), sqle);
}
finally {
DbConnectionManager.closeConnection(rs, pstmt, con);
......@@ -821,8 +825,8 @@ public class ConversationManager implements Startable, ComponentEventListener {
//Check if the component is a gateway
boolean gatewayFound = false;
Element childElement = iq.getChildElement();
for (Iterator it = childElement.elementIterator("identity"); it.hasNext();) {
Element identity = (Element)it.next();
for (Iterator<Element> it = childElement.elementIterator("identity"); it.hasNext();) {
Element identity = it.next();
if ("gateway".equals(identity.attributeValue("category"))) {
gatewayFound = true;
}
......@@ -943,7 +947,7 @@ public class ConversationManager implements Startable, ComponentEventListener {
}
}
catch (Exception e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
finally {
DbConnectionManager.closeConnection(pstmt, con);
......@@ -960,7 +964,7 @@ public class ConversationManager implements Startable, ComponentEventListener {
*/
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")) {
String value = (String)params.get("value");
metadataArchivingEnabled = Boolean.valueOf(value);
......@@ -991,7 +995,7 @@ public class ConversationManager implements Startable, ComponentEventListener {
idleTime = Integer.parseInt(value) * JiveConstants.MINUTE;
}
catch (Exception e) {
Log.error(e);
Log.error(e.getMessage(), e);
idleTime = DEFAULT_IDLE_TIME * JiveConstants.MINUTE;
}
}
......@@ -1001,13 +1005,13 @@ public class ConversationManager implements Startable, ComponentEventListener {
maxTime = Integer.parseInt(value) * JiveConstants.MINUTE;
}
catch (Exception e) {
Log.error(e);
Log.error(e.getMessage(), e);
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")) {
metadataArchivingEnabled = true;
}
......@@ -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.
}
public void xmlPropertyDeleted(String property, Map params) {
public void xmlPropertyDeleted(String property, Map<String, Object> params) {
// Ignore.
}
}
......
......@@ -18,25 +18,26 @@
*/
package org.jivesoftware.openfire.archive;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.plugin.MonitoringPlugin;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.NotFoundException;
import org.jivesoftware.util.ParamUtils;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
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 {
private static final Logger Log = LoggerFactory.getLogger(ConversationPDFServlet.class);
public void init() throws ServletException {
}
......@@ -63,7 +64,7 @@ public class ConversationPDFServlet extends HttpServlet {
response.setHeader("Pragma", "public");
// setting the content type
response.setContentType("application/pdf");
// the contentlength is needed for MSIE!!!
// the content length is needed for MSIE!!!
response.setContentLength(stream.size());
// write ByteArrayOutputStream to the ServletOutputStream
ServletOutputStream out = response.getOutputStream();
......@@ -71,7 +72,7 @@ public class ConversationPDFServlet extends HttpServlet {
out.flush();
}
catch (NotFoundException nfe) {
Log.error(nfe);
Log.error(nfe.getMessage(), nfe);
}
}
......
......@@ -19,28 +19,39 @@
package org.jivesoftware.openfire.archive;
import com.lowagie.text.*;
import com.lowagie.text.Font;
import com.lowagie.text.Image;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfPageEventHelper;
import com.lowagie.text.pdf.PdfWriter;
import java.awt.Color;
import java.io.ByteArrayOutputStream;
import java.net.URL;
import java.util.Arrays;
import java.util.Collection;
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.plugin.MonitoringPlugin;
import org.jivesoftware.openfire.user.UserManager;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.NotFoundException;
import org.xmpp.component.ComponentManagerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xmpp.packet.JID;
import java.awt.*;
import java.io.ByteArrayOutputStream;
import java.net.URL;
import java.util.*;
import java.util.List;
import java.util.concurrent.Future;
import com.lowagie.text.Chunk;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Font;
import com.lowagie.text.FontFactory;
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.
......@@ -49,6 +60,8 @@ import java.util.concurrent.Future;
*/
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
* asynchronously.
......@@ -69,7 +82,7 @@ public class ConversationUtils {
return future.get();
}
catch (Exception e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
}
......@@ -93,7 +106,7 @@ public class ConversationUtils {
info = toConversationInfo(conversation, formatParticipants);
}
catch (NotFoundException e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
return info;
......
......@@ -19,26 +19,30 @@
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.ObjectInput;
import java.io.ObjectOutput;
import java.util.ArrayList;
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.
*
* @author Gaston Dombiak
*/
public class SendConversationEventsTask implements ClusterTask {
private static final Logger Log = LoggerFactory.getLogger(SendConversationEventsTask.class);
private List<ConversationEvent> events;
/**
......
......@@ -21,26 +21,31 @@
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.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.SessionData;
import org.jivesoftware.openfire.component.InternalComponentManager;
import org.jivesoftware.openfire.plugin.MonitoringPlugin;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xmpp.component.ComponentManagerFactory;
import org.xmpp.forms.DataForm;
import org.xmpp.forms.FormField;
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.
*
......@@ -50,6 +55,8 @@ import java.util.List;
*/
public class GetGroupConversationTranscript extends AdHocCommand {
private static final Logger Log = LoggerFactory.getLogger(GetGroupConversationTranscript.class);
protected void addStageInformation(SessionData data, Element command) {
DataForm form = new DataForm(DataForm.Type.form);
form.setTitle("Requesting PDF of conversation transcript");
......
......@@ -83,7 +83,7 @@ public class MonitoringPlugin implements Plugin {
* @param clazz the module class.
* @return the instance of the module.
*/
public Object getModule(Class clazz) {
public Object getModule(Class<?> clazz) {
return picoContainer.getComponentInstanceOfType(clazz);
}
......
......@@ -19,27 +19,33 @@
*/
package org.jivesoftware.openfire.reporting;
import org.jivesoftware.util.Log;
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 java.io.IOException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
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.
*/
public class MonitoringDWR extends DWRServlet {
private static final Logger Log = LoggerFactory.getLogger(MonitoringDWR.class);
private Document document;
public void configure(ServletConfig servletConfig, Configuration configuration) throws ServletException {
......
......@@ -22,12 +22,14 @@ package org.jivesoftware.openfire.reporting.stats;
import org.jivesoftware.openfire.cluster.ClusterManager;
import org.jivesoftware.openfire.stats.Statistic;
import org.jivesoftware.util.Log;
import org.jrobin.core.RrdDb;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class DefaultStatsViewer implements StatsViewer {
private static final Logger Log = LoggerFactory.getLogger(DefaultStatsViewer.class);
private StatsEngine engine;
/**
......
......@@ -18,17 +18,18 @@
*/
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.ObjectInput;
import java.io.ObjectOutput;
import java.util.HashMap;
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
* collect samples of statistics that keep track information that is local to
......@@ -38,6 +39,9 @@ import java.util.Map;
* @author Gaston Dombiak
*/
public class GetStatistics implements ClusterTask {
private static final Logger Log = LoggerFactory.getLogger(GetStatistics.class);
private Map<String, Double> samples;
public Object getResult() {
......
......@@ -19,10 +19,6 @@
*/
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.FileInputStream;
import java.io.IOException;
......@@ -30,7 +26,15 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
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 {
private static final Logger Log = LoggerFactory.getLogger(RrdSqlBackend.class);
// SQL prepared statements
static final String JDBC_SELECT = "SELECT bytes from ofRRDs where id = ?";
static final String JDBC_INSERT = "INSERT INTO ofRRDs (id, updatedDate, bytes) VALUES (?, ?, ?)";
......
......@@ -47,7 +47,6 @@ import java.util.*;
*/
public class StatsAction {
/**
* Retrieves a map containing the high / low and current count statistics
* for the 'sessions', 'conversations' and 'packet_count' statistics.
......@@ -98,9 +97,9 @@ public class StatsAction {
* @param mostRecentConversationID the last conversationID that has been retrieved.
* @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
List<Map> cons = new ArrayList<Map>();
List<Map<String, Long>> cons = new ArrayList<Map<String, Long>>();
MonitoringPlugin plugin = (MonitoringPlugin)XMPPServer.getInstance().getPluginManager().getPlugin("monitoring");
ConversationManager conversationManager = (ConversationManager)plugin.getModule(ConversationManager.class);
Collection<Conversation> conversations = conversationManager.getConversations();
......@@ -138,7 +137,7 @@ public class StatsAction {
URLEncoder.encode(con.getRoom().getNode(), "UTF-8") + "'>" + con.getRoom().getNode() +
"</a></i>)";
} catch (UnsupportedEncodingException e) {
Log.error(e);
Log.error(e.getMessage(), e);
}
}
mCon.put("users", users);
......
......@@ -18,19 +18,35 @@
*/
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.reporting.util.TaskEngine;
import org.jivesoftware.openfire.stats.Statistic;
import org.jivesoftware.openfire.stats.StatisticsManager;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
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 java.io.File;
import java.io.IOException;
import java.util.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The stats workhorse. Handles the job of sampling the different statistics existing in
......@@ -41,6 +57,8 @@ import java.util.*;
*/
public class StatsEngine implements Startable {
private static final Logger Log = LoggerFactory.getLogger(StatsEngine.class);
private static final int STAT_RESOULUTION = 60;
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