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/08/01 09:33:45 UTC

openmeetings git commit: [OPENMEETINGS-1677] room balancer seems to be fixed

Repository: openmeetings
Updated Branches:
  refs/heads/3.3.x 6d766bb62 -> 59c689b61


[OPENMEETINGS-1677] room balancer seems to be fixed


Project: http://git-wip-us.apache.org/repos/asf/openmeetings/repo
Commit: http://git-wip-us.apache.org/repos/asf/openmeetings/commit/59c689b6
Tree: http://git-wip-us.apache.org/repos/asf/openmeetings/tree/59c689b6
Diff: http://git-wip-us.apache.org/repos/asf/openmeetings/diff/59c689b6

Branch: refs/heads/3.3.x
Commit: 59c689b61ec4ab344f839b9dea329b9339d9b724
Parents: 6d766bb
Author: Maxim Solodovnik <so...@gmail.com>
Authored: Tue Aug 1 16:33:37 2017 +0700
Committer: Maxim Solodovnik <so...@gmail.com>
Committed: Tue Aug 1 16:33:37 2017 +0700

----------------------------------------------------------------------
 .../src/main/swf/base/mainDatasets.lzx          |  36 +++++---------
 .../src/site/resources/images/cluster2.png      | Bin 52772 -> 30889 bytes
 .../src/site/xdoc/Clustering.xml                |  29 ++++++++---
 .../openmeetings/web/app/Application.java       |  23 +++++++--
 .../apache/openmeetings/web/room/SwfPanel.java  |  49 +++++++++----------
 5 files changed, 75 insertions(+), 62 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/openmeetings/blob/59c689b6/openmeetings-flash/src/main/swf/base/mainDatasets.lzx
----------------------------------------------------------------------
diff --git a/openmeetings-flash/src/main/swf/base/mainDatasets.lzx b/openmeetings-flash/src/main/swf/base/mainDatasets.lzx
index 0e15c06..cb33fbc 100644
--- a/openmeetings-flash/src/main/swf/base/mainDatasets.lzx
+++ b/openmeetings-flash/src/main/swf/base/mainDatasets.lzx
@@ -7,49 +7,37 @@
   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.
-  
+
 -->
 
 <!-- all datasets for main.lzx -->
 
 <library>
-
-	<method name="getLocalBaseUrl">
-	<![CDATA[
-		var urlObject = lz.Browser.getBaseURL();
-		//If Port is Null or undefinied use port 80
-		var port = (urlObject.port != null && urlObject.port != undefined) ? urlObject.port : 80;
-		//if($debug) Debug.write("getBaseUrl:: [urlObject, port]", urlObject, port);
-		var url = "" + urlObject.protocol + "://" + urlObject.host + (port != 80 ? ":" + port : "") + urlObject.path;
-		//if($debug) Debug.write("!!!!!!! getBaseUrl:: [urlObject, port, url]", urlObject, port, url);
-		url = url + (url.slice(-1) == '/' ? '' : '/');
-		//if($debug) Debug.write("!!!!!!! getBaseUrl:: [last, url]", url.slice(-1), url);
-		return url;
-	]]>
-	</method>
-
 	<method name="getServerBaseUrl">
 	<![CDATA[
-		var protocol = lz.Browser.getInitArg('protocol');
+		var url = lz.Browser.getBaseURL();
+		// If Port is Null or undefinied use port 80
+		var port = (url.port != null && url.port != undefined) ? url.port : 80;
 		var host = lz.Browser.getInitArg('host');
-		var port = lz.Browser.getInitArg('port');
-		var context = lz.Browser.getInitArg('context');
-		if (protocol != undefined && host != undefined && port != undefined && !isNaN(port) && context != undefined) {
+		if (host != undefined) {
+			if($debug) Debug.write("Cluster detected:: using node", host);
 			canvas.setAttribute('isCluster', true);
 			canvas.setAttribute('rtmphostlocal', host);
-			return protocol + "://" + host + ":" + port + "/" + context + "/public/";
 		} else {
-			return getLocalBaseUrl();
+			host = url.host;
 		}
+		var url = "" + url.protocol + "://" + host + (port != 80 ? ":" + port : "") + url.path;
+		url = url + (url.slice(-1) == '/' ? '' : '/');
+		return url;
 	]]>
 	</method>
 

http://git-wip-us.apache.org/repos/asf/openmeetings/blob/59c689b6/openmeetings-server/src/site/resources/images/cluster2.png
----------------------------------------------------------------------
diff --git a/openmeetings-server/src/site/resources/images/cluster2.png b/openmeetings-server/src/site/resources/images/cluster2.png
index 6d47e1d..a7391be 100644
Binary files a/openmeetings-server/src/site/resources/images/cluster2.png and b/openmeetings-server/src/site/resources/images/cluster2.png differ

http://git-wip-us.apache.org/repos/asf/openmeetings/blob/59c689b6/openmeetings-server/src/site/xdoc/Clustering.xml
----------------------------------------------------------------------
diff --git a/openmeetings-server/src/site/xdoc/Clustering.xml b/openmeetings-server/src/site/xdoc/Clustering.xml
index 3f58db1..7fc6513 100644
--- a/openmeetings-server/src/site/xdoc/Clustering.xml
+++ b/openmeetings-server/src/site/xdoc/Clustering.xml
@@ -123,20 +123,35 @@
 							</li>
 						</ul>
 					</li>
+					<li>
+						<p>In the file <tt>/opt/red5/webapps/root/crossdomain.xml</tt>:</p>
+						<ul>
+							<li>
+								Update policy to allow requests from other servers (<a href="https://www.adobe.com/devnet-docs/acrobatetk/tools/AppSec/xdomain.html">the guide</a>)<br/>
+								Here is example of very permissive policy (not recommended)<br/>
+								<source><![CDATA[
+<cross-domain-policy>
+	<allow-access-from domain="*" />
+</cross-domain-policy>
+								]]></source>
+							</li>
+						</ul>
+					</li>
 				</ol>
 			</subsection>
 			<subsection name="Ensure everything works as expected">
 				<ul>
 					<li>Set up the cluster and loggin with two users, go to the same room (also check before room
-					entering that the status page with the room list shows the correct number of participants before
-					entering the room). You should login to the same server initially, the server will redirect you
-					for the conference room to the appropriate server automatically. Both users should be in the same room.
+						entering that the status page with the room list shows the correct number of participants before
+						entering the room). You should login to the same server initially, the server will redirect you
+						for the conference room to the appropriate server automatically. Both users should be in the same room.
 					</li>
 					<li>Do the same with only two users but go to _different_ rooms. The calculation should send
