[CalendarServer-changes] [12789] CalendarServer/trunk/calendarserver/webadmin
source_changes at macosforge.org
source_changes at macosforge.org
Mon Mar 3 17:54:58 PST 2014
Revision: 12789
http://trac.calendarserver.org//changeset/12789
Author: wsanchez at apple.com
Date: 2014-03-03 17:54:58 -0800 (Mon, 03 Mar 2014)
Log Message:
-----------
Stream job data to the chart.
Modified Paths:
--------------
CalendarServer/trunk/calendarserver/webadmin/work.py
CalendarServer/trunk/calendarserver/webadmin/work.xhtml
Modified: CalendarServer/trunk/calendarserver/webadmin/work.py
===================================================================
--- CalendarServer/trunk/calendarserver/webadmin/work.py 2014-03-04 01:39:50 UTC (rev 12788)
+++ CalendarServer/trunk/calendarserver/webadmin/work.py 2014-03-04 01:54:58 UTC (rev 12789)
@@ -25,6 +25,7 @@
"WorkMonitorResource",
]
+from time import time
from json import dumps
from zope.interface import implementer
@@ -93,7 +94,6 @@
self._store = store
-
@inlineCallbacks
def render(self, request):
yield self.poll()
@@ -104,68 +104,24 @@
def poll(self):
txn = self._store.newTransaction()
- payload = {}
+ jobData = yield JobItem.histogram(txn)
- records = yield JobItem.histogram(txn)
+ self.addEvents((
+ dict(
+ eventClass=u"work-total",
+ eventID=time(),
+ eventText=asJSON(jobData),
+ ),
+ ))
+ if not hasattr(self, "_clock"):
+ from twisted.internet import reactor
+ self._clock = reactor
+ self._clock.callLater(1, self.poll)
- # for workDescription, workItemClass, itemAttributes in (
- # (
- # u"Organizer Request",
- # ScheduleOrganizerWork,
- # (
- # ("icalendarUid", "iCalendar UID"),
- # ("attendeeCount", "Attendee Count"),
- # ),
- # ),
- # (
- # u"Attendee Reply",
- # ScheduleReplyWork,
- # (
- # ("icalendarUid", "iCalendar UID"),
- # ),
- # ),
- # (
- # u"Attendee Refresh",
- # ScheduleRefreshWork,
- # (
- # ("icalendarUid", "iCalendar UID"),
- # ("attendeeCount", "Attendee Count"),
- # ),
- # ),
- # ):
- # workItems = yield workItemClass.all(txn)
- # categoryData = []
- # for workItem in workItems:
- # itemData = {}
-
- # for itemAttribute, itemDescription in itemAttributes:
- # itemData[itemDescription] = getattr(
- # workItem, itemAttribute
- # )
-
- # categoryData.append(itemData)
-
- # payload[workDescription] = categoryData
-
- # self.addEvents((
- # dict(
- # eventClass=u"work",
- # eventText=asJSON(payload),
- # ),
- # ))
-
- # if not hasattr(self, "_clock"):
- # from twisted.internet import reactor
- # self._clock = reactor
-
- # # self._clock.callLater(5, self.poll)
-
-
-
@implementer(IEventDecoder)
class EventDecoder(object):
@staticmethod
Modified: CalendarServer/trunk/calendarserver/webadmin/work.xhtml
===================================================================
--- CalendarServer/trunk/calendarserver/webadmin/work.xhtml 2014-03-04 01:39:50 UTC (rev 12788)
+++ CalendarServer/trunk/calendarserver/webadmin/work.xhtml 2014-03-04 01:54:58 UTC (rev 12789)
@@ -26,26 +26,82 @@
<script src="http://d3js.org/d3.v3.min.js"></script>
<script>
+ var workTableDescriptions = {
+ // Scheduling
+ "SCHEDULE_ORGANIZER_WORK": "Schedule Organizer",
+ "SCHEDULE_REPLY_WORK": "Schedule Reply",
+ "SCHEDULE_REPLY_CANCEL_WORK": "Schedule Reply (Cancel)",
+ "SCHEDULE_REFRESH_WORK": "Schedule Refresh",
+ "SCHEDULE_AUTO_REPLY_WORK": "Schedule Auto-reply",
+
+ // iMIP scheduling
+ "IMIP_POLLING_WORK": "iMIP Poll",
+ "IMIP_INVITATION_WORK": "iMIP Invitation",
+ "IMIP_REPLY_WORK": "iMIP Reply",
+
+ // Group cacher
+ "GROUP_CACHER_POLLING_WORK": "Group Cache Poll",
+ "GROUP_REFRESH_WORK": "Group Refresh",
+ "GROUP_ATTENDEE_RECONCILIATION_WORK": "Group Attendee Reconciliation",
+
+ // Push notifications
+ "PUSH_NOTIFICATION_WORK": "Push Notification",
+
+ // Event splitting
+ "CALENDAR_OBJECT_SPLITTER_WORK": "Event Split",
+
+ // Inbox cleanup
+ "INBOX_CLEANUP_WORK": "Inbox Cleanup",
+ "CLEANUP_ONE_INBOX_WORK": "Inbox Cleanup: One",
+
+ // Revision cleanup
+ "REVISION_CLEANUP_WORK": "Revision Cleanup",
+ "FIND_MIN_VALID_REVISION_WORK": "Revision Cleanup: Find Minimum",
+ };
+
function drawChart(data) {
+ items = [];
+
+ // Add items in the order used by workTableDescriptions
+ for (key in workTableDescriptions) {
+ if (key in data) {
+ items.push({
+ name: key,
+ count: data[key],
+ description: workTableDescriptions[key],
+ });
+ }
+ }
+
+ for (key in data) {
+ if (! key in workTableDescriptions) {
+ items.push({
+ name: key,
+ count: data[key],
+ description: key,
+ });
+ }
+ }
+
var width = 600;
var barHeight = 20;
var scaledWidth =
d3.scale.linear()
- .domain([0, d3.max(data)])
+ .domain([0, d3.max(items, function(i) { return i.count; })])
.range([0, width]);
var chart =
d3.select("#work_queues_chart")
.attr("width", width)
- .attr("height", barHeight * data.length);
+ .attr("height", barHeight * items.length);
var bars =
chart.selectAll("g")
- .data(data)
+ .data(items);
// Enter selection
- bars.enter().append("g")
+ bars.enter().append("g");
// Update selection
bars.attr(
@@ -54,36 +110,44 @@
);
bars.append("rect")
- .attr("width", scaledWidth)
+ .attr("width", function(i) { return scaledWidth(i.count); })
.attr("height", barHeight - 1);
bars.append("text")
- .attr("x", function(d) { return scaledWidth(d) - 3; })
+ .attr("x", function(i) { return scaledWidth(i.count) - 3; })
.attr("y", barHeight / 2)
.attr("dy", "0.35em")
- .text(function(d) { return d; });
+ .text(function(i) { return i.count; });
// Exit selection
- bars.exit().remove()
+ bars.exit().remove();
}
- function updateChart() {
- drawChart([4, 8, 15, 16, 23, 42]);
- }
+ function initChart() {
+ data = {};
- function initChart() {
- drawChart([1, 2, 3, 4, 8, 15, 16, 23, 42]);
+ for (key in workTableDescriptions) {
+ data[key] = 0;
+ }
+
+ drawChart(data);
}
+ function registerForEvents() {
+ var eventSource = new EventSource("./events");
- function initEventSource() {
- var eventSource = new EventSource("./events");
+ eventSource.addEventListener(
+ "work-total",
+ function(e) { drawChart(JSON.parse(e.data)); },
+ false
+ );
+
}
window.onload = function() {
initChart();
- initEventSource();
+ registerForEvents();
};
</script>
@@ -95,8 +159,6 @@
<h1><t:slot name="title" /></h1>
<svg id="work_queues_chart" />
- <br />
- <button onclick="updateChart()">Update</button>
</body>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140303/f4eb78fd/attachment-0001.html>
More information about the calendarserver-changes
mailing list