Permalink
Browse files

meetings now are removed after the end

  • Loading branch information...
1 parent 2b45b1a commit 415b1ac6db27067a167c9bff7bcd46e481ed5695 @jthomerson committed May 1, 2010
@@ -35,14 +35,15 @@ private boolean isDev() {
// NOTE: these will only be called before app is started, resulting in non-dev values always
public int getSecondsBetweenMeetingUpdateRuns() { return isDev() ? 15 : 45; }
public int getSecondsBeforeFirstMeetingUpdateRun() { return isDev() ? 15 : 45; }
+ public int getSecondsBeforeMeetingIsRemovedAfterEnding() { return 15 * 60; } /* 15 minutes */
// ManageMeeting page:
- public int getSecondsBetweenManageMeetingPagePolls() { return isDev() ? 15 : 30; }
+ public int getSecondsBetweenManageMeetingPagePolls() { return isDev() ? 5 : 20; }
// WaitingRoom page:
- public int getSecondsBetweenWaitingRoomPagePolls() { return isDev() ? 10 : 90; }
+ public int getSecondsBetweenWaitingRoomPagePolls() { return isDev() ? 5 : 20; }
public int getSecondsBeforeFirstWaitingRoomPagePoll() { return isDev() ? 2 : 2; }
- public int getSecondsWithNoPingThatIndicatesTimeOut() { return isDev() ? 30 : 210; }
+ public int getSecondsWithNoPingThatIndicatesTimeOut() { return isDev() ? 15 : 90; }
// HomePage :
public int getSecondsBetweenHomePagePolls() { return getSecondsBetweenWaitingRoomPagePolls(); }
@@ -23,10 +23,15 @@
import java.util.Map;
import org.apache.commons.lang.RandomStringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.genericconf.bbbgateway.TimerSettings;
public class Meeting extends Entity {
private static final long serialVersionUID = 1L;
+ private static final Logger logger = LoggerFactory.getLogger(Meeting.class);
private Server server;
@@ -290,4 +295,16 @@ public void removeAttendee(Attendee att) {
waiters.remove(att.getName());
}
+ public boolean isTimedOut() {
+ if (startTime != null && endTime != null) {
+ long ended = endTime.getTime();
+ final int elapsed = (int) ((System.currentTimeMillis() - ended) / 1000);
+ final boolean timedOut = elapsed > TimerSettings.INSTANCE.getSecondsBeforeMeetingIsRemovedAfterEnding();
+ logger.debug("meeting: {}, ended: {}, elapsed: {}, threshold: {}, timed out: {}", new Object[] { name, ended, elapsed, TimerSettings.INSTANCE.getSecondsBeforeMeetingIsRemovedAfterEnding(), timedOut });
+ return timedOut;
+ }
+ logger.debug("meeting not timed out because it hasn't started and ended");
+ return false;
+ }
+
}
@@ -69,6 +69,7 @@ boolean doExecute() throws Exception {
Date end = (Date) xml.get("endTime");
boolean running = (Boolean) xml.get("running");
meeting.setStartTime(start);
+ meeting.setEndTime(end);
logger.info("meeting [{}] start: {}; end: {}; running: {}", new Object[] { meeting.getMeetingID(), start, end, running });
List<Attendee> atts = (List<Attendee>) xml.get("attendees");
@@ -49,8 +49,20 @@ public MeetingService() {
@Override
public void run() {
logger.info("update meetings timer task running");
- for (Meeting meeting : meetings.values()) {
+ Set<Meeting> toRemove = new HashSet<Meeting>();
+ for (Meeting meeting : new HashSet<Meeting>(meetings.values())) {
tryToUpdateMeeting(meeting);
+ // now allow new ones to join if some have dropped off:
+ bulkAllowAttendees(meeting);
+ if (meeting.isTimedOut()) {
+ toRemove.add(meeting);
+ }
+ }
+ logger.info("meetings to remove: " + toRemove);
+ synchronized(meetings) {
+ for (Meeting rem : toRemove) {
+ meetings.remove(rem.getMeetingID());
+ }
}
}
};
@@ -72,6 +84,7 @@ public void bulkAllowAttendees(Meeting meeting) {
Collections.sort(waiters);
waiters = waiters.subList(0, Math.min(waiters.size(), allowIn));
for (Attendee att : waiters) {
+ logger.debug("allowing {} to join", new Object[] { att });
att.setAllowedToJoin(true);
}
}
@@ -22,7 +22,6 @@
import org.apache.wicket.PageParameters;
import org.apache.wicket.ajax.AbstractAjaxTimerBehavior;
import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.AjaxSelfUpdatingTimerBehavior;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.behavior.SimpleAttributeModifier;
import org.apache.wicket.markup.html.WebMarkupContainer;
@@ -62,14 +62,19 @@ public ManageMeeting(PageParameters params) {
logger.info("meeting ID: " + meetingID + "; check: " + check + "; okay: " + okay);
if (!okay) {
getSession().error("You are not authorized to manage that meeting");
- throw new RestartResponseAtInterceptPageException(HomePage.class);
+ throw new RestartResponseAtInterceptPageException(getApplication().getHomePage());
}
IModel<Meeting> model = new LoadableDetachableModel<Meeting>() {
private static final long serialVersionUID = 1L;
@Override
protected Meeting load() {
- return meetingService.findByMeetingID(meetingID);
+ final Meeting mtg = meetingService.findByMeetingID(meetingID);
+ if (mtg == null) {
+ getSession().error("That meeting no longer exists");
+ throw new RestartResponseAtInterceptPageException(getApplication().getHomePage());
+ }
+ return mtg;
}
};
setDefaultModel(new CompoundPropertyModel<Meeting>(model));

0 comments on commit 415b1ac

Please sign in to comment.