Commit 5a2e745b authored by Matt Tucker's avatar Matt Tucker Committed by matt

Work on offline presence optimization.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@6355 b35dd754-fafc-0310-a699-88a17e54d16e
parent c7d972d6
-- $Revision: $
-- $Date: $
CREATE TABLE jivePresence (
username VARCHAR(64) NOT NULL,
offlinePresence VARCHAR(2000),
offlineDate CHAR(15) NOT NULL,
CONSTRAINT jivePresence_pk PRIMARY KEY (username)
);
UPDATE jiveVersion set version=11 where name = 'wildfire';
\ No newline at end of file
CREATE TABLE jivePresence (
username VARCHAR(64) NOT NULL,
offlinePresence LONGVARCHAR,
offlineDate VARCHAR(15) NOT NULL,
CONSTRAINT jivePresence_pk PRIMARY KEY (username)
);
UPDATE jiveVersion set version=11 where name = 'wildfire';
\ No newline at end of file
# $Revision: $
# $Date: $
CREATE TABLE jivePresence (
username VARCHAR(64) NOT NULL,
offlinePresence TEXT,
offlineDate CHAR(15) NOT NULL,
PRIMARY KEY (username)
);
UPDATE jiveVersion set version=11 where name = 'wildfire';
\ No newline at end of file
-- $Revision: $
-- $Date: $
CREATE TABLE jivePresence (
username VARCHAR2(64) NOT NULL,
offlinePresence LONG,
offlineDate CHAR(15) NOT NULL,
CONSTRAINT jivePresence_pk PRIMARY KEY (username)
);
UPDATE jiveVersion set version=11 where name = 'wildfire';
-- $Revision: $
-- $Date: $
CREATE TABLE jivePresence (
username VARCHAR(64) NOT NULL,
offlinePresence TEXT,
offlineDate VARCHAR(15) NOT NULL,
CONSTRAINT jivePresence_pk PRIMARY KEY (username)
);
UPDATE jiveVersion set version=11 where name = 'wildfire';
/* $Revision: $ */
/* $Date: $ */
CREATE TABLE jivePresence (
username NVARCHAR(64) NOT NULL,
offlinePresence NTEXT,
offlineDate CHAR(15) NOT NULL,
CONSTRAINT jivePresence_pk PRIMARY KEY (username)
);
UPDATE jiveVersion set version=11 where name = 'wildfire';
/* $Revision: $ */
/* $Date: $ */
CREATE TABLE jivePresence (
username NVARCHAR(64) NOT NULL,
offlinePresence TEXT,
offlineDate CHAR(15) NOT NULL,
CONSTRAINT jivePresence_pk PRIMARY KEY (username)
);
UPDATE jiveVersion set version=11 where name = 'wildfire';
...@@ -40,6 +40,12 @@ CREATE TABLE jiveOffline ( ...@@ -40,6 +40,12 @@ CREATE TABLE jiveOffline (
CONSTRAINT jiveOffline_pk PRIMARY KEY (username, messageID) CONSTRAINT jiveOffline_pk PRIMARY KEY (username, messageID)
); );
CREATE TABLE jivePresence (
username VARCHAR(64) NOT NULL,
offlinePresence VARCHAR(2000),
offlineDate CHAR(15) NOT NULL,
CONSTRAINT jivePresence_pk PRIMARY KEY (username)
);
CREATE TABLE jiveRoster ( CREATE TABLE jiveRoster (
rosterID INTEGER NOT NULL, rosterID INTEGER NOT NULL,
...@@ -336,7 +342,7 @@ INSERT INTO jiveID (idType, id) VALUES (18, 1); ...@@ -336,7 +342,7 @@ INSERT INTO jiveID (idType, id) VALUES (18, 1);
INSERT INTO jiveID (idType, id) VALUES (19, 1); INSERT INTO jiveID (idType, id) VALUES (19, 1);
INSERT INTO jiveID (idType, id) VALUES (23, 1); INSERT INTO jiveID (idType, id) VALUES (23, 1);
INSERT INTO jiveVersion (name, version) VALUES ('wildfire', 10); INSERT INTO jiveVersion (name, version) VALUES ('wildfire', 11;
-- Entry for admin user -- Entry for admin user
INSERT INTO jiveUser (username, password, name, email, creationDate, modificationDate) INSERT INTO jiveUser (username, password, name, email, creationDate, modificationDate)
......
...@@ -43,7 +43,7 @@ CREATE TABLE jiveOffline ( ...@@ -43,7 +43,7 @@ CREATE TABLE jiveOffline (
CREATE TABLE jivePresence ( CREATE TABLE jivePresence (
username VARCHAR(64) NOT NULL, username VARCHAR(64) NOT NULL,
offlinePresence LONGVARCHAR, offlinePresence LONGVARCHAR,
lastActivity VARCHAR(15), offlineDate VARCHAR(15) NOT NULL,
CONSTRAINT jivePresence_pk PRIMARY KEY (username) CONSTRAINT jivePresence_pk PRIMARY KEY (username)
); );
...@@ -329,7 +329,7 @@ INSERT INTO jiveID (idType, id) VALUES (18, 1); ...@@ -329,7 +329,7 @@ INSERT INTO jiveID (idType, id) VALUES (18, 1);
INSERT INTO jiveID (idType, id) VALUES (19, 1); INSERT INTO jiveID (idType, id) VALUES (19, 1);
INSERT INTO jiveID (idType, id) VALUES (23, 1); INSERT INTO jiveID (idType, id) VALUES (23, 1);
INSERT INTO jiveVersion (name, version) VALUES ('wildfire', 10); INSERT INTO jiveVersion (name, version) VALUES ('wildfire', 11);
// Entry for admin user // Entry for admin user
INSERT INTO jiveUser (username, password, name, email, creationDate, modificationDate) INSERT INTO jiveUser (username, password, name, email, creationDate, modificationDate)
......
...@@ -57,6 +57,13 @@ CREATE TABLE jiveOffline ( ...@@ -57,6 +57,13 @@ CREATE TABLE jiveOffline (
PRIMARY KEY (username, messageID) PRIMARY KEY (username, messageID)
); );
CREATE TABLE jivePresence (
username VARCHAR(64) NOT NULL,
offlinePresence TEXT,
offlineDate CHAR(15) NOT NULL,
PRIMARY KEY (username)
);
CREATE TABLE jiveRoster ( CREATE TABLE jiveRoster (
rosterID BIGINT NOT NULL, rosterID BIGINT NOT NULL,
username VARCHAR(64) NOT NULL, username VARCHAR(64) NOT NULL,
...@@ -311,7 +318,7 @@ INSERT INTO jiveID (idType, id) VALUES (18, 1); ...@@ -311,7 +318,7 @@ INSERT INTO jiveID (idType, id) VALUES (18, 1);
INSERT INTO jiveID (idType, id) VALUES (19, 1); INSERT INTO jiveID (idType, id) VALUES (19, 1);
INSERT INTO jiveID (idType, id) VALUES (23, 1); INSERT INTO jiveID (idType, id) VALUES (23, 1);
INSERT INTO jiveVersion (name, version) VALUES ('wildfire', 10); INSERT INTO jiveVersion (name, version) VALUES ('wildfire', 11);
# Entry for admin user # Entry for admin user
INSERT INTO jiveUser (username, password, name, email, creationDate, modificationDate) INSERT INTO jiveUser (username, password, name, email, creationDate, modificationDate)
......
...@@ -41,6 +41,14 @@ CREATE TABLE jiveOffline ( ...@@ -41,6 +41,14 @@ CREATE TABLE jiveOffline (
); );
CREATE TABLE jivePresence (
username VARCHAR2(64) NOT NULL,
offlinePresence LONG,
offlineDate CHAR(15) NOT NULL,
CONSTRAINT jivePresence_pk PRIMARY KEY (username)
);
CREATE TABLE jiveRoster ( CREATE TABLE jiveRoster (
rosterID INTEGER NOT NULL, rosterID INTEGER NOT NULL,
username VARCHAR2(64) NOT NULL, username VARCHAR2(64) NOT NULL,
...@@ -317,7 +325,7 @@ INSERT INTO jiveID (idType, id) VALUES (18, 1); ...@@ -317,7 +325,7 @@ INSERT INTO jiveID (idType, id) VALUES (18, 1);
INSERT INTO jiveID (idType, id) VALUES (19, 1); INSERT INTO jiveID (idType, id) VALUES (19, 1);
INSERT INTO jiveID (idType, id) VALUES (23, 1); INSERT INTO jiveID (idType, id) VALUES (23, 1);
INSERT INTO jiveVersion (name, version) VALUES ('wildfire', 10); INSERT INTO jiveVersion (name, version) VALUES ('wildfire', 11);
-- Entry for admin user -- Entry for admin user
INSERT INTO jiveUser (username, password, name, email, creationDate, modificationDate) INSERT INTO jiveUser (username, password, name, email, creationDate, modificationDate)
......
...@@ -43,6 +43,14 @@ CREATE TABLE jiveOffline ( ...@@ -43,6 +43,14 @@ CREATE TABLE jiveOffline (
); );
CREATE TABLE jivePresence (
username VARCHAR(64) NOT NULL,
offlinePresence TEXT,
offlineDate VARCHAR(15) NOT NULL,
CONSTRAINT jivePresence_pk PRIMARY KEY (username)
);
CREATE TABLE jiveRoster ( CREATE TABLE jiveRoster (
rosterID INTEGER NOT NULL, rosterID INTEGER NOT NULL,
username VARCHAR(64) NOT NULL, username VARCHAR(64) NOT NULL,
...@@ -326,7 +334,7 @@ INSERT INTO jiveID (idType, id) VALUES (18, 1); ...@@ -326,7 +334,7 @@ INSERT INTO jiveID (idType, id) VALUES (18, 1);
INSERT INTO jiveID (idType, id) VALUES (19, 1); INSERT INTO jiveID (idType, id) VALUES (19, 1);
INSERT INTO jiveID (idType, id) VALUES (23, 1); INSERT INTO jiveID (idType, id) VALUES (23, 1);
INSERT INTO jiveVersion (name, version) VALUES ('wildfire', 10); INSERT INTO jiveVersion (name, version) VALUES ('wildfire', 11);
-- Entry for admin user -- Entry for admin user
INSERT INTO jiveUser (username, password, name, email, creationDate, modificationDate) INSERT INTO jiveUser (username, password, name, email, creationDate, modificationDate)
......
...@@ -41,6 +41,14 @@ CREATE TABLE jiveOffline ( ...@@ -41,6 +41,14 @@ CREATE TABLE jiveOffline (
); );
CREATE TABLE jivePresence (
username NVARCHAR(64) NOT NULL,
offlinePresence NTEXT,
offlineDate CHAR(15) NOT NULL,
CONSTRAINT jivePresence_pk PRIMARY KEY (username)
);
CREATE TABLE jiveRoster ( CREATE TABLE jiveRoster (
rosterID INTEGER NOT NULL, rosterID INTEGER NOT NULL,
username NVARCHAR(64) NOT NULL, username NVARCHAR(64) NOT NULL,
...@@ -324,7 +332,7 @@ INSERT INTO jiveID (idType, id) VALUES (18, 1); ...@@ -324,7 +332,7 @@ INSERT INTO jiveID (idType, id) VALUES (18, 1);
INSERT INTO jiveID (idType, id) VALUES (19, 1); INSERT INTO jiveID (idType, id) VALUES (19, 1);
INSERT INTO jiveID (idType, id) VALUES (23, 1); INSERT INTO jiveID (idType, id) VALUES (23, 1);
INSERT INTO jiveVersion (name, version) VALUES ('wildfire', 10); INSERT INTO jiveVersion (name, version) VALUES ('wildfire', 11);
/* Entry for admin user */ /* Entry for admin user */
INSERT INTO jiveUser (username, password, name, email, creationDate, modificationDate) INSERT INTO jiveUser (username, password, name, email, creationDate, modificationDate)
......
...@@ -39,6 +39,14 @@ CREATE TABLE jiveOffline ( ...@@ -39,6 +39,14 @@ CREATE TABLE jiveOffline (
message TEXT NOT NULL, message TEXT NOT NULL,
CONSTRAINT jiveOffline_pk PRIMARY KEY (username, messageID) CONSTRAINT jiveOffline_pk PRIMARY KEY (username, messageID)
); );
CREATE TABLE jivePresence (
username NVARCHAR(64) NOT NULL,
offlinePresence TEXT,
offlineDate CHAR(15) NOT NULL,
CONSTRAINT jivePresence_pk PRIMARY KEY (username)
);
CREATE TABLE jiveRoster ( CREATE TABLE jiveRoster (
...@@ -324,7 +332,7 @@ INSERT INTO jiveID (idType, id) VALUES (18, 1); ...@@ -324,7 +332,7 @@ INSERT INTO jiveID (idType, id) VALUES (18, 1);
INSERT INTO jiveID (idType, id) VALUES (19, 1); INSERT INTO jiveID (idType, id) VALUES (19, 1);
INSERT INTO jiveID (idType, id) VALUES (23, 1); INSERT INTO jiveID (idType, id) VALUES (23, 1);
INSERT INTO jiveVersion (name, version) VALUES ('wildfire', 10); INSERT INTO jiveVersion (name, version) VALUES ('wildfire', 11);
/* Entry for admin user */ /* Entry for admin user */
INSERT INTO jiveUser (username, password, name, email, creationDate, modificationDate) INSERT INTO jiveUser (username, password, name, email, creationDate, modificationDate)
......
...@@ -44,7 +44,7 @@ public class SchemaManager { ...@@ -44,7 +44,7 @@ public class SchemaManager {
/** /**
* Current Wildfire database schema version. * Current Wildfire database schema version.
*/ */
private static final int DATABASE_VERSION = 10; private static final int DATABASE_VERSION = 11;
/** /**
* Creates a new Schema manager. * Creates a new Schema manager.
......
...@@ -682,8 +682,8 @@ public class ClientSession extends Session { ...@@ -682,8 +682,8 @@ public class ClientSession extends Session {
wasAvailable = true; wasAvailable = true;
// Notify listeners that the session is now available // Notify listeners that the session is now available
PresenceEventDispatcher.availableSession(this, presence); PresenceEventDispatcher.availableSession(this, presence);
} else }
if (this.presence.isAvailable() && oldPresence.getPriority() != this.presence.getPriority()) else if (this.presence.isAvailable() && oldPresence.getPriority() != this.presence.getPriority())
{ {
// The client has changed the priority of his presence // The client has changed the priority of his presence
sessionManager.changePriority(getAddress(), this.presence.getPriority()); sessionManager.changePriority(getAddress(), this.presence.getPriority());
......
...@@ -1269,6 +1269,27 @@ public class SessionManager extends BasicModule { ...@@ -1269,6 +1269,27 @@ public class SessionManager extends BasicModule {
return anonymousSessions.size(); return anonymousSessions.size();
} }
/**
* Returns the number of sessions for a user that are available. For the count
* of all sessions for the user, including sessions that are just starting
* or closed, see {@see #getSessionCount(String)}.
*
* @param username the user.
* @return number of available sessions for a user.
*/
public int getActiveSessionCount(String username) {
if (username == null || !userManager.isRegisteredUser(username)) {
return 0;
}
int sessionCount = 0;
for (Session session: sessions.get(username).getSessions()) {
if (session.getStatus() != Session.STATUS_CLOSED) {
sessionCount++;
}
}
return sessionCount;
}
public int getSessionCount(String username) { public int getSessionCount(String username) {
if (username == null || !userManager.isRegisteredUser(username)) { if (username == null || !userManager.isRegisteredUser(username)) {
return 0; return 0;
......
...@@ -273,28 +273,6 @@ public class UserManager implements IQResultListener { ...@@ -273,28 +273,6 @@ public class UserManager implements IQResultListener {
return provider.findUsers(fields, query); return provider.findUsers(fields, query);
} }
/**
* Returns the value of the specified property for the given username. If the user
* has been loaded into memory then the ask the user to return the value of the
* property. However, if the user is not present in memory then try to get the property
* value directly from the database as a way to optimize the performance.
*
* @param username the username of the user to get a specific property value.
* @param propertyName the name of the property to return its value.
* @return the value of the specified property for the given username.
*/
public String getUserProperty(String username, String propertyName) {
username = username.trim().toLowerCase();
User user = userCache.get(username);
if (user == null) {
return User.getPropertyValue(username, propertyName);
}
else {
// User is in memory so ask the user for the specified property value
return user.getProperties().get(propertyName);
}
}
/** /**
* Returns true if the specified local username belongs to a registered local user. * Returns true if the specified local username belongs to a registered local user.
* *
......
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