openmeetings-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebawag...@apache.org
Subject svn commit: r1441976 - in /openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/session: ISessionManager.java SessionManager.java store/DatabaseStore.java store/HashMapStore.java store/IClientPersistenceStore.java
Date Sun, 03 Feb 2013 22:18:43 GMT
Author: sebawagner
Date: Sun Feb  3 22:18:43 2013
New Revision: 1441976

URL: http://svn.apache.org/viewvc?rev=1441976&view=rev
Log:
OPENMEETINGS-460 Fixing persistence using database session client cache

Modified:
    openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/session/ISessionManager.java
    openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/session/SessionManager.java
    openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/session/store/DatabaseStore.java
    openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/session/store/HashMapStore.java
    openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/session/store/IClientPersistenceStore.java

Modified: openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/session/ISessionManager.java
URL: http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/session/ISessionManager.java?rev=1441976&r1=1441975&r2=1441976&view=diff
==============================================================================
--- openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/session/ISessionManager.java
(original)
+++ openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/session/ISessionManager.java
Sun Feb  3 22:18:43 2013
@@ -20,7 +20,6 @@ package org.apache.openmeetings.session;
 
 import java.util.Collection;
 import java.util.List;
-import java.util.Set;
 
 import org.apache.openmeetings.data.beans.basic.SearchResult;
 import org.apache.openmeetings.persistence.beans.basic.Server;