-					both users to different servers, cause based on the calculation two different rooms on a cluster
-					with two nodes should go exactly one room for each node. You can now loggin really to node1
-					and node2 of your cluster while those users are loggedin and go to <tt>Administration &gt; Connections</tt>
-					and check in the column "servers" where they are located. They should be on different server.
+						both users to different servers, cause based on the calculation two different rooms on a cluster
+						with two nodes should go exactly one room for each node. You can now loggin really to node1
+						and node2 of your cluster while those users are loggedin and go to <tt>Administration &gt; Connections</tt>
+						and check in the column "Server Name" where they are located. They should be on different server.<br/>
+						Additionally client details, available on click, should show different servers <tt>tcUrl</tt> for clients with "Stream ID"
 					</li>
 				</ul>
 				<img src="images/cluster2.png" alt="" width="650" height="369" />

http://git-wip-us.apache.org/repos/asf/openmeetings/blob/59c689b6/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java b/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java
index dcad229..10b5f03 100644
--- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java
+++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java
@@ -140,7 +140,7 @@ public class Application extends AuthenticatedWebApplication implements IApplica
 	private final static String INVALID_SESSIONS_KEY = "INVALID_SESSIONS_KEY";
 	private final static String ROOMS_KEY = "ROOMS_KEY";
 	private final static String STREAM_CLIENT_KEY = "STREAM_CLIENT_KEY";
-	private final static String NAME_ATTR_KEY = "name";
+	public final static String NAME_ATTR_KEY = "name";
 	//additional maps for faster searching should be created
 	private DashboardContext dashboardContext;
 	private static Set<String> STRINGS_WITH_APP = new HashSet<>(); //FIXME need to be removed
@@ -167,23 +167,38 @@ public class Application extends AuthenticatedWebApplication implements IApplica
 			@Override
 			public void memberRemoved(MembershipEvent evt) {
 				//server down, need to remove all online clients, process persistent addresses
+				String serverId = evt.getMember().getStringAttribute(NAME_ATTR_KEY);
 				for (Map.Entry<String, Client> e : getOnlineUsers().entrySet()) {
-					String serverId = evt.getMember().getStringAttribute(NAME_ATTR_KEY);
 					if (serverId.equals(e.getValue().getServerId())) {
 						exit(e.getValue());
 					}
 				}
+				Map<String, StreamClient> streams = getStreamClients();
+				for (Map.Entry<String, StreamClient> e : streams.entrySet()) {
+					if (serverId.equals(e.getValue().getServerId())) {
+						streams.remove(e.getKey());
+					}
+				}
 				updateJpaAddresses(_getBean(ConfigurationDao.class));
 			}
 
 			@Override
