You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openmeetings.apache.org by so...@apache.org on 2017/07/30 15:55:50 UTC
[4/5] openmeetings git commit: [OPENMEETINGS-1677] Hazelcast is added
to handle cluster
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/ca559564/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/ServerUtil.java
----------------------------------------------------------------------
diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/ServerUtil.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/ServerUtil.java
deleted file mode 100644
index 4c909e6..0000000
--- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/ServerUtil.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * 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.core.session;
-
-import org.apache.openmeetings.db.dao.server.ServerDao;
-import org.apache.openmeetings.db.entity.server.Server;
-import org.apache.openmeetings.util.OpenmeetingsVariables;
-import org.red5.logging.Red5LoggerFactory;
-import org.slf4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-
-/**
- * Configures the current reference to the {@link Server} for this Tomcat/Web-Container.
- *
- * It is a Spring Bean and configured as Singleton. There is only one instance of this
- * bean in the entire Web-Application.
- *
- * @author sebawagner
- *
- */
-public class ServerUtil {
- protected static final Logger log = Red5LoggerFactory.getLogger(
- ServerUtil.class, OpenmeetingsVariables.webAppRootKey);
-
- @Autowired
- private ServerDao serverDao;
-
- /**
- * Injected via Spring configuration
- *
- * for cluster configuration, if only using one server (no cluster), serverId is null,
- * this is the current serverId of this Tomcat instance (null means no cluster is configured)
- */
- private String serverId = null;
-
- /**
- * a reference of the current server in that Tomcat instance
- */
- private Server currentServer;
-
- public String getServerId() {
- return serverId;
- }
-
- public void setServerId(String serverId) {
- this.serverId = serverId;
- }
-
- /**
- *
- * @return the current server
- */
- public Server getCurrentServer() {
- if (serverId == null) {
- return null;
- }
- if (currentServer != null && serverId.equals(currentServer.getId().toString())) {
- return currentServer;
- }
- currentServer = serverDao.get(Long.parseLong(serverId));
- if (currentServer == null) {
- log.warn("You have configured a serverId that does not exist in your list of servers, serverId: "+serverId);
- }
- return currentServer;
- }
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/ca559564/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/SessionManager.java
----------------------------------------------------------------------
diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/SessionManager.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/SessionManager.java
index 6a51b5b..990b73e 100644
--- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/SessionManager.java
+++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/SessionManager.java
@@ -19,29 +19,28 @@
package org.apache.openmeetings.core.session;
import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey;
+import static org.apache.openmeetings.util.OpenmeetingsVariables.wicketApplicationName;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
-import java.util.LinkedList;
+import java.util.HashSet;
import java.util.List;
-import java.util.Map.Entry;
+import java.util.Map;
+import java.util.Set;
import java.util.UUID;
+import java.util.stream.Collectors;
-import org.apache.openmeetings.core.session.store.IClientPersistenceStore;
+import org.apache.openmeetings.IApplication;
import org.apache.openmeetings.db.dao.server.ISessionManager;
-import org.apache.openmeetings.db.dto.basic.SearchResult;
-import org.apache.openmeetings.db.dto.server.ClientSessionInfo;
-import org.apache.openmeetings.db.entity.room.Client;
-import org.apache.openmeetings.db.entity.server.Server;
+import org.apache.openmeetings.db.entity.room.StreamClient;
+import org.apache.wicket.Application;
import org.apache.wicket.util.string.Strings;
import org.red5.logging.Red5LoggerFactory;
+import org.red5.server.Server;
import org.slf4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
/**
- * Handle {@link Client} objects.
+ * Handle {@link StreamClient} objects.
*
* Use a kind of decorator pattern to inject the {@link Server} into every call.
*
@@ -51,315 +50,99 @@ import org.springframework.beans.factory.annotation.Autowired;
public class SessionManager implements ISessionManager {
protected static final Logger log = Red5LoggerFactory.getLogger(SessionManager.class, webAppRootKey);
- @Autowired
- private ServerUtil serverUtil;
-
- /**
- * Injected via Spring, needs a getter/setter because it can be configured
- * Autowired will not suit here as there are multiple implementations of the
- * {@link IClientPersistenceStore}
- */
- private IClientPersistenceStore cache;
-
- public IClientPersistenceStore getCache() {
- return cache;
- }
-
- public void setCache(IClientPersistenceStore cache) {
- this.cache = cache;
- }
-
- @Override
- public void clearCache() {
- cache.clear();
+ private static Map<String, StreamClient> getClients() {
+ IApplication iapp = (IApplication)Application.get(wicketApplicationName);
+ return iapp.getStreamClients();
}
@Override
- public Client add(Client c, Server server) {
+ public StreamClient add(StreamClient c) {
if (c == null) {
return null;
}
- if (server == null) {
- server = serverUtil.getCurrentServer();
- }
+ IApplication iapp = (IApplication)Application.get(wicketApplicationName);
+ c.setServerId(iapp.getServerId());
c.setConnectedSince(new Date());
c.setRoomEnter(new Date());
if (Strings.isEmpty(c.getPublicSID())) {
c.setPublicSID(UUID.randomUUID().toString());
}
- c.setServer(server);
-
- if (cache.containsKey(null, c.getStreamid())) {
- log.error("Tried to add an existing Client " + c.getStreamid());
- return null;
- }
-
- cache.put(c.getStreamid(), c);
- return c;
+ return iapp.update(c);
}
@Override
- public Client addClientListItem(String streamId, String scopeName,
- int remotePort, String remoteAddress, String swfUrl, Server server) {
- if (server == null) {
- server = serverUtil.getCurrentServer();
- }
- try {
-
- // Store the Connection into a bean and add it to the HashMap
- Client rcm = new Client();
- rcm.setConnectedSince(new Date());
- rcm.setStreamid(streamId);
- rcm.setScope(scopeName);
- rcm.setPublicSID(UUID.randomUUID().toString());
- rcm.setServer(server);
- rcm.setUserport(remotePort);
- rcm.setUserip(remoteAddress);
- rcm.setSwfurl(swfUrl);
- rcm.setIsMod(false);
- rcm.setCanDraw(false);
-
- if (cache.containsKey(null, streamId)) {
- log.error("Tried to add an existing Client " + streamId);
- return null;
- }
-
- cache.put(rcm.getStreamid(), rcm);
-
- return rcm;
- } catch (Exception err) {
- log.error("[addClientListItem]", err);
- }
- return null;
+ public Collection<StreamClient> list() {
+ return getClients().values();
}
@Override
- public Collection<Client> getClients() {
- return cache.getClients();
+ public StreamClient get(String uid) {
+ return getClients().get(uid);
}
@Override
- public Collection<Client> getClientsWithServer() {
- return cache.getClientsWithServer();
+ public StreamClient update(StreamClient rcm) {
+ IApplication iapp = (IApplication)Application.get(wicketApplicationName);
+ return iapp.update(rcm);
}
@Override
- public Client getClientByStreamId(String streamId, Server server) {
- if (server == null) {
- server = serverUtil.getCurrentServer();
- }
- try {
- if (!cache.containsKey(server, streamId)) {
- log.debug("Tried to get a non existing Client " + streamId + " server " + server);
- return null;
- }
- return cache.get(server, streamId);
- } catch (Exception err) {
- log.error("[getClientByStreamId]", err);
- }
- return null;
+ public boolean remove(String uid) {
+ StreamClient c = getClients().remove(uid);
+ return c != null;
}
@Override
- public Client getClientByPublicSID(String publicSID, Server server) {
- if (server == null) {
- server = serverUtil.getCurrentServer();
- }
- try {
- List<Client> list = cache.getClientsByPublicSID(server, publicSID);
- return list == null || list.isEmpty() ? null : list.get(0);
- } catch (Exception err) {
- log.error("[getClientByPublicSID]", err);
- }
- return null;
+ public List<StreamClient> listByRoom(Long roomId) {
+ return list().stream()
+ .filter(c -> roomId.equals(c.getRoomId()) && !c.isScreenClient())
+ .collect(Collectors.toList());
}
@Override
- public ClientSessionInfo getClientByPublicSIDAnyServer(String publicSID) {
- try {
- for (Entry<Long,List<Client>> entry : cache.getClientsByPublicSID(publicSID).entrySet()) {
- for (Client rcl : entry.getValue()) {
- return new ClientSessionInfo(rcl, entry.getKey());
- }
- }
- } catch (Exception err) {
- log.error("[getClientByPublicSIDAnyServer]", err);
- }
- return null;
+ public Collection<StreamClient> listByRoomAll(Long roomId) {
+ return list().stream()
+ .filter(c -> roomId.equals(c.getRoomId()))
+ .collect(Collectors.toList());
}
@Override
- public Client getClientByUserId(Long userId) {
- try {
- for (Client rcl : cache.getClientsByUserId(null, userId)) {
- if (rcl.isScreenClient()) {
- continue;
- }
-
- return rcl;
- }
- } catch (Exception err) {
- log.error("[getClientByUserId]", err);
- }
- return null;
+ public List<StreamClient> listModeratorByRoom(Long roomId) {
+ return list().stream()
+ .filter(c -> roomId.equals(c.getRoomId()) && c.getIsMod())
+ .collect(Collectors.toList());
}
@Override
- public boolean updateAVClientByStreamId(String streamId, Client rcm, Server server) {
- if (server == null) {
- server = serverUtil.getCurrentServer();
- }
- try {
- // get the corresponding user session object and update the settings
- Client rclUsual = getClientByPublicSID(rcm.getPublicSID(), server);
- if (rclUsual != null) {
- rclUsual.setBroadCastID(rcm.getBroadCastID());
- rclUsual.setAvsettings(rcm.getAvsettings());
- rclUsual.setVHeight(rcm.getVHeight());
- rclUsual.setVWidth(rcm.getVWidth());
- rclUsual.setVX(rcm.getVX());
- rclUsual.setVY(rcm.getVY());
- Client rclSaved = cache.get(server, rclUsual.getStreamid());
- if (rclSaved != null) {
- cache.put(rclUsual.getStreamid(), rclUsual);
- } else {
- log.debug("Tried to update a non existing Client " + rclUsual.getStreamid());
- }
- }
-
- updateClientByStreamId(streamId, rcm, false, server);
- return true;
- } catch (Exception err) {
- log.error("[updateAVClientByStreamId]", err);
- }
- return false;
+ public long getRecordingCount(Long roomId) {
+ return list().stream()
+ .filter(c -> roomId.equals(c.getRoomId()) && c.isStartRecording())
+ .collect(Collectors.toList()).size();
}
@Override
- public boolean updateClientByStreamId(String streamId, Client rcm, boolean updateRoomCount, Server server) {
- if (server == null) {
- server = serverUtil.getCurrentServer();
- }
- try {
- Client rclSaved = cache.get(server, streamId);
-
- if (rclSaved != null) {
- cache.put(streamId, rcm);
- return true;
- } else {
- log.debug("Tried to update a non existing Client " + streamId);
- }
- } catch (Exception err) {
- log.error("[updateClientByStreamId]", err);
- }
- return false;
+ public long getPublishingCount(Long roomId) {
+ return list().stream()
+ .filter(c -> roomId.equals(c.getRoomId()) && c.isStreamPublishStarted())
+ .collect(Collectors.toList()).size();
}
@Override
- public boolean removeClient(String streamId, Server server) {
- if (server == null) {
- server = serverUtil.getCurrentServer();
- }
- try {
- if (cache.containsKey(server,streamId)) {
- cache.remove(server,streamId);
- return true;
- } else {
- log.debug("Tried to remove a non existing Client " + streamId);
- }
- } catch (Exception err) {
- log.error("[removeClient]", err);
- }
- return false;
+ public Set<Long> getActiveRoomIds() {
+ IApplication iapp = (IApplication)Application.get(wicketApplicationName);
+ return iapp.getActiveRoomIds();
}
@Override
- public List<Client> getClientListByRoom(Long roomId) {
- List<Client> roomClientList = new ArrayList<>();
- try {
- for (Client rcl : cache.getClientsByRoomId(roomId)) {
- if (rcl.isScreenClient()) {
- continue;
+ public Set<Long> getActiveRoomIds(String serverId) {
+ Set<Long> ids = new HashSet<>();
+ if (serverId != null) {
+ for (Map.Entry<String, StreamClient> e : getClients().entrySet()) {
+ if (serverId.equals(e.getValue().getServerId())) {
+ ids.add(e.getValue().getRoomId());
}
-
- // Only parse really those users out that are really a full session object
- // and no pseudo session object like the audio/video or screen
- // sharing connection
- roomClientList.add(rcl);
}
- } catch (Exception err) {
- log.error("[getClientListByRoom]", err);
- }
- return roomClientList;
- }
-
- @Override
- public Collection<Client> getClientListByRoomAll(Long roomId) {
- try {
- return cache.getClientsByRoomId(roomId);
- } catch (Exception err) {
- log.error("[getClientListByRoomAll]", err);
}
- return null;
- }
-
- @Override
- public List<Client> getCurrentModeratorByRoom(Long roomId) {
- List<Client> rclList = new LinkedList<>();
- List<Client> currentClients = this.getClientListByRoom(roomId);
- for (Client rcl : currentClients) {
- if (rcl.getIsMod()) {
- rclList.add(rcl);
- }
- }
- return rclList;
- }
-
- @Override
- public SearchResult<Client> getListByStartAndMax(int start, int max, String orderby, boolean asc) {
- SearchResult<Client> sResult = new SearchResult<>();
- sResult.setObjectName(Client.class.getName());
- sResult.setRecords(Long.valueOf(cache.size()));
- sResult.setResult(cache.getClientsWithServer());
- return sResult;
- }
-
- @Override
- public long getRecordingCount(long roomId) {
- List<Client> currentClients = this.getClientListByRoom(roomId);
- int numberOfRecordingUsers = 0;
- for (Client rcl : currentClients) {
- if (rcl.isStartRecording()) {
- numberOfRecordingUsers++;
- }
- }
- return numberOfRecordingUsers;
- }
-
- @Override
- public long getPublishingCount(long roomId) {
- List<Client> currentClients = this.getClientListByRoom(roomId);
- int numberOfPublishingUsers = 0;
- for (Client rcl : currentClients) {
- if (rcl.isStreamPublishStarted()) {
- numberOfPublishingUsers++;
- }
- }
- return numberOfPublishingUsers;
- }
-
- @Override
- public List<Long> getActiveRoomIdsByServer(Server server) {
- return cache.getRoomsIdsByServer(server == null ? serverUtil.getCurrentServer() : server);
- }
-
- @Override
- public String getSessionStatistics() {
- return cache.getDebugInformation(Arrays.asList(IClientPersistenceStore.DEBUG_DETAILS.SIZE));
- }
-
- @Override
- public void sessionStart() {
- // TODO Auto-generated method stub
+ return ids;
}
}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/ca559564/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/store/DatabaseStore.java
----------------------------------------------------------------------
diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/store/DatabaseStore.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/store/DatabaseStore.java
deleted file mode 100644
index 5e79da3..0000000
--- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/store/DatabaseStore.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * 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.core.session.store;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.openmeetings.db.dao.room.ClientDao;
-import org.apache.openmeetings.db.entity.room.Client;
-import org.apache.openmeetings.db.entity.server.Server;
-import org.springframework.beans.factory.annotation.Autowired;
-
-public class DatabaseStore implements IClientPersistenceStore {
-
- @Autowired
- private ClientDao clientDao;
-
- @Override
- public void clear() {
- clientDao.cleanAllClients();
- }
-
- @Override
- public void put(String streamId, Client rcl) {
- if (rcl.getId() != null) {
- clientDao.update(rcl);
- } else {
- clientDao.add(rcl);
- }
- }
-
- @Override
- public boolean containsKey(Server server, String streamId) {
- return clientDao.countClientsByServerAndStreamId(server, streamId) > 0;
- }
-
- @Override
- public Client get(Server server, String streamId) {
- return clientDao.getClientByServerAndStreamId(server, streamId);
- }
-
- @Override
- public List<Client> getClientsByPublicSID(Server server, String publicSID) {
- return clientDao.getClientsByPublicSIDAndServer(server, publicSID);
- }
-
- @Override
- public Map<Long, List<Client>> getClientsByPublicSID(String publicSID) {
- Map<Long, List<Client>> returnMap = new HashMap<>();
- List<Client> clientList = clientDao.getClientsByPublicSID(publicSID);
- for (Client cl : clientList) {
- if (cl.getServer() == null) {
- List<Client> clList = returnMap.get(null);
- if (clList == null) {
- clList = new ArrayList<>();
- }
- clList.add(cl);
- returnMap.put(null, clList);
- } else {
- List<Client> clList = returnMap.get(cl.getServer().getId());
- if (clList == null) {
- clList = new ArrayList<>();
- }
- clList.add(cl);
- returnMap.put(cl.getServer().getId(), clList);
- }
- }
- return returnMap;
- }
-
- @Override
- public Collection<Client> getClients() {
- return clientDao.getClients();
- }
-
- @Override
- public Collection<Client> getClientsWithServer() {
- return clientDao.getClientsWithServer();
- }
-
- @Override
- public Collection<Client> getClientsByServer(Server server) {
- return clientDao.getClientsByServer(server);
- }
-
- @Override
- public List<Client> getClientsByUserId(Server server, Long userId) {
- return clientDao.getClientsByUserId(server, userId);
- }
-
- @Override
- public List<Client> getClientsByRoomId(Long roomId) {
- return clientDao.getClientsByRoomId(roomId);
- }
-
- @Override
- public void remove(Server server, String streamId) {
- clientDao.removeClientByServerAndStreamId(server, streamId);
- }
-
- @Override
- public int size() {
- return clientDao.countClients();
- }
-
- @Override
- public int sizeByServer(Server server) {
- return clientDao.countClientsByServer(server);
- }
-
- @Override
- public Collection<Client> values() {
- return clientDao.getClients();
- }
-
- @Override
- public String getDebugInformation(List<DEBUG_DETAILS> detailLevel) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public List<Long> getRoomsIdsByServer(Server server) {
- return clientDao.getRoomsIdsByServer(server);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/ca559564/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/store/HashMapStore.java
----------------------------------------------------------------------
diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/store/HashMapStore.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/store/HashMapStore.java
deleted file mode 100644
index c896b34..0000000
--- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/store/HashMapStore.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * 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.core.session.store;
-
-import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.apache.openmeetings.db.entity.room.Client;
-import org.apache.openmeetings.db.entity.server.Server;
-import org.red5.logging.Red5LoggerFactory;
-import org.slf4j.Logger;
-
-/**
- * Stores the session in the memory.
- * Is NOT designed to be clustered across multiple servers.
- *
- * <ul>
- * <li>client by streamid</li>
- * <li>client by publicSID</li>
- * <li>client by userId</li>
- * <li>clients by roomId</li>
- * <li>roomIds by server</li>
- * </ul>
- *
- * @author sebawagner
- *
- */
-public class HashMapStore implements IClientPersistenceStore {
- protected static final Logger log = Red5LoggerFactory.getLogger(HashMapStore.class, webAppRootKey);
-
- private Map<String, Client> clientsByStreamId = new ConcurrentHashMap<>();
-
- @Override
- public void clear() {
- clientsByStreamId = new ConcurrentHashMap<>();
- }
-
- @Override
- public void put(String streamId, Client rcl) {
- clientsByStreamId.put(rcl.getStreamid(), rcl);
- }
-
- @Override
- public boolean containsKey(Server server, String streamId) {
- return clientsByStreamId.containsKey(streamId);
- }
-
- @Override
- public Client get(Server server, String streamId) {
- return clientsByStreamId.get(streamId);
- }
-
- @Override
- public List<Client> getClientsByPublicSID(Server server, String publicSID) {
- List<Client> clientList = new ArrayList<>();
- for (Map.Entry<String, Client> e: clientsByStreamId.entrySet()) {
- Client cl = e.getValue();
- if (cl.getPublicSID().equals(publicSID)) {
- clientList.add(cl);
- }
- }
- return clientList;
- }
-
- @Override
- public Map<Long,List<Client>> getClientsByPublicSID(String publicSID) {
- Map<Long,List<Client>> clientMapList = new HashMap<>();
- List<Client> clientList = new ArrayList<>();
- for (Map.Entry<String, Client> e: clientsByStreamId.entrySet()) {
- Client cl = e.getValue();
- if (cl.getPublicSID().equals(publicSID)) {
- clientList.add(cl);
- }
- }
- clientMapList.put(null, clientList);
- return clientMapList;
- }
-
- @Override
- public Collection<Client> getClients() {
- return clientsByStreamId.values();
- }
-
- @Override
- public Collection<Client> getClientsWithServer() {
- //there is no server object to be loaded, memory cache means
- //there is no cluster enabled
- return getClients();
- }
-
- @Override
- public Collection<Client> getClientsByServer(Server server) {
- return clientsByStreamId.values();
- }
-
- @Override
- public List<Client> getClientsByUserId(Server server, Long userId) {
- List<Client> clientList = new ArrayList<>();
- for (Map.Entry<String, Client> e: clientsByStreamId.entrySet()) {
- Client cl = e.getValue();
- if (cl.getUserId().equals(userId)) {
- clientList.add(cl);
- }
- }
- return clientList;
- }
-
- @Override
- public List<Client> getClientsByRoomId(Long roomId) {
- List<Client> clientList = new ArrayList<>();
- for (Map.Entry<String, Client> e: clientsByStreamId.entrySet()) {
- Client cl = e.getValue();
- if (cl.getRoomId() != null && cl.getRoomId().equals(roomId)) {
- clientList.add(cl);
- }
- }
- return clientList;
- }
-
- @Override
- public void remove(Server server, String streamId) {
- clientsByStreamId.remove(streamId);
- }
-
- @Override
- public int size() {
- return clientsByStreamId.size();
- }
-
- @Override
- public int sizeByServer(Server server) {
- return clientsByStreamId.size();
- }
-
- @Override
- public Collection<Client> values() {
- return clientsByStreamId.values();
- }
-
- public int getTotalNumberOfSessions() {
- return clientsByStreamId.size();
- }
-
- /**
- * Print some session statistics to the debug out
- *
- * @param detailLevel
- */
- public void printDebugInformation(List<DEBUG_DETAILS> detailLevel) {
- log.debug("Session Statistics Start ################## ");
- log.debug(getDebugInformation(detailLevel));
- log.debug("Session Statistics End ################## ");
- }
-
- @Override
- public String getDebugInformation(List<DEBUG_DETAILS> detailLevel) {
- StringBuilder statistics = new StringBuilder();
-
- if (detailLevel.contains(DEBUG_DETAILS.SIZE)) {
- addNewLine(statistics, "Number of sessions Total " + getTotalNumberOfSessions());
- }
-
- return statistics.toString();
- }
-
- private static void addNewLine(StringBuilder strBuilder, String message) {
- strBuilder.append(message + "\n\r");
- }
-
- @Override
- public List<Long> getRoomsIdsByServer(Server server) {
- Set<Long> rooms = new HashSet<>();
- for (Map.Entry<String, Client> e: clientsByStreamId.entrySet()) {
- Client cl = e.getValue();
- Long roomId = cl.getRoomId();
- if (roomId != null && roomId.longValue() > 0 && !rooms.contains(roomId)) {
- rooms.add(roomId);
- }
- }
- return new ArrayList<>(rooms);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/ca559564/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/store/IClientPersistenceStore.java
----------------------------------------------------------------------
diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/store/IClientPersistenceStore.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/store/IClientPersistenceStore.java
deleted file mode 100644
index a511680..0000000
--- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/store/IClientPersistenceStore.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * 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.core.session.store;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.openmeetings.db.entity.room.Client;
-import org.apache.openmeetings.db.entity.server.Server;
-
-public interface IClientPersistenceStore {
-
- public enum DEBUG_DETAILS {
- SIZE
- }
-
- /**
- * called upon start of the session cache
- */
- void clear();
-
- /**
- *
- * @param streamId
- * @param rcl
- */
- void put(String streamId, Client rcl);
-
- /**
- *
- * @param server
- * @param streamId
- * @return
- */
- boolean containsKey(Server server, String streamId);
-
- /**
- * by server and publicSID
- *
- * @param server
- * @param streamId
- * @return will return null if the client does not exist in the list
- */
- Client get(Server server, String streamId);
-
- /**
- *
- * @param server
- * @param publicSID
- * @return will return an empty list if nothing available
- */
- List<Client> getClientsByPublicSID(Server server, String publicSID);
-
- /**
- * Searches for the publicSID across all servers
- *
- * @param publicSID
- * @return will return a map with the serverId as key and the RoomClients as list in the value
- */
- Map<Long, List<Client>> getClientsByPublicSID(String publicSID);
-
- Collection<Client> getClients();
-
- /**
- * get all clients by a specific {@link Server}
- *
- * @param server
- * @return will return an empty map if nothing available
- */
- Collection<Client> getClientsByServer(Server server);
-
- /**
- *
- * @param server
- * @param userId
- * @return will return an empty list if nothing available
- */
- Collection<Client> getClientsByUserId(Server server, Long userId);
-
- /**
- *
- * We ignore the server here, cause ONE room can only be on ONE server and often we don't know where.
- *
- * @param roomId
- * @return will return an empty map if nothing available
- */
- List<Client> getClientsByRoomId(Long roomId);
-
- void remove(Server server, String streamId);
-
- int size();
-
- int sizeByServer(Server server);
-
- Collection<Client> values();
-
- /**
- * Get some session statistics
- *
- * @param detailLevel
- * @return
- */
- 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
- */
- List<Long> getRoomsIdsByServer(Server server);
-
- /**
- * if database cache + cluster is enabled, the server object will be loaded
- * into the client
- *
- * @return
- */
- Collection<Client> getClientsWithServer();
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/ca559564/openmeetings-core/src/main/java/org/apache/openmeetings/core/util/IClientUtil.java
----------------------------------------------------------------------
diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/util/IClientUtil.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/util/IClientUtil.java
index 4df1f49..a025eb8 100644
--- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/util/IClientUtil.java
+++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/util/IClientUtil.java
@@ -18,6 +18,7 @@
*/
package org.apache.openmeetings.core.util;
+import org.apache.openmeetings.db.entity.room.StreamClient;
import org.red5.server.api.IClient;
public class IClientUtil {
@@ -26,8 +27,8 @@ public class IClientUtil {
, sharing
}
- public static void init(IClient client, Long id, boolean sharing) {
- client.setAttribute(ConAttrs.omId.name(), id);
+ public static void init(IClient client, String uid, boolean sharing) {
+ client.setAttribute(ConAttrs.omId.name(), uid);
client.setAttribute(ConAttrs.sharing.name(), sharing);
}
@@ -37,9 +38,9 @@ public class IClientUtil {
* @param conn
* @return - Id of {@link StreamClient} for this IConnection, or <code>null</code>
*/
- public static Long getId(IClient client) {
+ public static String getId(IClient client) {
Object o = client.getAttribute(ConAttrs.omId.name());
- return o instanceof Long ? (Long)o : null;
+ return o instanceof String ? (String)o : null;
}
public static boolean isSharing(IClient client) {
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/ca559564/openmeetings-db/src/main/java/org/apache/openmeetings/IApplication.java
----------------------------------------------------------------------
diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/IApplication.java b/openmeetings-db/src/main/java/org/apache/openmeetings/IApplication.java
index a3d65a4..b8f5bc0 100644
--- a/openmeetings-db/src/main/java/org/apache/openmeetings/IApplication.java
+++ b/openmeetings-db/src/main/java/org/apache/openmeetings/IApplication.java
@@ -20,12 +20,15 @@ package org.apache.openmeetings;
import java.util.List;
import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
import java.util.function.Supplier;
import javax.servlet.ServletContext;
-import org.apache.openmeetings.db.entity.room.Client;
+import org.apache.openmeetings.db.entity.basic.Client;
import org.apache.openmeetings.db.entity.room.Invitation;
+import org.apache.openmeetings.db.entity.room.StreamClient;
import org.apache.wicket.request.IExceptionMapper;
import org.apache.wicket.request.IRequestMapper;
import org.apache.wicket.request.mapper.parameter.PageParameters;
@@ -40,10 +43,9 @@ public interface IApplication {
String getOmString(long id, long languageId);
String getOmString(String key, long languageId);
String getOmString(String key, final Locale loc, String... params);
- Client updateClient(Client rcl, boolean forceSize);
- org.apache.openmeetings.db.entity.basic.Client getOmOnlineClient(String uid);
- List<org.apache.openmeetings.db.entity.basic.Client> getOmRoomClients(Long roomId);
- List<org.apache.openmeetings.db.entity.basic.Client> getOmClients(Long userId);
+ Client getOmOnlineClient(String uid);
+ List<Client> getOmRoomClients(Long roomId);
+ List<Client> getOmClients(Long userId);
String getOmContactsLink();
String getOmInvitationLink(Invitation i);
String urlForActivatePage(PageParameters pp);
@@ -51,4 +53,11 @@ public interface IApplication {
void exit(String uid);
void setXFrameOptions(String xFrameOptions);
void setContentSecurityPolicy(String contentSecurityPolicy);
+
+ // stream client
+ StreamClient updateClient(StreamClient rcl, boolean forceSize);
+ String getServerId();
+ Map<String, StreamClient> getStreamClients();
+ StreamClient update(StreamClient c);
+ Set<Long> getActiveRoomIds();
}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/ca559564/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/room/ClientDao.java
----------------------------------------------------------------------
diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/room/ClientDao.java b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/room/ClientDao.java
deleted file mode 100644
index 66996af..0000000
--- a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/room/ClientDao.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * 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.db.dao.room;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-import javax.persistence.Query;
-import javax.persistence.TypedQuery;
-
-import org.apache.openmeetings.db.entity.room.Client;
-import org.apache.openmeetings.db.entity.server.Server;
-import org.springframework.transaction.annotation.Transactional;
-
-/**
- * Persistence of client objects to database is only available if so configured!
- *
- * @author sebawagner
- *
- */
-@Transactional
-public class ClientDao {
-
- @PersistenceContext
- private EntityManager em;
-
- private static List<Long> EMPTY_LIST = new ArrayList<>(0);
-
- public void cleanAllClients() {
- em.createNamedQuery("deleteAll").executeUpdate();
- }
-
- public void cleanClientsByServer(Server server) {
- em.createNamedQuery("deleteClientsByServer").
- setParameter("server", server).
- executeUpdate();
- }
-
- public Client add(Client entity) {
- em.persist(entity);
- return entity;
- }
-
- public Client update(Client entity) {
- em.merge(entity);
- return entity;
- }
-
- public void delete(Client entity) {
- Query q = em.createNamedQuery("deletedById");
- q.setParameter("id", entity.getId());
- q.executeUpdate();
- }
-
- public void removeClientByServerAndStreamId(Server server, String streamId) {
- Query q = em.createNamedQuery("deletedByServerAndStreamId");
- q.setParameter("server", server);
- q.setParameter("streamid", streamId);
- q.executeUpdate();
- }
-
- public int countClients() {
- return em.createNamedQuery("countClients", Long.class).getSingleResult().intValue();
- }
-
- public int countClientsByServer(Server server) {
- TypedQuery<Long> q = em.createNamedQuery("countClientsByServer", Long.class);
- q.setParameter("server", server);
- return q.getSingleResult().intValue();
- }
-
- public long countClientsByServerAndStreamId(Server server, String streamId) {
- TypedQuery<Long> q = em.createNamedQuery("countClientsByServerAndStreamId", Long.class);
- q.setParameter("streamid", streamId);
- q.setParameter("server", server);
- return q.getSingleResult();
- }
-
- /**
- * Query.getSingleResult would throw an error if result is null,
- * see: http://stackoverflow.com/questions/2002993/jpa-getsingleresult-or-null
- *
- * @param server
- * @param streamId
- * @return
- */
- public Client getClientByServerAndStreamId(Server server, String streamId) {
- TypedQuery<Client> q = em.createNamedQuery("getClientByServerAndStreamId", Client.class);
- q.setParameter("streamid", streamId);
- q.setParameter("server", server);
- List<Client> ll = q.getResultList();
- if (ll.size() == 1) {
- return ll.get(0);
- } else if (ll.size() == 0) {
- return null;
- }
- throw new RuntimeException("more then one client was found streamId "+ streamId + " server "+server);
- }
-
- public List<Client> getClientsByPublicSIDAndServer(Server server, String publicSID) {
- TypedQuery<Client> q = em.createNamedQuery("getClientsByPublicSIDAndServer", Client.class);
- q.setParameter("server", server);
- q.setParameter("publicSID", publicSID);
- return q.getResultList();
- }
-
- public List<Client> getClientsByPublicSID(String publicSID) {
- TypedQuery<Client> q = em.createNamedQuery("getClientsByPublicSID", Client.class);
- q.setParameter("publicSID", publicSID);
- return q.getResultList();
- }
-
- public List<Client> getClientsByServer(Server server) {
- TypedQuery<Client> q = em.createNamedQuery("getClientsByServer", Client.class);
- q.setParameter("server", server);
- return q.getResultList();
- }
-
- public List<Client> getClients() {
- return em.createNamedQuery("getClients", Client.class).getResultList();
- }
-
- public List<Client> getClientsWithServer() {
- return em.createNamedQuery("getClientsWithServer", Client.class).getResultList();
- }
-
- public List<Client> getClientsByUserId(Server server, Long userId) {
- TypedQuery<Client> q = em.createNamedQuery("getClientsByUserId", Client.class);
- q.setParameter("server", server);
- q.setParameter("userId", userId);
- return q.getResultList();
- }
-
- public List<Client> getClientsByRoomId(Long roomId) {
- TypedQuery<Client> q = em.createNamedQuery("getClientsByRoomId", Client.class);
- q.setParameter("roomId", roomId);
- 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) {
- 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;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/ca559564/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/room/RoomDao.java
----------------------------------------------------------------------
diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/room/RoomDao.java b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/room/RoomDao.java
index b82925d..0ea7a43 100644
--- a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/room/RoomDao.java
+++ b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/room/RoomDao.java
@@ -23,6 +23,7 @@ import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey;
import java.util.ArrayList;
import java.util.Calendar;
+import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
@@ -202,7 +203,7 @@ public class RoomDao implements IGroupAdminDataProviderDao<Room> {
.getResultList();
}
- public long getRoomsCapacityByIds(List<Long> ids) {
+ public long getRoomsCapacityByIds(Collection<Long> ids) {
return ids == null || ids.isEmpty() ? 0L
: em.createNamedQuery("getRoomsCapacityByIds", Long.class).setParameter("ids", ids).getSingleResult();
}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/ca559564/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/server/ISessionManager.java
----------------------------------------------------------------------
diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/server/ISessionManager.java b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/server/ISessionManager.java
index 920647a..7b9b361 100644
--- a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/server/ISessionManager.java
+++ b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/server/ISessionManager.java
@@ -20,126 +20,50 @@ package org.apache.openmeetings.db.dao.server;
import java.util.Collection;
import java.util.List;
+import java.util.Set;
-import org.apache.openmeetings.db.dto.basic.SearchResult;
-import org.apache.openmeetings.db.dto.server.ClientSessionInfo;
-import org.apache.openmeetings.db.entity.room.Client;
-import org.apache.openmeetings.db.entity.server.Server;
+import org.apache.openmeetings.db.entity.room.StreamClient;
/**
- * Methods to add/get/remove {@link Client}s to the session
+ * Methods to add/get/remove {@link StreamClient}s to the session
*
*
* @author sebawagner
*
*/
public interface ISessionManager {
- void clearCache();
-
- /**
- * Notified on server start, when the session manager should be started and
- * eventually caches cleared/setup
- */
- void sessionStart();
-
- Client add(Client c, Server server);
- /**
- * add a new client item
- *
- * @param streamId
- * @param scopeName
- * @param remotePort
- * @param remoteAddress
- * @param swfUrl
- * @param server
- * @return
- */
- Client addClientListItem(String streamId, String scopeName, int remotePort, String remoteAddress, String swfUrl, Server server);
-
- Collection<Client> getClients();
+ StreamClient add(StreamClient c);
/**
* loads the server into the client (only if database cache is used)
*
* @return
*/
- Collection<Client> getClientsWithServer();
-
- /**
- * Get a client by its streamId
- *
- * @param streamId
- * @param server
- * @return
- */
- Client getClientByStreamId(String streamId, Server server);
-
- /**
- * get a client by its publicSID and the server,
- *
- * @param publicSID
- * @param server
- * @return
- */
- Client getClientByPublicSID(String publicSID, Server server);
+ Collection<StreamClient> list();
/**
- * same as {@link #getClientByPublicSID(String, boolean, Server)} but it ignores
- * if the server part, so it will deliver any client just by its publicSID.<br/>
- * <br/>
- * <b>Note:</b>
- * This method requires more time to find the user, so under normal circumstances
- * you should use {@link #getClientByPublicSID(String, boolean, Server)}!
+ * Get a client by its UID
*
- * @param publicSID
+ * @param uid
* @return
*/
- ClientSessionInfo getClientByPublicSIDAnyServer(String publicSID);
+ StreamClient get(String uid);
/**
+ * Updates {@link StreamClient} in the cache
*
- * @param userId
- * @return
- *
- * @deprecated There could be multiple users logged in with the same userid,
- * then this call would return a list not a single user
- */
- @Deprecated
- Client getClientByUserId(Long userId);
-
- /**
- * Update the session object of the audio/video-connection and additionally
- * swap the values to the session object of the user that holds the full
- * session object
- *
- * @param streamId
- * @param rcm
- * @return
- */
- boolean updateAVClientByStreamId(String streamId, Client rcm, Server server);
-
- /**
- * Update the session object
- *
- * updateRoomCount is only <i>one</i> time true, in
- * ScopeApplicationAdapter#setRoomValues(Long, Boolean, Boolean, String)
- * .
- *
- * @param streamId
* @param rcm
- * @param updateRoomCount
- * true means the count for the room has to be updated
- * @return
+ * @return updated client
*/
- boolean updateClientByStreamId(String streamId, Client rcm, boolean updateRoomCount, Server server);
+ StreamClient update(StreamClient rcm);
/**
* Remove a client from the session store
*
- * @param streamId
- * @return
+ * @param uid
+ * @return true if client was removed
*/
- boolean removeClient(String streamId, Server server);
+ boolean remove(String uid);
/**
* Get all ClientList Objects of that room and domain This Function is
@@ -149,28 +73,17 @@ public interface ISessionManager {
* @param roomId
* @return
*/
- List<Client> getClientListByRoom(Long roomId);
+ List<StreamClient> listByRoom(Long roomId);
- Collection<Client> getClientListByRoomAll(Long roomId);
+ Collection<StreamClient> listByRoomAll(Long roomId);
/**
* get the current Moderator in this room
*
- * @param roomname
- * @return
- */
- List<Client> getCurrentModeratorByRoom(Long roomId);
-
- /**
- * Get list of current client sessions
- *
- * @param start
- * @param max
- * @param orderby
- * @param asc
+ * @param roomId
* @return
*/
- SearchResult<Client> getListByStartAndMax(int start, int max, String orderby, boolean asc);
+ List<StreamClient> listModeratorByRoom(Long roomId);
/**
* returns number of current users recording
@@ -178,7 +91,7 @@ public interface ISessionManager {
* @param roomId
* @return
*/
- long getRecordingCount(long roomId);
+ long getRecordingCount(Long roomId);
/**
* returns a number of current users publishing screensharing
@@ -186,21 +99,20 @@ public interface ISessionManager {
* @param roomId
* @return
*/
- long getPublishingCount(long roomId);
+ long getPublishingCount(Long roomId);
/**
- * Get a list of all servers of all rooms on that server, serverId = null
- * means it is a local session on the master.
+ * Get a list of all rooms with users in the system.
*
- * @param server
* @return a set, a roomId can be only one time in this list
*/
- List<Long> getActiveRoomIdsByServer(Server server);
+ Set<Long> getActiveRoomIds();
/**
- * Get some statistics about the current sessions
+ * Get a list of rooms with users on particular cluster node.
*
- * @return
+ * @param server
+ * @return a set, a roomId can be only one time in this list
*/
- String getSessionStatistics();
+ Set<Long> getActiveRoomIds(String serverId);
}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/ca559564/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/server/ServerDao.java
----------------------------------------------------------------------
diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/server/ServerDao.java b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/server/ServerDao.java
deleted file mode 100644
index dad22cf..0000000
--- a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/server/ServerDao.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * 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.db.dao.server;
-
-import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey;
-
-import java.util.Date;
-import java.util.List;
-
-import javax.persistence.EntityManager;
-import javax.persistence.NoResultException;
-import javax.persistence.PersistenceContext;
-import javax.persistence.TypedQuery;
-
-import org.apache.openmeetings.db.dao.IDataProviderDao;
-import org.apache.openmeetings.db.dao.user.UserDao;
-import org.apache.openmeetings.db.entity.server.Server;
-import org.apache.openmeetings.util.DaoHelper;
-import org.red5.logging.Red5LoggerFactory;
-import org.slf4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
-
-/**
- *
- * CRUD for {@link Server}
- *
- * @author solomax, sebawagner
- *
- */
-@Transactional
-public class ServerDao implements IDataProviderDao<Server> {
- private static final Logger log = Red5LoggerFactory.getLogger(ServerDao.class, webAppRootKey);
- public final static String[] searchFields = { "name", "address", "comment" };
-
- @PersistenceContext
- private EntityManager em;
-
- @Autowired
- private UserDao userDao;
-
- /**
- * Get a list of all available servers
- *
- * @return
- */
- public List<Server> getServerList() {
- log.debug("getServerList enter");
- TypedQuery<Server> q = em.createNamedQuery("getAllServers",
- Server.class);
- return q.getResultList();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.openmeetings.data.OmDAO#get(int, int)
- */
- @Override
- public List<Server> get(int start, int max) {
- TypedQuery<Server> q = em.createNamedQuery("getAllServers", Server.class);
- q.setFirstResult(start);
- q.setMaxResults(max);
- return q.getResultList();
- }
-
- @Override
- public List<Server> get(String search, int start, int count, String order) {
- TypedQuery<Server> q = em.createQuery(DaoHelper.getSearchQuery(
- "Server", "s", search, true, false, order, searchFields),
- Server.class);
- q.setFirstResult(start);
- q.setMaxResults(count);
- return q.getResultList();
- }
-
- /**
- * get the list of all servers in the cluster that are ready to receive a
- * ping (active = true)
- *
- * @return
- */
- public List<Server> getActiveServers() {
- return em.createNamedQuery("getActiveServers", Server.class)
- .getResultList();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.openmeetings.data.OmDAO#count()
- */
- @Override
- public long count() {
- log.debug("getServerCount enter");
- TypedQuery<Long> q = em.createNamedQuery("getServerCount", Long.class);
-
- return q.getSingleResult();
- }
-
- @Override
- public long count(String search) {
- TypedQuery<Long> q = em.createQuery(DaoHelper.getSearchQuery("Server",
- "s", search, true, true, null, searchFields), Long.class);
- return q.getSingleResult();
- }
-
- @Override
- public Server get(long id) {
- return get(Long.valueOf(id));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.openmeetings.data.OmDAO#get(long)
- */
- @Override
- public Server get(Long id) {
- Server result = null;
- log.debug("getServer enter, id = " + id);
- TypedQuery<Server> q = em.createNamedQuery("getServerById",
- Server.class);
- q.setParameter("id", id);
- try {
- result = q.getSingleResult();
- } catch (NoResultException e) {
- // noop
- }
- return result;
- }
-
- /**
- * Get server by its address
- *
- * @param address
- * @return
- */
- public Server getServerByAddress(String address) {
- log.debug("getServer enter, address = " + address);
- TypedQuery<Server> q = em.createNamedQuery("getServerByAddress",
- Server.class);
- q.setParameter("address", address);
- List<Server> list = q.getResultList();
- return list.size() > 0 ? list.get(0) : null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.openmeetings.data.OmDAO#update(org.apache.openmeetings.persistence
- * .beans.OmEntity, long)
- */
- @Override
- public Server update(Server entity, Long userId) {
- entity.setDeleted(false);
- if (entity.getId() == null) {
- entity.setInserted(new Date());
- if (userId != null) {
- entity.setInsertedby(userDao.get(userId));
- }
- em.persist(entity);
- } else {
- entity.setUpdated(new Date());
- if (userId != null) {
- entity.setUpdatedby(userDao.get(userId));
- }
- em.merge(entity);
- }
- return entity;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.openmeetings.data.OmDAO#delete(org.apache.openmeetings.persistence
- * .beans.OmEntity, long)
- */
- @Override
- public void delete(Server entity, Long userId) {
- if (entity.getId() != null) {
- entity.setUpdated(new Date());
- if (userId != null) {
- entity.setUpdatedby(userDao.get(userId));
- }
- entity.setDeleted(true);
- em.merge(entity);
- }
- }
-
- /**
- * get {@link Server} by name
- *
- * @param name
- * @return
- */
- public List<Server> getServersByName(String name) {
- TypedQuery<Server> q = em.createNamedQuery("getServerByName",
- Server.class);
- q.setParameter("name", name);
- return q.getResultList();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/ca559564/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/server/SessiondataDao.java
----------------------------------------------------------------------
diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/server/SessiondataDao.java b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/server/SessiondataDao.java
index 22facee..96f3cad 100644
--- a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/server/SessiondataDao.java
+++ b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/server/SessiondataDao.java
@@ -28,7 +28,7 @@ import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
-import org.apache.openmeetings.db.entity.room.Client;
+import org.apache.openmeetings.db.entity.room.StreamClient;
import org.apache.openmeetings.db.entity.server.Sessiondata;
import org.red5.logging.Red5LoggerFactory;
import org.slf4j.Logger;
@@ -205,7 +205,7 @@ public class SessiondataDao {
*/
public void clearSessionByRoomId(Long roomId) {
try {
- for (Client rcl : sessionManager.getClientListByRoom(roomId)) {
+ for (StreamClient rcl : sessionManager.listByRoom(roomId)) {
String aux = rcl.getSwfurl();
//FIXME TODO this need to be refactored !
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/ca559564/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/IUserManager.java
----------------------------------------------------------------------
diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/IUserManager.java b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/IUserManager.java
index 9a6e641..3ffda70 100644
--- a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/IUserManager.java
+++ b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/IUserManager.java
@@ -52,10 +52,8 @@ public interface IUserManager {
Long getLanguage(Locale loc);
User loginOAuth(Map<String, String> params, long serverId) throws IOException, NoSuchAlgorithmException;
- /** TODO FIXME seems to be unused **/
- boolean kickUserByStreamId(String SID, Long roomId);
-
- boolean kickUserByPublicSID(String SID, String publicSID);
+ boolean kickClient(String sid, String uid);
+ boolean kickUsersByRoomId(String sid, Long room_id);
List<Userdata> getUserdataDashBoard(Long userId);
}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/ca559564/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/IUserService.java
----------------------------------------------------------------------
diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/IUserService.java b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/IUserService.java
deleted file mode 100644
index 677a56d..0000000
--- a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/IUserService.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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.db.dao.user;
-
-//FIXME HACK to bypass cross project compilation
-public interface IUserService {
- boolean kickUserByStreamId(String sid, String streamid, long serverId);
-
- boolean kickUserBySessionId(String sid, long userId, String sessionId);
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/ca559564/openmeetings-db/src/main/java/org/apache/openmeetings/db/dto/room/RoomStatus.java
----------------------------------------------------------------------
diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dto/room/RoomStatus.java b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dto/room/RoomStatus.java
index 98831a2..1c5bc51 100644
--- a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dto/room/RoomStatus.java
+++ b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dto/room/RoomStatus.java
@@ -20,18 +20,18 @@ package org.apache.openmeetings.db.dto.room;
import java.util.List;
-import org.apache.openmeetings.db.entity.room.Client;
+import org.apache.openmeetings.db.entity.room.StreamClient;
public class RoomStatus {
- List<Client> clientList;
+ List<StreamClient> clientList;
BrowserStatus browserStatus;
public RoomStatus() {}
- public List<Client> getClientList() {
+ public List<StreamClient> getClientList() {
return clientList;
}
- public void setClientList(List<Client> clientList) {
+ public void setClientList(List<StreamClient> clientList) {
this.clientList = clientList;
}
public BrowserStatus getBrowserStatus() {
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/ca559564/openmeetings-db/src/main/java/org/apache/openmeetings/db/dto/server/ClientSessionInfo.java
----------------------------------------------------------------------
diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dto/server/ClientSessionInfo.java b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dto/server/ClientSessionInfo.java
deleted file mode 100644
index cd437e7..0000000
--- a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dto/server/ClientSessionInfo.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.db.dto.server;
-
-import org.apache.openmeetings.db.entity.room.Client;
-
-
-public class ClientSessionInfo {
-
- private Client rcl;
- public Long serverId;
-
- public ClientSessionInfo() {}
-
- public ClientSessionInfo(Client rcl, Long serverId) {
- super();
- this.rcl = rcl;
- this.serverId = serverId;
- }
-
- public Client getRcl() {
- return rcl;
- }
- public void setRcl(Client rcl) {
- this.rcl = rcl;
- }
- public Long getServerId() {
- return serverId;
- }
- public void setServerId(Long serverId) {
- this.serverId = serverId;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/ca559564/openmeetings-db/src/main/java/org/apache/openmeetings/db/dto/server/ServerDTO.java
----------------------------------------------------------------------
diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dto/server/ServerDTO.java b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dto/server/ServerDTO.java
deleted file mode 100644
index cc8e933..0000000
--- a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dto/server/ServerDTO.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * 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.db.dto.server;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.apache.openmeetings.db.entity.server.Server;
-
-/**
- *
- * Bean send to the client about the server he is going to use for the conference
- * session
- *
- * @author sebawagner
- *
- */
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.FIELD)
-public class ServerDTO implements Serializable {
- private static final long serialVersionUID = 1L;
- private Long id;
- private String name;
- private String address;
- private int port;
- private String user;
- private String password;
- private String webapp;
- private String protocol;
- private boolean active;
- private String comment;
-
- public ServerDTO() {}
-
- public ServerDTO(Server s) {
- if (s == null) {
- return;
- }
- id = s.getId();
- name = s.getName();
- address = s.getAddress();
- port = s.getPort();
- user = s.getUser();
- password = s.getPass();
- webapp = s.getWebapp();
- protocol = s.getProtocol();
- active = s.isActive();
- comment = s.getComment();
- }
-
- public Server get() {
- Server s = new Server();
- s.setId(id);
- s.setName(name);
- s.setAddress(address);
- s.setPort(port);
- s.setUser(user);
- s.setPass(password);
- s.setWebapp(webapp);
- s.setProtocol(protocol);
- s.setActive(active);
- s.setComment(comment);
- return s;
- }
-
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public String getAddress() {
- return address;
- }
-
- public void setAddress(String address) {
- this.address = address;
- }
-
- public int getPort() {
- return port;
- }
-
- public void setPort(int port) {
- this.port = port;
- }
-
- public String getProtocol() {
- return protocol;
- }
-
- public void setProtocol(String protocol) {
- this.protocol = protocol;
- }
-
- public String getWebapp() {
- return webapp;
- }
-
- public void setWebapp(String webapp) {
- this.webapp = webapp;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getUser() {
- return user;
- }
-
- public void setUser(String user) {
- this.user = user;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
-
- public boolean isActive() {
- return active;
- }
-
- public void setActive(boolean active) {
- this.active = active;
- }
-
- public String getComment() {
- return comment;
- }
-
- public void setComment(String comment) {
- this.comment = comment;
- }
-
- @Override
- public String toString() {
- return "id "+id+" address "+address+" port "+port+" protocol "+protocol;
- }
-
- public static List<ServerDTO> list(List<Server> l) {
- List<ServerDTO> list = new ArrayList<>();
- if (l != null) {
- for (Server s : l) {
- list.add(new ServerDTO(s));
- }
- }
- return list;
- }
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/ca559564/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/basic/Client.java
----------------------------------------------------------------------
diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/basic/Client.java b/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/basic/Client.java
index efd7c15..3f2398f 100644
--- a/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/basic/Client.java
+++ b/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/basic/Client.java
@@ -26,11 +26,12 @@ import java.util.UUID;
import org.apache.openmeetings.db.dao.user.UserDao;
import org.apache.openmeetings.db.entity.room.Room.Right;
+import org.apache.openmeetings.db.entity.room.StreamClient;
import org.apache.openmeetings.db.entity.user.User;
import org.apache.wicket.protocol.ws.api.registry.IKey;
/**
- * Temporary class, later will be merged with {@link org.apache.openmeetings.db.entity.room.Client}
+ * Temporary class, later will be merged with {@link org.apache.openmeetings.db.entity.room.StreamClient}
* @author solomax
*
*/
@@ -65,6 +66,7 @@ public class Client implements IClient {
private int mic = -1;
private int width = 0;
private int height = 0;
+ private String serverId = null;
public Client(String sessionId, int pageId, Long userId, UserDao dao) {
this.sessionId = sessionId;
@@ -75,7 +77,7 @@ public class Client implements IClient {
sid = UUID.randomUUID().toString();
}
- public Client(org.apache.openmeetings.db.entity.room.Client rcl, User user) {
+ public Client(StreamClient rcl, User user) {
this.sessionId = UUID.randomUUID().toString();
this.pageId = 0;
this.user = user;
@@ -107,14 +109,16 @@ public class Client implements IClient {
return user;
}
- public void updateUser(UserDao dao) {
+ public Client updateUser(UserDao dao) {
user = dao.get(user.getId());
+ return this;
}
public Long getUserId() {
return user.getId();
}
+ @Override
public String getUid() {
return uid;
}
@@ -153,8 +157,8 @@ public class Client implements IClient {
}
}
- public Set<Activity> getActivities() {
- return activities;
+ public void clearActivities() {
+ activities.clear();
}
public boolean hasActivity(Activity a) {
@@ -169,7 +173,7 @@ public class Client implements IClient {
}
}
- public void set(Activity a) {
+ public Client set(Activity a) {
activities.add(a);
switch (a) {
case broadcastV:
@@ -184,9 +188,10 @@ public class Client implements IClient {
break;
default:
}
+ return this;
}
- public void remove(Activity a) {
+ public Client remove(Activity a) {
activities.remove(a);
switch (a) {
case broadcastV:
@@ -199,6 +204,7 @@ public class Client implements IClient {
break;
default:
}
+ return this;
}
public Date getConnectedSince() {
@@ -284,6 +290,15 @@ public class Client implements IClient {
}
@Override
+ public String getServerId() {
+ return serverId;
+ }
+
+ public void setServerId(String serverId) {
+ this.serverId = serverId;
+ }
+
+ @Override
public int hashCode() {
final int prime = 31;
int result = 1;
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/ca559564/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/basic/IClient.java
----------------------------------------------------------------------
diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/basic/IClient.java b/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/basic/IClient.java
index 3e72c0e..9d1cdc1 100644
--- a/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/basic/IClient.java
+++ b/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/basic/IClient.java
@@ -22,10 +22,12 @@ import org.apache.openmeetings.db.entity.IDataProviderEntity;
/**
* Temporary interface, will be removed after 2 types of cliens will be merged
- * {@link org.apache.openmeetings.db.entity.room.Client}
+ * {@link org.apache.openmeetings.db.entity.room.StreamClient}
* {@link org.apache.openmeetings.db.entity.basic.Client}
* @author solomax
*
*/
public interface IClient extends IDataProviderEntity {
+ String getUid();
+ String getServerId();
}