openmeetings-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebawag...@apache.org
Subject svn commit: r1442019 - in /openmeetings/trunk/singlewebapp/src/org/apache/openmeetings: data/conference/dao/ persistence/beans/rooms/ remote/ session/ session/store/ test/session/
Date Mon, 04 Feb 2013 03:39:55 GMT
Author: sebawagner
Date: Mon Feb  4 03:39:55 2013
New Revision: 1442019

URL: http://svn.apache.org/viewvc?rev=1442019&view=rev
Log:
OPENMEETINGS-460 Fix getting active roomid's by server + Test, temporary fix for login into
conference room when cluster is enabled (only single node tested yet)

Added:
    openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/test/session/TestDbSessionGetRoomIds.java
Modified:
    openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/data/conference/dao/ClientDao.java
    openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/persistence/beans/rooms/Client.java
    openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/remote/ConferenceService.java
    openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/session/ISessionManager.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/data/conference/dao/ClientDao.java
URL: http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/data/conference/dao/ClientDao.java?rev=1442019&r1=1442018&r2=1442019&view=diff
==============================================================================
--- openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/data/conference/dao/ClientDao.java
(original)
+++ openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/data/conference/dao/ClientDao.java
Mon Feb  4 03:39:55 2013
@@ -18,6 +18,7 @@
  */
 package org.apache.openmeetings.data.conference.dao;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import javax.persistence.EntityManager;
@@ -41,6 +42,8 @@ public class ClientDao {
 	@PersistenceContext
 	private EntityManager em;
 	
+	private static List<Long> EMPTY_LIST = new ArrayList<Long>(0);
+	
 	public void cleanAllClients() {
 		em.createNamedQuery("deleteAll").executeUpdate();
 	}
@@ -152,9 +155,23 @@ public class ClientDao {
 		return q.getResultList();
 	}
 
+	/**
+	 * returns a list of servers or an empty list in case no roomIds are found
+	 * 
+	 * @param server
+	 * @return
+	 */
 	public List<Long> getRoomsIdsByServer(Server server) {
-		//TODO needed for cluster implementation	
-		return null;
+		Query q = em.createNamedQuery("getRoomsIdsByServer");
+		q.setParameter("server", server);
+		@SuppressWarnings("unchecked")
+		List<Long> resultList = q.getResultList();
+		//if the result list contains only a value null, it means it 
+		//was empty and no roomid's have been found
+		if (resultList.size() == 1 && resultList.get(0) == null) {
+			return EMPTY_LIST;
+		}
+		return resultList;
 	}
 
 }