-			public void memberAttributeChanged(MemberAttributeEvent arg0) {
+			public void memberAttributeChanged(MemberAttributeEvent evt) {
 			}
 
 			@Override
-			public void memberAdded(MembershipEvent membershipEvent) {
+			public void memberAdded(MembershipEvent evt) {
 				//server added, need to process persistent addresses
 				updateJpaAddresses(_getBean(ConfigurationDao.class));
+				//check for duplicate instance-names
+				Set<String> names = new HashSet<>();
+				for (Member m : evt.getMembers()) {
+					String serverId = evt.getMember().getStringAttribute(NAME_ATTR_KEY);
+					if (names.contains(serverId)) {
+						log.warn("Duplicate cluster instance with name {} found {}", serverId, m);
+					}
+					names.add(serverId);
+				}
 			}
 		});
 		setPageManagerProvider(new DefaultPageManagerProvider(this) {

http://git-wip-us.apache.org/repos/asf/openmeetings/blob/59c689b6/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/SwfPanel.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/SwfPanel.java b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/SwfPanel.java
index b40658c..e65ebed 100644
--- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/SwfPanel.java
+++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/SwfPanel.java
@@ -19,6 +19,7 @@
 package org.apache.openmeetings.web.room;
 
 import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey;
+import static org.apache.openmeetings.web.app.Application.NAME_ATTR_KEY;
 import static org.apache.openmeetings.web.app.Application.getBean;
 import static org.apache.openmeetings.web.app.WebSession.WICKET_ROOM_ID;
 import static org.apache.openmeetings.web.app.WebSession.getLanguage;
@@ -26,6 +27,7 @@ import static org.apache.openmeetings.web.app.WebSession.getSid;
 import static org.apache.wicket.RuntimeConfigurationType.DEVELOPMENT;
 
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -56,9 +58,7 @@ import org.slf4j.Logger;
 
 import com.github.openjson.JSONArray;
 import com.github.openjson.JSONObject;
-import com.hazelcast.core.HazelcastInstance;
 import com.hazelcast.core.Member;
-import com.hazelcast.instance.MemberImpl;
 
 public class SwfPanel extends BasePanel {
 	private static final long serialVersionUID = 1L;
@@ -186,8 +186,7 @@ public class SwfPanel extends BasePanel {
 	}
 
 	private static PageParameters addServer(PageParameters pp, Member m) {
-		//TODO check this return pp.add("protocol", s.getProtocol()).add("host", s.getAddress()).add("port", s.getPort()).add("context", s.getWebapp());
-		return pp;
+		return pp.add("host", m.getAddress().getHost());
 	}
 
 	private static PageParameters addServer(Long roomId, boolean addBasic) {
@@ -199,31 +198,27 @@ public class SwfPanel extends BasePanel {
 		long minimum = -1;
 		Member result = null;
 		Map<Member, Set<Long>> activeRoomsMap = new HashMap<>();
-		for (Member _m : Application.get(). getServers()) {
-			String serverId = null;
-			MemberImpl m = (MemberImpl)_m;
-			try {
-				HazelcastInstance ins = (HazelcastInstance)MemberImpl.class.getDeclaredField("instance").get(m);
-				serverId = ins.getName();
-			} catch (Exception e) {
-				//no-op
+		List<Member> servers = Application.get().getServers();
+		if (servers.size() > 1) {
+			for (Member m : servers) {
+				String serverId = m.getStringAttribute(NAME_ATTR_KEY);
+				Set<Long> roomIds = getBean(ISessionManager.class).getActiveRoomIds(serverId);
+				if (roomIds.contains(roomId)) {
+					// if the room is already opened on a server, redirect the user to that one,
+					log.debug("Room is already opened on a server {}", m.getAddress());
+					return addServer(pp, m);
+				}
+				activeRoomsMap.put(m, roomIds);
 			}
-			Set<Long> roomIds = getBean(ISessionManager.class).getActiveRoomIds(serverId);
-			if (roomIds.contains(roomId)) {
-				// if the room is already opened on a server, redirect the user to that one,
-				log.debug("Room is already opened on a server {}", m.getAddress());
-				return addServer(pp, m);
+			for (Map.Entry<Member, Set<Long>> entry : activeRoomsMap.entrySet()) {
+				Set<Long> roomIds = entry.getValue();
+				long capacity = getBean(RoomDao.class).getRoomsCapacityByIds(roomIds);
+				if (minimum < 0 || capacity < minimum) {
+					minimum = capacity;
+					result = entry.getKey();
+				}
+				log.debug("Checking server: {} Number of rooms {} RoomIds: {} max(Sum): {}", entry.getKey(), roomIds.size(), roomIds, capacity);
 			}
-			activeRoomsMap.put(m, roomIds);
-		}
-		for (Map.Entry<Member, Set<Long>> entry : activeRoomsMap.entrySet()) {
-			Set<Long> roomIds = entry.getValue();
-			long capacity = getBean(RoomDao.class).getRoomsCapacityByIds(roomIds);
-			if (minimum < 0 || capacity < minimum) {
-				minimum = capacity;
-				result = entry.getKey();
-			}
-			log.debug("Checking server: {} Number of rooms {} RoomIds: {} max(Sum): {}", entry.getKey(), roomIds.size(), roomIds, capacity);
 		}
 		return result == null ? pp : addServer(pp, result);
 	}