Commit 883436ff authored by Matt Tucker's avatar Matt Tucker Committed by matt

Added stat for users created.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@6419 b35dd754-fafc-0310-a699-88a17e54d16e
parent 20adaba1
...@@ -17,11 +17,15 @@ import org.jivesoftware.stringprep.StringprepException; ...@@ -17,11 +17,15 @@ import org.jivesoftware.stringprep.StringprepException;
import org.jivesoftware.util.*; import org.jivesoftware.util.*;
import org.jivesoftware.wildfire.IQResultListener; import org.jivesoftware.wildfire.IQResultListener;
import org.jivesoftware.wildfire.XMPPServer; import org.jivesoftware.wildfire.XMPPServer;
import org.jivesoftware.wildfire.stats.StatisticsManager;
import org.jivesoftware.wildfire.stats.i18nStatistic;
import org.jivesoftware.wildfire.stats.Statistic;
import org.jivesoftware.wildfire.event.UserEventDispatcher; import org.jivesoftware.wildfire.event.UserEventDispatcher;
import org.xmpp.packet.IQ; import org.xmpp.packet.IQ;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
/** /**
* Manages users, including loading, creating and deleting. * Manages users, including loading, creating and deleting.
...@@ -42,6 +46,8 @@ public class UserManager implements IQResultListener { ...@@ -42,6 +46,8 @@ public class UserManager implements IQResultListener {
private static UserProvider provider; private static UserProvider provider;
private static UserManager instance = new UserManager(); private static UserManager instance = new UserManager();
private static final String USERS_CREATED_STAT = "users_created";
static { static {
// Initialize caches. // Initialize caches.
userCache = CacheManager.initializeCache("User", "userCache", 512 * 1024, userCache = CacheManager.initializeCache("User", "userCache", 512 * 1024,
...@@ -96,8 +102,18 @@ public class UserManager implements IQResultListener { ...@@ -96,8 +102,18 @@ public class UserManager implements IQResultListener {
return instance; return instance;
} }
private AtomicInteger usersCreated = new AtomicInteger(0);
private UserManager() { private UserManager() {
// Add a statistic to record users being created.
StatisticsManager.getInstance().addStatistic(USERS_CREATED_STAT, new i18nStatistic(USERS_CREATED_STAT,
Statistic.Type.rate_total)
{
public double sample() {
return usersCreated.getAndSet(0);
}
});
} }
/** /**
...@@ -134,6 +150,9 @@ public class UserManager implements IQResultListener { ...@@ -134,6 +150,9 @@ public class UserManager implements IQResultListener {
UserEventDispatcher.dispatchEvent(user, UserEventDispatcher.EventType.user_created, UserEventDispatcher.dispatchEvent(user, UserEventDispatcher.EventType.user_created,
Collections.emptyMap()); Collections.emptyMap());
// Increment users created statistic.
usersCreated.getAndIncrement();
return user; return user;
} }
...@@ -377,7 +396,6 @@ public class UserManager implements IQResultListener { ...@@ -377,7 +396,6 @@ public class UserManager implements IQResultListener {
} }
} }
private static void initProvider() { private static void initProvider() {
String className = JiveGlobals.getXMLProperty("provider.user.className", String className = JiveGlobals.getXMLProperty("provider.user.className",
"org.jivesoftware.wildfire.user.DefaultUserProvider"); "org.jivesoftware.wildfire.user.DefaultUserProvider");
......
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