Modified: openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/persistence/beans/rooms/Client.java
URL: http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/persistence/beans/rooms/Client.java?rev=1442019&r1=1442018&r2=1442019&view=diff
==============================================================================
--- openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/persistence/beans/rooms/Client.java
(original)
+++ openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/persistence/beans/rooms/Client.java
Mon Feb  4 03:39:55 2013
@@ -57,7 +57,8 @@ import org.apache.openmeetings.utils.mat
 	@NamedQuery(name = "getClients", query = "SELECT c FROM Client c"),
 	@NamedQuery(name = "getClientsWithServer", query = "SELECT c FROM Client c LEFT JOIN FETCH
c.server"),
 	@NamedQuery(name = "getClientsByUserId", query = "SELECT c FROM Client c WHERE c.server
= :server AND c.user_id = :user_id"),
-	@NamedQuery(name = "getClientsByRoomId", query = "SELECT c FROM Client c WHERE c.room_id
= :room_id")
+	@NamedQuery(name = "getClientsByRoomId", query = "SELECT c FROM Client c WHERE c.room_id
= :room_id"),
+	@NamedQuery(name = "getRoomsIdsByServer", query = "SELECT c.room_id FROM Client c WHERE
c.server = :server GROUP BY c.room_id")
 })
 @Table(name = "client")
 public class Client implements Serializable {

Modified: openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/remote/ConferenceService.java
URL: http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/remote/ConferenceService.java?rev=1442019&r1=1442018&r2=1442019&view=diff
==============================================================================
--- openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/remote/ConferenceService.java
(original)
+++ openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/remote/ConferenceService.java
Mon Feb  4 03:39:55 2013
@@ -789,7 +789,7 @@ public class ConferenceService {
 			
 			//check if the user is on master hosted, (serverId == null)
 			for (Long activeRoomId : sessionManager.getActiveRoomIdsByServer(null)) {
-				if (activeRoomId.equals(roomId)) {
+				if (activeRoomId != null && activeRoomId.equals(roomId)) {
 					return null;
 				}
 			}

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=1442019&r1=1442018&r2=1442019&view=diff
==============================================================================
--- openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/session/ISessionManager.java
(original)
+++ openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/session/ISessionManager.java
Mon Feb  4 03:39:55 2013
@@ -203,7 +203,7 @@ public interface ISessionManager {
 	 * means it is a local session on the master.
 	 * 
 	 * @param server
-	 * @return
+	 * @return a set, a roomId can be only one time in this list
 	 */
 	public abstract List<Long> getActiveRoomIdsByServer(Server 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=1442019&r1=1442018&r2=1442019&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
Mon Feb  4 03:39:55 2013
@@ -175,7 +175,16 @@ public class HashMapStore implements ICl
 	}
 
 	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!");
+		List<Long> roomIds = new ArrayList<Long>();
+		for (Client cl : clientsByStreamId.values()) {
+			Long roomId = cl.getRoom_id();
+			if (roomId != null && roomId > 0) {
+				if (!roomIds.contains(roomId)) {
+					
+				}
+			}
+		}
+		return roomIds;
 	}
 
 }

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=1442019&r1=1442018&r2=1442019&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
Mon Feb  4 03:39:55 2013
@@ -121,6 +121,14 @@ public interface IClientPersistenceStore
 	 */
 	public abstract String getDebugInformation(List<DEBUG_DETAILS> detailLevel);
 
+	/**
+	 * returns a list of roomIds (unique) that are currently active on the given server
+	 * In case the session is stored in the memory (no-cluster setup) it will always 
+	 * return simply all active roomIds
+	 * 
+	 * @param server
+	 * @return
+	 */
 	public abstract List<Long> getRoomsIdsByServer(Server server);
 
 	/**

Added: openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/test/session/TestDbSessionGetRoomIds.java
URL: http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/test/session/TestDbSessionGetRoomIds.java?rev=1442019&view=auto
==============================================================================
--- openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/test/session/TestDbSessionGetRoomIds.java
(added)
+++ openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/test/session/TestDbSessionGetRoomIds.java
Mon Feb  4 03:39:55 2013
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License") +  you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openmeetings.test.session;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.List;
+
+import org.apache.openmeetings.OpenmeetingsVariables;
+import org.apache.openmeetings.data.basic.dao.ServerDao;
+import org.apache.openmeetings.data.conference.dao.ClientDao;
+import org.apache.openmeetings.persistence.beans.basic.Server;
+import org.apache.openmeetings.persistence.beans.rooms.Client;
+import org.apache.openmeetings.test.AbstractOpenmeetingsSpringTest;
+import org.junit.Test;
+import org.red5.logging.Red5LoggerFactory;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class TestDbSessionGetRoomIds extends AbstractOpenmeetingsSpringTest {
+
+	protected static final Logger log = Red5LoggerFactory.getLogger(
+			TestDbSessionGetRoomIds.class, OpenmeetingsVariables.webAppRootKey);
+
+	@Autowired
+	private ServerDao serverDao;
+
+	@Autowired
+	private ClientDao clientDao;
+
+	@Test
+	public void testDbSessionFunctions() {
+
+		clientDao.cleanAllClients();
+		
+		List<Server> serverList = serverDao.getActiveServers();
+
+		Server server = null;
+		if (serverList.size() > 0) {
+			server = serverList.get(0);
+		} else {
+			server = new Server();
+			server.setName("Test Server");
+			server.setActive(true);
+			serverDao.update(server, 0);
+		}
+
+		Client cl1 = new Client();
+		cl1.setStreamid("1");
+		cl1.setServer(server);
+		cl1.setUser_id(1L);
+		cl1.setRoom_id(1L);
+		cl1.setPublicSID("public1");
+		clientDao.add(cl1);
+
+		Client cl2 = new Client();
+		cl2.setStreamid("2");
+		cl2.setServer(server);
+		cl2.setRoom_id(1L);
+		cl2.setUser_id(2L);
+		cl2.setPublicSID("public2");
+		clientDao.add(cl2);
+
+		Client cl3 = new Client();
+		cl3.setStreamid("3");
+		cl3.setServer(server);
+		cl3.setRoom_id(3L);
+		cl3.setUser_id(3L);
+		cl3.setPublicSID("public3");
+		clientDao.add(cl3);
+		
+		List<Long> roomids = clientDao.getRoomsIdsByServer(server);
+
+		assertEquals(2, roomids.size());
+		
+		//delete all
+		clientDao.cleanAllClients();
+
+		int countAll = clientDao.countClients();
+		assertEquals(0, countAll);
+	}
+
+}



Mime
View raw message