@@ -207,7 +206,7 @@ public interface ISessionManager {
 	 * @param server
 	 * @return
 	 */
-	public abstract Set<Long> getActiveRoomIdsByServer(Server server);
+	public abstract List<Long> getActiveRoomIdsByServer(Server server);
 
 	/**
 	 * Get some statistics about the current sessions

Modified: openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/session/SessionManager.java
URL: http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/session/SessionManager.java?rev=1441976&r1=1441975&r2=1441976&view=diff
==============================================================================
--- openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/session/SessionManager.java
(original)
+++ openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/session/SessionManager.java
Sun Feb  3 22:18:43 2013
@@ -23,12 +23,10 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Date;
-import java.util.HashSet;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map.Entry;
 import java.util.Random;
-import java.util.Set;
 
 import org.apache.openmeetings.OpenmeetingsVariables;
 import org.apache.openmeetings.data.beans.basic.SearchResult;
@@ -53,8 +51,6 @@ public class SessionManager implements I
 	protected static final Logger log = Red5LoggerFactory.getLogger(
 			SessionManager.class, OpenmeetingsVariables.webAppRootKey);
 	
-	private static Set<Long> EMPTY_HASH_SET = new HashSet<Long>();
-	
 	@Autowired
 	private ServerUtil serverUtil;
 	@Autowired
@@ -273,7 +269,7 @@ public class SessionManager implements I
 			ArrayList<Client> roomClientList = new ArrayList<Client>();
 			try {
 
-				for (Client rcl : cache.getClientsByRoomId(roomId).values()) {
+				for (Client rcl : cache.getClientsByRoomId(roomId)) {
 
 					if (rcl.getIsScreenClient() == null || rcl.getIsScreenClient()) {
 						continue;
@@ -296,7 +292,7 @@ public class SessionManager implements I
 		
 		public synchronized Collection<Client> getClientListByRoomAll(Long roomId) {
 			try {
-				return cache.getClientsByRoomId(roomId).values();
+				return cache.getClientsByRoomId(roomId);
 			} catch (Exception err) {
 				log.error("[getClientListByRoomAll]", err);
 			}
@@ -347,11 +343,8 @@ public class SessionManager implements I
 			return numberOfPublishingUsers;
 		}
 		
-		public Set<Long> getActiveRoomIdsByServer(Server server) {
-			if (cache.getClientsByServerAndRoom(server) == null) {
-				return EMPTY_HASH_SET;
-			}
-			return cache.getClientsByServerAndRoom(server).keySet();
+		public List<Long> getActiveRoomIdsByServer(Server server) {
+			return cache.getRoomsIdsByServer(server);
 		}
 		
 		
@@ -449,7 +442,7 @@ public class SessionManager implements I
 		return sessionManager.getPublishingCount(roomId);
 	}
 
-	public Set<Long> getActiveRoomIdsByServer(Server server) {
+	public List<Long> getActiveRoomIdsByServer(Server server) {
 		if (server == null) {
 			server = serverUtil.getCurrentServer();
 		}

Modified: openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/session/store/DatabaseStore.java
URL: http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/session/store/DatabaseStore.java?rev=1441976&r1=1441975&r2=1441976&view=diff
==============================================================================
--- openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/session/store/DatabaseStore.java
(original)
+++ openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/session/store/DatabaseStore.java
Sun Feb  3 22:18:43 2013
@@ -21,7 +21,6 @@ package org.apache.openmeetings.session.
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
-import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -47,7 +46,11 @@ public class DatabaseStore implements IC
 	}
 	
 	public void put(String streamId, Client rcl) {
-		clientDao.add(rcl);
+		if (rcl.getId() > 0) {
+			clientDao.update(rcl);
+		} else {
+			clientDao.add(rcl);
+		}
 	}
 
 	public boolean containsKey(Server server, String streamId) {
@@ -95,39 +98,27 @@ public class DatabaseStore implements IC
 	}
 
 	public List<Client> getClientsByUserId(Server server, Long userId) {
-		// TODO Auto-generated method stub
-		return null;
+		return clientDao.getClientsByUserId(server, userId);
 	}
 
-	public LinkedHashMap<String, Client> getClientsByRoomId(Long roomId) {
-		// TODO Auto-generated method stub
-		return null;
+	public List<Client> getClientsByRoomId(Long roomId) {
+		return clientDao.getClientsByRoomId(roomId);
 	}
 
 	public void remove(Server server, String streamId) {
-		// TODO Auto-generated method stub
-		
+		clientDao.removeClientByServerAndStreamId(server, streamId);
 	}
 
 	public int size() {
-		// TODO Auto-generated method stub
-		return 0;
+		return clientDao.countClients();
 	}
 
 	public int sizeByServer(Server server) {
-		// TODO Auto-generated method stub
-		return 0;
-	}
-
-	public LinkedHashMap<Long, Collection<Client>> getClientsByServerAndRoom(
-			Server server) {
-		// TODO Auto-generated method stub
-		return null;
+		return clientDao.countClientsByServer(server);
 	}
 
 	public Collection<Client> values() {
-		// TODO Auto-generated method stub
-		return null;
+		return clientDao.getClients();
 	}
 
 	public String getDebugInformation(List<DEBUG_DETAILS> detailLevel) {
@@ -135,4 +126,8 @@ public class DatabaseStore implements IC
 		return null;
 	}
 
+	public List<Long> getRoomsIdsByServer(Server server) {
+		return clientDao.getRoomsIdsByServer(server);
+	}
+
 }

Modified: openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/session/store/HashMapStore.java
URL: http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/session/store/HashMapStore.java?rev=1441976&r1=1441975&r2=1441976&view=diff
==============================================================================
--- openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/session/store/HashMapStore.java
(original)
+++ openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/session/store/HashMapStore.java
Sun Feb  3 22:18:43 2013
@@ -110,11 +110,11 @@ public class HashMapStore implements ICl
 		return clientList;
 	}
 	
-	public  LinkedHashMap<String, Client> getClientsByRoomId(Long roomId) {
-		LinkedHashMap<String,Client> clientList = new LinkedHashMap<String, Client>();
+	public  List<Client> getClientsByRoomId(Long roomId) {
+		List<Client> clientList = new ArrayList<Client>();
 		for (Client cl : clientsByStreamId.values()) {
 			if (cl.getRoom_id() != null && cl.getRoom_id().equals(roomId)) {
-				clientList.put(cl.getStreamid(), cl);
+				clientList.add(cl);
 			}
 		}
 		return clientList;
@@ -136,12 +136,6 @@ public class HashMapStore implements ICl
 		return clientsByStreamId.values();
 	}
 	
-	public LinkedHashMap<Long,Collection<Client>> getClientsByServerAndRoom(Server
server) {
-		LinkedHashMap<Long,Collection<Client>> clientsByServer = new LinkedHashMap<Long,Collection<Client>>();
-		clientsByServer.put(null, clientsByStreamId.values());
-		return clientsByServer;
-	}
-	
 	public int getTotalNumberOfSessions() {
 		return clientsByStreamId.size();
 	}
@@ -174,4 +168,8 @@ public class HashMapStore implements ICl
 		strBuilder.append(message + "\n\r");
 	}
 
+	public List<Long> getRoomsIdsByServer(Server server) {
+		throw new RuntimeException("This method should bever be called if the server is running
in a single node (NON-Cluster) setup!");
+	}
+
 }

Modified: openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/session/store/IClientPersistenceStore.java
URL: http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/session/store/IClientPersistenceStore.java?rev=1441976&r1=1441975&r2=1441976&view=diff
==============================================================================
--- openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/session/store/IClientPersistenceStore.java
(original)
+++ openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/session/store/IClientPersistenceStore.java
Sun Feb  3 22:18:43 2013
@@ -19,7 +19,6 @@
 package org.apache.openmeetings.session.store;
 
 import java.util.Collection;
-import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -100,14 +99,11 @@ public interface IClientPersistenceStore
 	/**
 	 * 
 	 * We ignore the server here, cause ONE room can only be on ONE server and often we don't
know where.
-	 * However at a later stage clients might be on different servers and still in the save
room
-	 * so we keep that parameter for now
 	 * 
-	 * @param server
 	 * @param roomId
 	 * @return will return an empty map if nothing available
 	 */
-	public abstract LinkedHashMap<String, Client> getClientsByRoomId(Long roomId);
+	public abstract List<Client> getClientsByRoomId(Long roomId);
 
 	public abstract void remove(Server server, String streamId);
 
@@ -115,9 +111,6 @@ public interface IClientPersistenceStore
 
 	public abstract int sizeByServer(Server server);
 
-	public abstract LinkedHashMap<Long, Collection<Client>> getClientsByServerAndRoom(
-			Server server);
-	
 	public abstract Collection<Client> values();
 	
 	/**
@@ -128,4 +121,6 @@ public interface IClientPersistenceStore
 	 */
 	public abstract String getDebugInformation(List<DEBUG_DETAILS> detailLevel);
 
+	public abstract List<Long> getRoomsIdsByServer(Server server);
+
 }
\ No newline at end of file



Mime
View raw message