Commit e811c7c2 authored by Axel Brand's avatar Axel Brand Committed by daeva

Gojara

- show no active sessions as own column, prettier that way
- check if spectrum2 is correctly answering or at least not saying unknown command before trying to parse information from response
- refactored gateway statistic values in gojaraadmin as we use this from interceptors and because of this needs to support concurrent access. 

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@13714 b35dd754-fafc-0310-a699-88a17e54d16e
parent b9eb6505
...@@ -49,7 +49,8 @@ public class GojaraAdminProcessor extends AbstractRemoteRosterProcessor { ...@@ -49,7 +49,8 @@ public class GojaraAdminProcessor extends AbstractRemoteRosterProcessor {
private void handleOnlineUsers(Message message, String subdomain) { private void handleOnlineUsers(Message message, String subdomain) {
Log.debug("Found online_users command!"); Log.debug("Found online_users command!");
if (message.getBody().equals("0")) String body = message.getBody();
if (body.equals("0") || body.startsWith("Unknown command."))
return; return;
String[] content = message.getBody().split("\\r?\\n"); String[] content = message.getBody().split("\\r?\\n");
for (String user : content) { for (String user : content) {
...@@ -68,14 +69,19 @@ public class GojaraAdminProcessor extends AbstractRemoteRosterProcessor { ...@@ -68,14 +69,19 @@ public class GojaraAdminProcessor extends AbstractRemoteRosterProcessor {
} }
private void handleStatistic(Message message, String subdomain, String statistic) { private void handleStatistic(Message message, String subdomain, String statistic) {
int result; String body = message.getBody();
// we dont catch this with exception so we can see what might go wrong. Sometimes S2 responded not knowing the
// command but i dont really know why
if (body.startsWith("Unknown command."))
return;
int value;
try { try {
result = Integer.parseInt(message.getBody()); value = Integer.parseInt(body);
gojaraAdminManager.putStatisticValue(subdomain, statistic, value);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
result = 0;
} }
gojaraAdminManager.getGatewayStatisticsMap().get(subdomain).put(statistic, result);
} }
} }
\ No newline at end of file
package org.jivesoftware.openfire.plugin.gojara.sessions; package org.jivesoftware.openfire.plugin.gojara.sessions;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.jivesoftware.openfire.PacketRouter; import org.jivesoftware.openfire.PacketRouter;
import org.jivesoftware.openfire.XMPPServer; import org.jivesoftware.openfire.XMPPServer;
...@@ -49,7 +49,7 @@ public class GojaraAdminManager { ...@@ -49,7 +49,7 @@ public class GojaraAdminManager {
adminUser = _server.createJID("gojaraadmin", null); adminUser = _server.createJID("gojaraadmin", null);
unconfiguredGateways = new HashSet<String>(); unconfiguredGateways = new HashSet<String>();
configuredGateways = new HashSet<String>(); configuredGateways = new HashSet<String>();
setGatewayStatisticsMap(new HashMap<String, Map<String, Integer>>()); gatewayStatisticsMap = new ConcurrentHashMap<String, Map<String, Integer>>(16, 0.75f, 1);
} }
public static GojaraAdminManager getInstance() { public static GojaraAdminManager getInstance() {
...@@ -74,10 +74,6 @@ public class GojaraAdminManager { ...@@ -74,10 +74,6 @@ public class GojaraAdminManager {
*/ */
public void testAdminConfiguration(String gateway) { public void testAdminConfiguration(String gateway) {
unconfiguredGateways.add(gateway); unconfiguredGateways.add(gateway);
// we add these here and not in confirmGateway so its more clear that these are not being gathered when viewing
// Spectrum2 Stats jsp
getGatewayStatisticsMap().put(gateway, new HashMap<String, Integer>());
Message message = generateCommand(gateway, "config_check"); Message message = generateCommand(gateway, "config_check");
message.setBody("status"); message.setBody("status");
router.route(message); router.route(message);
...@@ -92,6 +88,7 @@ public class GojaraAdminManager { ...@@ -92,6 +88,7 @@ public class GojaraAdminManager {
public void confirmGatewayConfig(String gateway) { public void confirmGatewayConfig(String gateway) {
unconfiguredGateways.remove(gateway); unconfiguredGateways.remove(gateway);
configuredGateways.add(gateway); configuredGateways.add(gateway);
gatewayStatisticsMap.put(gateway, new ConcurrentHashMap<String, Integer>(16, 0.75f, 1));
gatherGatewayStatistics(gateway); gatherGatewayStatistics(gateway);
} }
...@@ -102,7 +99,7 @@ public class GojaraAdminManager { ...@@ -102,7 +99,7 @@ public class GojaraAdminManager {
public void gatewayUnregistered(String gateway) { public void gatewayUnregistered(String gateway) {
unconfiguredGateways.remove(gateway); unconfiguredGateways.remove(gateway);
configuredGateways.remove(gateway); configuredGateways.remove(gateway);
getGatewayStatisticsMap().remove(gateway); gatewayStatisticsMap.remove(gateway);
} }
public boolean areGatewaysConfigured() { public boolean areGatewaysConfigured() {
...@@ -164,12 +161,8 @@ public class GojaraAdminManager { ...@@ -164,12 +161,8 @@ public class GojaraAdminManager {
} }
public Map<String, Map<String, Integer>> getGatewayStatisticsMap() { public void putStatisticValue(String subdomain, String statistic, int value) {
return gatewayStatisticsMap; gatewayStatisticsMap.get(subdomain).put(statistic, value);
}
public void setGatewayStatisticsMap(Map<String, Map<String, Integer>> gatewayStatisticsMap) {
this.gatewayStatisticsMap = gatewayStatisticsMap;
} }
/** /**
...@@ -269,4 +262,5 @@ public class GojaraAdminManager { ...@@ -269,4 +262,5 @@ public class GojaraAdminManager {
} }
return "-"; return "-";
} }
} }
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
Pages: [ Pages: [
<% <%
for (int i = 1; i <= numOfPages; i++) { for (int i = 1; i <= numOfPages; i++) {
%> %>
<%="<a href=\"gojara-activeSessions.jsp?page=" + i + "&sortby=" + sortParams.get("sortby") + "&sortorder=" <%="<a href=\"gojara-activeSessions.jsp?page=" + i + "&sortby=" + sortParams.get("sortby") + "&sortorder="
+ sortParams.get("sortorder") + "\" class=\"" + ((current_page + 1) == i ? "jive-current" : "") + "\">" + i + sortParams.get("sortorder") + "\" class=\"" + ((current_page + 1) == i ? "jive-current" : "") + "\">" + i
+ "</a>"%> + "</a>"%>
...@@ -103,7 +103,9 @@ ...@@ -103,7 +103,9 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<% <% if (numOfSessions == 0) { %>
<tr><td colspan="3">No active Sessions</td></tr>
<% } else {
for (GatewaySession gwsession : gwSessions.subList(current_index, next_items)) { for (GatewaySession gwsession : gwSessions.subList(current_index, next_items)) {
%> %>
<tr class="jive-odd"> <tr class="jive-odd">
...@@ -115,7 +117,7 @@ ...@@ -115,7 +117,7 @@
title="<%=JspHelper.dateDifferenceHelper(gwsession.getLastActivity())%>"><%=gwsession.getLastActivity()%></td> title="<%=JspHelper.dateDifferenceHelper(gwsession.getLastActivity())%>"><%=gwsession.getLastActivity()%></td>
</tr> </tr>
<% <%
} }}
%> %>
</tbody> </tbody>
</table> </table>
......
...@@ -49,13 +49,13 @@ ...@@ -49,13 +49,13 @@
</thead> </thead>
<tbody> <tbody>
<% <%
Set<String> gateways = gojaraAdminManager.getGatewayStatisticsMap().keySet(); Set<String> gateways = transportSessionManager.getActiveGateways();
for (String gateway : gateways) { for (String gateway : gateways) {
%> %>
<tr class="jive-odd"> <tr class="jive-odd">
<td><%=gateway %> <% if (!gateway.contains(domain)) { %> <td><%=gateway %> <% if (!gateway.contains(domain)) { %>
<img alt="gateway configuration info" src="/images/header-help_new.gif" title="Component name does not include server name: <%=domain%>. <img alt="gateway configuration info" src="/images/header-help_new.gif" title="Component name does not include server name: <%=domain%>.
It should be configured like this: transport.server-name, e.g.: icq.<%=gateway%>"> It should be configured like this: transport.server-name, e.g.: icq.<%=domain%>">
<% } %> <% } %>
</td> </td>
<td> <td>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment