Skip to content

Commit

Permalink
Added functionality to setl instance schedule
Browse files Browse the repository at this point in the history
Adds the appropriate actions to set the schedule for all instances of
an app.

Sample URLs:

http://monitor.host:port/cgi-bin/WebObjects/JavaMonitor.woa/admin/schedu
leType?type=app&name=AjaxExample&scheduleType=DAILY
http://monitor.host:port/cgi-bin/WebObjects/JavaMonitor.woa/admin/schedu
leType?type=app&name=AjaxExample&scheduleType=HOURLY
http://monitor.host:port/cgi-bin/WebObjects/JavaMonitor.woa/admin/schedu
leType?type=app&name=AjaxExample&scheduleType=WEEKLY

http://monitor.host:port/cgi-bin/WebObjects/JavaMonitor.woa/admin/dailyS
chedultRange?type=app&name=AjaxExample&hourBegin=1&hourEnd=9
http://monitor.host:port/cgi-bin/WebObjects/JavaMonitor.woa/admin/hourly
ScheduleRange?type=app&name=AjaxExample&hourBegin=1&hourEnd=9&interval=6
http://monitor.host:port/cgi-bin/WebObjects/JavaMonitor.woa/admin/weekly
ScheduleRange?type=app&name=AjaxExample&hourBegin=1&hourEnd=9&weekDay=1
  • Loading branch information
kiberkli authored and Pascal Robert committed Jun 4, 2012
1 parent 5a4f1e8 commit d5d757e
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,12 @@ public WOActionResults infoAction() {
result += "\"deaths\": \"" + minstance.deathCount() + "\", ";
result += "\"refusingNewSessions\": " + minstance.isRefusingNewSessions() + ", ";
result += "\"scheduled\": " + minstance.isScheduled() + ", ";
result += "\"schedulingHourlyStartTime\": " + minstance.schedulingHourlyStartTime() + ", ";
result += "\"schedulingDailyStartTime\": " + minstance.schedulingDailyStartTime() + ", ";
result += "\"schedulingWeeklyStartTime\": " + minstance.schedulingWeeklyStartTime() + ", ";
result += "\"schedulingType\": " + minstance.schedulingType() + ", ";
result += "\"schedulingStartDay\": " + minstance.schedulingStartDay() + ", ";
result += "\"schedulingInterval\": " + minstance.schedulingInterval() + ", ";
result += "\"transactions\": \"" + minstance.transactions() + "\", ";
result += "\"activeSessions\": \"" + minstance.activeSessions() + "\", ";
result += "\"averageIdlePeriod\": \"" + minstance.averageIdlePeriod() + "\", ";
Expand Down Expand Up @@ -446,6 +452,35 @@ public WOActionResults bounceAction() {
public void clearDeathsAction() {
applicationsPage().clearDeaths(instances);
}

public void scheduleTypeAction() {
String scheduleType = (String) context().request().formValueForKey("scheduleType");
if (scheduleType != null && ("HOURLY".equals(scheduleType) || "DAILY".equals(scheduleType) || "WEEKLY".equals(scheduleType)))
applicationsPage().scheduleType(instances, scheduleType);
}

public void hourlyScheduleRangeAction() {
String beginScheduleWindow = (String) context().request().formValueForKey("hourBegin");
String endScheduleWindow = (String) context().request().formValueForKey("hourEnd");
String interval = (String) context().request().formValueForKey("interval");
if (beginScheduleWindow != null && endScheduleWindow != null && interval != null)
applicationsPage().hourlyStartHours(instances, Integer.parseInt(beginScheduleWindow), Integer.parseInt(endScheduleWindow), Integer.parseInt(interval));
}

public void dailyScheduleRangeAction() {
String beginScheduleWindow = (String) context().request().formValueForKey("hourBegin");
String endScheduleWindow = (String) context().request().formValueForKey("hourEnd");
if (beginScheduleWindow != null && endScheduleWindow != null)
applicationsPage().dailyStartHours(instances, Integer.parseInt(beginScheduleWindow), Integer.parseInt(endScheduleWindow));
}

public void weeklyScheduleRangeAction() {
String beginScheduleWindow = (String) context().request().formValueForKey("hourBegin");
String endScheduleWindow = (String) context().request().formValueForKey("hourEnd");
String weekDay = (String) context().request().formValueForKey("weekDay");
if (beginScheduleWindow != null && endScheduleWindow != null && weekDay != null)
applicationsPage().weeklyStartHours(instances, Integer.parseInt(beginScheduleWindow), Integer.parseInt(endScheduleWindow), Integer.parseInt(weekDay));
}

public void turnScheduledOnAction() {
applicationsPage().turnScheduledOn(instances);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,57 @@ public void clearDeaths(NSArray nsarray) {
sendCommandInstancesToWotaskds("CLEAR");
}

public void scheduleType(NSArray nsarray, String scheduleType) {
// Should be one of "HOURLY", "DAILY", "WEEKLY"
for(Enumeration enumeration = nsarray.objectEnumerator(); enumeration.hasMoreElements();) {
MInstance minstance = (MInstance) enumeration.nextElement();
minstance.setSchedulingType(scheduleType);
processedInstance(minstance);
}
sendUpdateInstancesToWotaskds();
}

public void hourlyStartHours(NSArray nsarray, int beginScheduleWindow, int endScheduleWindow, int interval) {
int hour = beginScheduleWindow;
for(Enumeration enumeration = nsarray.objectEnumerator(); enumeration.hasMoreElements();) {
if (hour > endScheduleWindow)
hour = beginScheduleWindow;
MInstance minstance = (MInstance) enumeration.nextElement();
minstance.setSchedulingHourlyStartTime(new Integer(hour));
minstance.setSchedulingInterval(new Integer(interval));
processedInstance(minstance);
hour++;
}
sendUpdateInstancesToWotaskds();
}

public void dailyStartHours(NSArray nsarray, int beginScheduleWindow, int endScheduleWindow) {
int hour = beginScheduleWindow;
for(Enumeration enumeration = nsarray.objectEnumerator(); enumeration.hasMoreElements();) {
if (hour > endScheduleWindow)
hour = beginScheduleWindow;
MInstance minstance = (MInstance) enumeration.nextElement();
minstance.setSchedulingDailyStartTime(new Integer(hour));
processedInstance(minstance);
hour++;
}
sendUpdateInstancesToWotaskds();
}

public void weeklyStartHours(NSArray nsarray, int beginScheduleWindow, int endScheduleWindow, int startDay) {
int hour = beginScheduleWindow;
for(Enumeration enumeration = nsarray.objectEnumerator(); enumeration.hasMoreElements();) {
if (hour > endScheduleWindow)
hour = beginScheduleWindow;
MInstance minstance = (MInstance) enumeration.nextElement();
minstance.setSchedulingWeeklyStartTime(new Integer(hour));
minstance.setSchedulingStartDay(new Integer(startDay));
processedInstance(minstance);
hour++;
}
sendUpdateInstancesToWotaskds();
}

public void turnScheduledOn(NSArray nsarray) {
for(Enumeration enumeration = nsarray.objectEnumerator(); enumeration.hasMoreElements();) {
MInstance minstance = (MInstance) enumeration.nextElement();
Expand Down

0 comments on commit d5d757e

Please sign in to comment.