From d140ca0b40b72e4049a938dcfb38366ca0f74a02 Mon Sep 17 00:00:00 2001 From: Richard Alam Date: Tue, 4 Aug 2015 17:58:27 +0000 Subject: [PATCH] - add an api to let us query the user sessions in bbb-web. We use this to see what sessions are hanging around that may be causing OOM exception on tomcat7 --- .../grails-app/conf/UrlMappings.groovy | 7 +- .../web/controllers/ApiController.groovy | 81 +++++++++++++++++++ .../org/bigbluebutton/api/MeetingService.java | 6 +- 3 files changed, 92 insertions(+), 2 deletions(-) diff --git a/bigbluebutton-web/grails-app/conf/UrlMappings.groovy b/bigbluebutton-web/grails-app/conf/UrlMappings.groovy index 66f3d79855..c01269da1b 100755 --- a/bigbluebutton-web/grails-app/conf/UrlMappings.groovy +++ b/bigbluebutton-web/grails-app/conf/UrlMappings.groovy @@ -52,7 +52,12 @@ class UrlMappings { "/api/getMeetings"(controller:"api") { action = [GET:'getMeetingsHandler', POST:'getMeetingsHandler'] } - + + + "/api/getSessions"(controller:"api") { + action = [GET:'getSessionsHandler', POST:'getSessionsHandler'] + } + "/api/getRecordings"(controller:"api") { action = [GET:'getRecordingsHandler', POST:'getRecordingsHandler'] } diff --git a/bigbluebutton-web/grails-app/controllers/org/bigbluebutton/web/controllers/ApiController.groovy b/bigbluebutton-web/grails-app/controllers/org/bigbluebutton/web/controllers/ApiController.groovy index 7fe42aec40..37487d619a 100755 --- a/bigbluebutton-web/grails-app/controllers/org/bigbluebutton/web/controllers/ApiController.groovy +++ b/bigbluebutton-web/grails-app/controllers/org/bigbluebutton/web/controllers/ApiController.groovy @@ -822,6 +822,87 @@ class ApiController { } } } + + /************************************ + * GETSESSIONS API + ************************************/ + def getSessionsHandler = { + String API_CALL = "getSessions" + log.debug CONTROLLER_NAME + "#${API_CALL}" + + println("##### GETSESSIONS API CALL ####") + + // BEGIN - backward compatibility + if (StringUtils.isEmpty(params.checksum)) { + invalid("checksumError", "You did not pass the checksum security check") + return + } + + if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) { + invalid("checksumError", "You did not pass the checksum security check") + return + } + // END - backward compatibility + + ApiErrors errors = new ApiErrors() + + // Do we have a checksum? If none, complain. + if (StringUtils.isEmpty(params.checksum)) { + errors.missingParamError("checksum"); + } + + if (errors.hasErrors()) { + respondWithErrors(errors) + return + } + + // Do we agree on the checksum? If not, complain. + if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) { + errors.checksumError() + respondWithErrors(errors) + return + } + + Collection sssns = meetingService.getSessions(); + + if (sssns == null || sssns.isEmpty()) { + response.addHeader("Cache-Control", "no-cache") + withFormat { + xml { + render(contentType:"text/xml") { + response() { + returncode(RESP_CODE_SUCCESS) + sessions() + messageKey("noSessions") + message("no sessions were found on this server") + } + } + } + } + } else { + println("#### Has sessions [" + sssns.size() + "] #####") + response.addHeader("Cache-Control", "no-cache") + withFormat { + xml { + render(contentType:"text/xml") { + response() { + returncode(RESP_CODE_SUCCESS) + sessions { + for (m in sssns) { + meeting { + meetingID(m.meetingID) + meetingName(m.conferencename) + userName(m.fullname) + } + } + } + } + } + } + } + } + } + def getDefaultConfigXML = { diff --git a/bigbluebutton-web/src/java/org/bigbluebutton/api/MeetingService.java b/bigbluebutton-web/src/java/org/bigbluebutton/api/MeetingService.java index 968f6e72e7..a8d8ba9690 100755 --- a/bigbluebutton-web/src/java/org/bigbluebutton/api/MeetingService.java +++ b/bigbluebutton-web/src/java/org/bigbluebutton/api/MeetingService.java @@ -247,9 +247,13 @@ public class MeetingService implements MessageListener { return meetings.isEmpty() ? Collections.emptySet() : Collections.unmodifiableCollection(meetings.values()); } + public Collection getSessions() { + log.debug("Num sessions = [" + sessions.size() + "]"); + return sessions.isEmpty() ? Collections.emptySet() : Collections.unmodifiableCollection(sessions.values()); + } + public void createMeeting(Meeting m) { handle(new CreateMeeting(m)); -// handleCreateMeeting(m); } private void handleCreateMeeting(Meeting m) {