<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[13473] CalendarServer/trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/13473">13473</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2014-05-14 13:10:58 -0700 (Wed, 14 May 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Update to new jobqueue implementation. Enhance the dashboard to display more details on jobs being executed. Fix a bunch of historical schema problems.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunkcalendarserverdashboard_servicepy">CalendarServer/trunk/calendarserver/dashboard_service.py</a></li>
<li><a href="#CalendarServertrunkcalendarserverpushnotifierpy">CalendarServer/trunk/calendarserver/push/notifier.py</a></li>
<li><a href="#CalendarServertrunkcalendarserverpushtesttest_notifierpy">CalendarServer/trunk/calendarserver/push/test/test_notifier.py</a></li>
<li><a href="#CalendarServertrunkcalendarservertapcaldavpy">CalendarServer/trunk/calendarserver/tap/caldav.py</a></li>
<li><a href="#CalendarServertrunkcalendarservertoolsdashboardpy">CalendarServer/trunk/calendarserver/tools/dashboard.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavdatastoreschedulingimiptesttest_inboundpy">CalendarServer/trunk/txdav/caldav/datastore/scheduling/imip/test/test_inbound.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavdatastoreschedulingimiptesttest_outboundpy">CalendarServer/trunk/txdav/caldav/datastore/scheduling/imip/test/test_outbound.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavdatastoreschedulingtesttest_implicitpy">CalendarServer/trunk/txdav/caldav/datastore/scheduling/test/test_implicit.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavdatastoreschedulingworkpy">CalendarServer/trunk/txdav/caldav/datastore/scheduling/work.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavdatastoretesttest_sqlpy">CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py</a></li>
<li><a href="#CalendarServertrunktxdavcarddavdatastoretesttest_sqlpy">CalendarServer/trunk/txdav/carddav/datastore/test/test_sql.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresqlpy">CalendarServer/trunk/txdav/common/datastore/sql.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_dumppy">CalendarServer/trunk/txdav/common/datastore/sql_dump.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemacurrentoracledialectsql">CalendarServer/trunk/txdav/common/datastore/sql_schema/current-oracle-dialect.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemacurrentsql">CalendarServer/trunk/txdav/common/datastore/sql_schema/current.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv35sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v35.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv36sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v36.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaoldpostgresdialectv35sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v35.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaoldpostgresdialectv36sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v36.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoretesttest_sqlpy">CalendarServer/trunk/txdav/common/datastore/test/test_sql.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoretestutilpy">CalendarServer/trunk/txdav/common/datastore/test/util.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoreupgradesqlotherstesttest_attachment_migrationpy">CalendarServer/trunk/txdav/common/datastore/upgrade/sql/others/test/test_attachment_migration.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoreupgradesqltesttest_upgradepy">CalendarServer/trunk/txdav/common/datastore/upgrade/sql/test/test_upgrade.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoreworktesttest_inbox_cleanuppy">CalendarServer/trunk/txdav/common/datastore/work/test/test_inbox_cleanup.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoreworktesttest_revision_cleanuppy">CalendarServer/trunk/txdav/common/datastore/work/test/test_revision_cleanup.py</a></li>
<li><a href="#CalendarServertrunktxdavdpstesttest_clientpy">CalendarServer/trunk/txdav/dps/test/test_client.py</a></li>
<li><a href="#CalendarServertrunktxdavwhogroupspy">CalendarServer/trunk/txdav/who/groups.py</a></li>
<li><a href="#CalendarServertrunktxdavwhotesttest_group_attendeespy">CalendarServer/trunk/txdav/who/test/test_group_attendees.py</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv41sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v41.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaoldpostgresdialectv41sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v41.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_41_to_42sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_41_to_42.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaupgradespostgresdialectupgrade_from_41_to_42sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_41_to_42.sql</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunkcalendarserverdashboard_servicepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/calendarserver/dashboard_service.py (13472 => 13473)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/calendarserver/dashboard_service.py        2014-05-14 19:50:12 UTC (rev 13472)
+++ CalendarServer/trunk/calendarserver/dashboard_service.py        2014-05-14 20:10:58 UTC (rev 13473)
</span><span class="lines">@@ -85,7 +85,7 @@
</span><span class="cx"> @return: a string containing the JSON result.
</span><span class="cx"> @rtype: L{str}
</span><span class="cx"> """
</span><del>- return succeed(self.factory.logger.observer.getStats())
</del><ins>+ return succeed(self.factory.logger.getStats())
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> def data_slots(self):
</span><span class="lines">@@ -95,15 +95,13 @@
</span><span class="cx"> @return: a string containing the JSON result.
</span><span class="cx"> @rtype: L{str}
</span><span class="cx"> """
</span><del>- if self.factory.limiter is None:
- raise ValueError()
- states = tuple(self.factory.limiter.dispatcher.slavestates)
</del><ins>+ states = tuple(self.factory.limiter.dispatcher.slavestates) if self.factory.limiter is not None else ()
</ins><span class="cx"> results = []
</span><span class="cx"> for num, status in states:
</span><span class="cx"> result = {"slot": num}
</span><span class="cx"> result.update(status.items())
</span><span class="cx"> results.append(result)
</span><del>- return succeed({"slots": results, "overloaded": self.factory.limiter.overloaded})
</del><ins>+ return succeed({"slots": results, "overloaded": self.factory.limiter.overloaded if self.factory.limiter is not None else False})
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> def data_jobcount(self):
</span><span class="lines">@@ -133,7 +131,22 @@
</span><span class="cx"> returnValue(records)
</span><span class="cx">
</span><span class="cx">
</span><ins>+ def data_job_assignments(self):
+ """
+ Return a summary of the job assignments to workers.
</ins><span class="cx">
</span><ins>+ @return: a string containing the JSON result.
+ @rtype: L{str}
+ """
+
+ queuer = self.factory.store.queuer
+ loads = queuer.workerPool.eachWorkerLoad()
+ level = queuer.workerPool.loadLevel()
+
+ return succeed({"workers": loads, "level": level})
+
+
+
</ins><span class="cx"> class DashboardServer(Factory):
</span><span class="cx">
</span><span class="cx"> protocol = DashboardProtocol
</span></span></pre></div>
<a id="CalendarServertrunkcalendarserverpushnotifierpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/calendarserver/push/notifier.py (13472 => 13473)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/calendarserver/push/notifier.py        2014-05-14 19:50:12 UTC (rev 13472)
+++ CalendarServer/trunk/calendarserver/push/notifier.py        2014-05-14 20:10:58 UTC (rev 13473)
</span><span class="lines">@@ -20,7 +20,7 @@
</span><span class="cx">
</span><span class="cx"> from twext.enterprise.dal.record import fromTable
</span><span class="cx"> from twext.enterprise.dal.syntax import Delete, Select, Parameter
</span><del>-from twext.enterprise.jobqueue import WorkItem
</del><ins>+from twext.enterprise.jobqueue import WorkItem, WORK_PRIORITY_HIGH
</ins><span class="cx"> from twext.python.log import Logger
</span><span class="cx">
</span><span class="cx"> from twisted.internet.defer import inlineCallbacks
</span><span class="lines">@@ -41,6 +41,7 @@
</span><span class="cx"> class PushNotificationWork(WorkItem, fromTable(schema.PUSH_NOTIFICATION_WORK)):
</span><span class="cx">
</span><span class="cx"> group = property(lambda self: self.pushID)
</span><ins>+ default_priority = WORK_PRIORITY_HIGH
</ins><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><span class="cx"> def doWork(self):
</span></span></pre></div>
<a id="CalendarServertrunkcalendarserverpushtesttest_notifierpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/calendarserver/push/test/test_notifier.py (13472 => 13473)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/calendarserver/push/test/test_notifier.py        2014-05-14 19:50:12 UTC (rev 13472)
+++ CalendarServer/trunk/calendarserver/push/test/test_notifier.py        2014-05-14 20:10:58 UTC (rev 13473)
</span><span class="lines">@@ -18,12 +18,14 @@
</span><span class="cx"> from calendarserver.push.notifier import PushDistributor
</span><span class="cx"> from calendarserver.push.notifier import getPubSubAPSConfiguration
</span><span class="cx"> from calendarserver.push.notifier import PushNotificationWork
</span><del>-from twisted.internet.defer import inlineCallbacks, succeed, gatherResults
</del><ins>+from twisted.internet.defer import inlineCallbacks, succeed
</ins><span class="cx"> from twistedcaldav.config import ConfigDict
</span><span class="cx"> from txdav.common.datastore.test.util import populateCalendarsFrom
</span><span class="cx"> from txdav.common.datastore.sql_tables import _BIND_MODE_WRITE
</span><span class="cx"> from calendarserver.push.util import PushPriority
</span><span class="cx"> from txdav.idav import ChangeCategory
</span><ins>+from twext.enterprise.jobqueue import JobItem
+from twisted.internet import reactor
</ins><span class="cx">
</span><span class="cx"> class StubService(object):
</span><span class="cx"> def __init__(self):
</span><span class="lines">@@ -113,43 +115,38 @@
</span><span class="cx"> self._sqlCalendarStore.callWithNewTransactions(decorateTransaction)
</span><span class="cx">
</span><span class="cx"> txn = self._sqlCalendarStore.newTransaction()
</span><del>- wp = (yield txn.enqueue(PushNotificationWork,
</del><ins>+ yield txn.enqueue(PushNotificationWork,
</ins><span class="cx"> pushID="/CalDAV/localhost/foo/",
</span><span class="cx"> pushPriority=PushPriority.high.value
</span><del>- ))
</del><ins>+ )
</ins><span class="cx"> yield txn.commit()
</span><del>- yield wp.whenExecuted()
</del><ins>+ yield JobItem.waitEmpty(self.storeUnderTest().newTransaction, reactor, 60)
</ins><span class="cx"> self.assertEquals(pushDistributor.history,
</span><span class="cx"> [("/CalDAV/localhost/foo/", PushPriority.high)])
</span><span class="cx">
</span><span class="cx"> pushDistributor.reset()
</span><span class="cx"> txn = self._sqlCalendarStore.newTransaction()
</span><del>- proposals = []
- wp = yield txn.enqueue(PushNotificationWork,
</del><ins>+ yield txn.enqueue(PushNotificationWork,
</ins><span class="cx"> pushID="/CalDAV/localhost/bar/",
</span><span class="cx"> pushPriority=PushPriority.high.value
</span><span class="cx"> )
</span><del>- proposals.append(wp.whenExecuted())
- wp = yield txn.enqueue(PushNotificationWork,
</del><ins>+ yield txn.enqueue(PushNotificationWork,
</ins><span class="cx"> pushID="/CalDAV/localhost/bar/",
</span><span class="cx"> pushPriority=PushPriority.high.value
</span><span class="cx"> )
</span><del>- proposals.append(wp.whenExecuted())
- wp = yield txn.enqueue(PushNotificationWork,
</del><ins>+ yield txn.enqueue(PushNotificationWork,
</ins><span class="cx"> pushID="/CalDAV/localhost/bar/",
</span><span class="cx"> pushPriority=PushPriority.high.value
</span><span class="cx"> )
</span><del>- proposals.append(wp.whenExecuted())
</del><span class="cx"> # Enqueue a different pushID to ensure those are not grouped with
</span><span class="cx"> # the others:
</span><del>- wp = yield txn.enqueue(PushNotificationWork,
</del><ins>+ yield txn.enqueue(PushNotificationWork,
</ins><span class="cx"> pushID="/CalDAV/localhost/baz/",
</span><span class="cx"> pushPriority=PushPriority.high.value
</span><span class="cx"> )
</span><del>- proposals.append(wp.whenExecuted())
</del><span class="cx">
</span><span class="cx"> yield txn.commit()
</span><del>- yield gatherResults(proposals)
</del><ins>+ yield JobItem.waitEmpty(self.storeUnderTest().newTransaction, reactor, 60)
</ins><span class="cx"> self.assertEquals(set(pushDistributor.history),
</span><span class="cx"> set([("/CalDAV/localhost/bar/", PushPriority.high),
</span><span class="cx"> ("/CalDAV/localhost/baz/", PushPriority.high)]))
</span><span class="lines">@@ -158,24 +155,20 @@
</span><span class="cx"> # enqueuing low, medium, and high notifications
</span><span class="cx"> pushDistributor.reset()
</span><span class="cx"> txn = self._sqlCalendarStore.newTransaction()
</span><del>- proposals = []
- wp = yield txn.enqueue(PushNotificationWork,
</del><ins>+ yield txn.enqueue(PushNotificationWork,
</ins><span class="cx"> pushID="/CalDAV/localhost/bar/",
</span><span class="cx"> pushPriority=PushPriority.low.value
</span><span class="cx"> )
</span><del>- proposals.append(wp.whenExecuted())
- wp = yield txn.enqueue(PushNotificationWork,
</del><ins>+ yield txn.enqueue(PushNotificationWork,
</ins><span class="cx"> pushID="/CalDAV/localhost/bar/",
</span><span class="cx"> pushPriority=PushPriority.high.value
</span><span class="cx"> )
</span><del>- proposals.append(wp.whenExecuted())
- wp = yield txn.enqueue(PushNotificationWork,
</del><ins>+ yield txn.enqueue(PushNotificationWork,
</ins><span class="cx"> pushID="/CalDAV/localhost/bar/",
</span><span class="cx"> pushPriority=PushPriority.medium.value
</span><span class="cx"> )
</span><del>- proposals.append(wp.whenExecuted())
</del><span class="cx"> yield txn.commit()
</span><del>- yield gatherResults(proposals)
</del><ins>+ yield JobItem.waitEmpty(self.storeUnderTest().newTransaction, reactor, 60)
</ins><span class="cx"> self.assertEquals(pushDistributor.history,
</span><span class="cx"> [("/CalDAV/localhost/bar/", PushPriority.high)])
</span><span class="cx">
</span></span></pre></div>
<a id="CalendarServertrunkcalendarservertapcaldavpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/calendarserver/tap/caldav.py (13472 => 13473)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/calendarserver/tap/caldav.py        2014-05-14 19:50:12 UTC (rev 13472)
+++ CalendarServer/trunk/calendarserver/tap/caldav.py        2014-05-14 20:10:58 UTC (rev 13473)
</span><span class="lines">@@ -1275,6 +1275,14 @@
</span><span class="cx">
</span><span class="cx"> directory = store.directoryService()
</span><span class="cx">
</span><ins>+ # Job queues always required
+ from twisted.internet import reactor
+ pool = PeerConnectionPool(
+ reactor, store.newTransaction, config.WorkQueue.ampPort
+ )
+ store.queuer = store.queuer.transferProposalCallbacks(pool)
+ pool.setServiceParent(result)
+
</ins><span class="cx"> # Optionally set up mail retrieval
</span><span class="cx"> if config.Scheduling.iMIP.Enabled:
</span><span class="cx"> mailRetriever = MailRetriever(
</span><span class="lines">@@ -1284,6 +1292,26 @@
</span><span class="cx"> else:
</span><span class="cx"> mailRetriever = None
</span><span class="cx">
</span><ins>+ # Start listening on the stats socket, for administrators to inspect
+ # the current stats on the server.
+ stats = None
+ if config.Stats.EnableUnixStatsSocket:
+ stats = DashboardServer(logObserver, None)
+ stats.store = store
+ statsService = GroupOwnedUNIXServer(
+ gid, config.Stats.UnixStatsSocket, stats, mode=0660
+ )
+ statsService.setName("unix-stats")
+ statsService.setServiceParent(result)
+ if config.Stats.EnableTCPStatsSocket:
+ stats = DashboardServer(logObserver, None)
+ stats.store = store
+ statsService = TCPServer(
+ config.Stats.TCPStatsPort, stats, interface=""
+ )
+ statsService.setName("tcp-stats")
+ statsService.setServiceParent(result)
+
</ins><span class="cx"> # Optionally set up group cacher
</span><span class="cx"> if config.GroupCaching.Enabled:
</span><span class="cx"> groupCacher = GroupCacher(
</span><span class="lines">@@ -1779,14 +1807,14 @@
</span><span class="cx"> # the current stats on the server.
</span><span class="cx"> stats = None
</span><span class="cx"> if config.Stats.EnableUnixStatsSocket:
</span><del>- stats = DashboardServer(logger, cl if config.UseMetaFD else None)
</del><ins>+ stats = DashboardServer(logger.observer, cl if config.UseMetaFD else None)
</ins><span class="cx"> statsService = GroupOwnedUNIXServer(
</span><span class="cx"> gid, config.Stats.UnixStatsSocket, stats, mode=0660
</span><span class="cx"> )
</span><span class="cx"> statsService.setName("unix-stats")
</span><span class="cx"> statsService.setServiceParent(s)
</span><span class="cx"> if config.Stats.EnableTCPStatsSocket:
</span><del>- stats = DashboardServer(logger, cl if config.UseMetaFD else None)
</del><ins>+ stats = DashboardServer(logger.observer, cl if config.UseMetaFD else None)
</ins><span class="cx"> statsService = TCPServer(
</span><span class="cx"> config.Stats.TCPStatsPort, stats, interface=""
</span><span class="cx"> )
</span></span></pre></div>
<a id="CalendarServertrunkcalendarservertoolsdashboardpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/calendarserver/tools/dashboard.py (13472 => 13473)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/calendarserver/tools/dashboard.py        2014-05-14 19:50:12 UTC (rev 13472)
+++ CalendarServer/trunk/calendarserver/tools/dashboard.py        2014-05-14 20:10:58 UTC (rev 13473)
</span><span class="lines">@@ -414,10 +414,11 @@
</span><span class="cx">
</span><span class="cx"> help = "display server jobs"
</span><span class="cx"> clientItem = "jobs"
</span><ins>+ FORMAT_WIDTH = 78
</ins><span class="cx">
</span><span class="cx"> def makeWindow(self, top=0, left=0):
</span><span class="cx"> nlines = self.readItem("jobcount")
</span><del>- self._createWindow("Jobs", nlines + 5, begin_y=top, begin_x=left)
</del><ins>+ self._createWindow("Jobs", nlines + 5, ncols=self.FORMAT_WIDTH, begin_y=top, begin_x=left)
</ins><span class="cx"> return self
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -435,19 +436,28 @@
</span><span class="cx">
</span><span class="cx"> x = 1
</span><span class="cx"> y = 1
</span><del>- s = " {:<40}{:>8} ".format("Work Type", "Count")
</del><ins>+ s = " {:<40}{:>8}{:>10}{:>8}{:>8} ".format("Work Type", "Count", "Assigned", "Failed", "Overdue")
</ins><span class="cx"> if self.usesCurses:
</span><span class="cx"> self.window.addstr(y, x, s, curses.A_REVERSE)
</span><span class="cx"> else:
</span><span class="cx"> print(s)
</span><span class="cx"> y += 1
</span><del>- for work_type, count in sorted(records.items(), key=lambda x: x[0]):
</del><ins>+ total_count = 0
+ total_assigned = 0
+ total_failed = 0
+ total_overdue = 0
+ for work_type, details in sorted(records.items(), key=lambda x: x[0]):
+ count, assigned, failed, overdue = details
+ total_count += count
+ total_assigned += assigned
+ total_failed += failed
+ total_overdue += overdue
</ins><span class="cx"> changed = (
</span><span class="cx"> work_type in self.lastResult and
</span><del>- self.lastResult[work_type] != count
</del><ins>+ self.lastResult[work_type][0] != count
</ins><span class="cx"> )
</span><del>- s = "{}{:<40}{:>8} ".format(
- ">" if count else " ", work_type, count
</del><ins>+ s = "{}{:<40}{:>8}{:>10}{:>8}{:>8} ".format(
+ ">" if count else " ", work_type, count, assigned, failed, overdue
</ins><span class="cx"> )
</span><span class="cx"> try:
</span><span class="cx"> if self.usesCurses:
</span><span class="lines">@@ -463,9 +473,9 @@
</span><span class="cx"> pass
</span><span class="cx"> y += 1
</span><span class="cx">
</span><del>- s = " {:<40}{:>8} ".format("Total:", sum(records.values()))
</del><ins>+ s = " {:<40}{:>8}{:>10}{:>8}{:>8} ".format("Total:", total_count, total_assigned, total_failed, total_overdue)
</ins><span class="cx"> if self.usesCurses:
</span><del>- self.window.hline(y, x, "-", BOX_WIDTH - 2)
</del><ins>+ self.window.hline(y, x, "-", self.FORMAT_WIDTH - 2)
</ins><span class="cx"> y += 1
</span><span class="cx"> self.window.addstr(y, x, s)
</span><span class="cx"> else:
</span><span class="lines">@@ -479,6 +489,92 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><ins>+class AssignmentsWindow(BaseWindow):
+ """
+ Displays the status of the server's master process worker slave slots.
+ """
+
+ help = "display server child job assignments"
+ clientItem = "job_assignments"
+ FORMAT_WIDTH = 32
+
+ def makeWindow(self, top=0, left=0):
+ slots = self.readItem(self.clientItem)["workers"]
+ self._createWindow(
+ "Job Assignments", len(slots) + 5, self.FORMAT_WIDTH,
+ begin_y=top, begin_x=left
+ )
+ return self
+
+
+ def update(self):
+ data = self.clientData()
+ records = data["workers"]
+ self.iter += 1
+
+ if self.usesCurses:
+ self.window.erase()
+ self.window.border()
+ self.window.addstr(
+ 0, 2,
+ self.title + " {} ({})".format(len(records), self.iter)
+ )
+
+ x = 1
+ y = 1
+ s = " {:>4}{:>12}{:>12} ".format(
+ "Slot", "assigned", "completed"
+ )
+ if self.usesCurses:
+ self.window.addstr(y, x, s, curses.A_REVERSE)
+ else:
+ print(s)
+ y += 1
+ total_completed = 0
+ for ctr, details in enumerate(records):
+ assigned, completed = details
+ total_completed += completed
+ changed = (
+ ctr in self.lastResult and
+ self.lastResult[ctr] != assigned
+ )
+ s = " {:>4}{:>12}{:>12} ".format(
+ ctr,
+ assigned,
+ completed,
+ )
+ try:
+ if self.usesCurses:
+ self.window.addstr(
+ y, x, s,
+ curses.A_REVERSE if changed else curses.A_NORMAL
+ )
+ else:
+ print(s)
+ except curses.error:
+ pass
+ y += 1
+
+ s = " {:<6}{:>10}{:>12}".format(
+ "Total:",
+ "{}%".format(data["level"]),
+ total_completed,
+ )
+ if self.usesCurses:
+ self.window.hline(y, x, "-", self.FORMAT_WIDTH - 2)
+ y += 1
+ self.window.addstr(y, x, s)
+ else:
+ print(s)
+ y += 1
+
+ if self.usesCurses:
+ self.window.refresh()
+
+ self.lastResult = records
+
+
+
</ins><span class="cx"> class SlotsWindow(BaseWindow):
</span><span class="cx"> """
</span><span class="cx"> Displays the status of the server's master process worker slave slots.
</span><span class="lines">@@ -491,7 +587,7 @@
</span><span class="cx"> def makeWindow(self, top=0, left=0):
</span><span class="cx"> slots = self.readItem(self.clientItem)["slots"]
</span><span class="cx"> self._createWindow(
</span><del>- "Slots", len(slots) + 5, self.FORMAT_WIDTH,
</del><ins>+ "HTTP Slots", len(slots) + 5, self.FORMAT_WIDTH,
</ins><span class="cx"> begin_y=top, begin_x=left
</span><span class="cx"> )
</span><span class="cx"> return self
</span><span class="lines">@@ -721,6 +817,7 @@
</span><span class="cx"> Dashboard.registerWindow(SystemWindow, "s")
</span><span class="cx"> Dashboard.registerWindow(StatsWindow, "r")
</span><span class="cx"> Dashboard.registerWindow(WorkWindow, "j")
</span><ins>+Dashboard.registerWindow(AssignmentsWindow, "w")
</ins><span class="cx"> Dashboard.registerWindow(SlotsWindow, "c")
</span><span class="cx"> Dashboard.registerWindow(HelpWindow, "h")
</span><span class="cx">
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavdatastoreschedulingimiptesttest_inboundpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/imip/test/test_inbound.py (13472 => 13473)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/imip/test/test_inbound.py        2014-05-14 19:50:12 UTC (rev 13472)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/imip/test/test_inbound.py        2014-05-14 20:10:58 UTC (rev 13473)
</span><span class="lines">@@ -16,7 +16,9 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> from twisted.internet.defer import inlineCallbacks, succeed
</span><ins>+from twisted.internet import reactor
</ins><span class="cx"> from twisted.python.modules import getModule
</span><ins>+from twisted.trial import unittest
</ins><span class="cx">
</span><span class="cx"> from twistedcaldav.config import ConfigDict
</span><span class="cx"> from twistedcaldav.ical import Component
</span><span class="lines">@@ -30,10 +32,10 @@
</span><span class="cx"> from txdav.caldav.datastore.scheduling.itip import iTIPRequestStatus
</span><span class="cx"> from txdav.common.datastore.test.util import CommonCommonTests
</span><span class="cx">
</span><ins>+from twext.enterprise.jobqueue import JobItem
+
</ins><span class="cx"> import email
</span><del>-from twisted.trial import unittest
</del><span class="cx">
</span><del>-
</del><span class="cx"> class InboundTests(CommonCommonTests, unittest.TestCase):
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><span class="lines">@@ -183,7 +185,9 @@
</span><span class="cx"> result = (yield self.receiver.processDSN(calBody, "xyzzy"))
</span><span class="cx"> self.assertEquals(result, MailReceiver.INJECTION_SUBMITTED)
</span><span class="cx">
</span><ins>+ yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
</ins><span class="cx">
</span><ins>+
</ins><span class="cx"> @inlineCallbacks
</span><span class="cx"> def test_processReply(self):
</span><span class="cx"> msg = email.message_from_string(self.dataFile('good_reply'))
</span><span class="lines">@@ -205,7 +209,9 @@
</span><span class="cx"> result = (yield self.receiver.processReply(msg))
</span><span class="cx"> self.assertEquals(result, MailReceiver.INJECTION_SUBMITTED)
</span><span class="cx">
</span><ins>+ yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
</ins><span class="cx">
</span><ins>+
</ins><span class="cx"> def test_processReplyMissingOrganizer(self):
</span><span class="cx"> msg = email.message_from_string(self.dataFile('reply_missing_organizer'))
</span><span class="cx">
</span><span class="lines">@@ -354,13 +360,13 @@
</span><span class="cx"> END:VCALENDAR
</span><span class="cx"> """
</span><span class="cx"> txn = self.store.newTransaction()
</span><del>- wp = (yield txn.enqueue(IMIPReplyWork,
</del><ins>+ yield txn.enqueue(IMIPReplyWork,
</ins><span class="cx"> organizer="urn:x-uid:user01",
</span><span class="cx"> attendee="mailto:xyzzy@example.com",
</span><span class="cx"> icalendarText=calendar
</span><del>- ))
</del><ins>+ )
</ins><span class="cx"> yield txn.commit()
</span><del>- yield wp.whenExecuted()
</del><ins>+ yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> def test_shouldDeleteAllMail(self):
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavdatastoreschedulingimiptesttest_outboundpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/imip/test/test_outbound.py (13472 => 13473)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/imip/test/test_outbound.py        2014-05-14 19:50:12 UTC (rev 13472)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/imip/test/test_outbound.py        2014-05-14 20:10:58 UTC (rev 13473)
</span><span class="lines">@@ -19,6 +19,7 @@
</span><span class="cx">
</span><span class="cx"> from pycalendar.datetime import DateTime
</span><span class="cx">
</span><ins>+from twisted.internet import reactor
</ins><span class="cx"> from twisted.internet.defer import inlineCallbacks, succeed
</span><span class="cx"> from twisted.trial import unittest
</span><span class="cx"> from twisted.web.template import Element, renderer, flattenString
</span><span class="lines">@@ -31,6 +32,8 @@
</span><span class="cx"> from txdav.caldav.datastore.scheduling.imip.outbound import StringFormatTemplateLoader
</span><span class="cx"> from txdav.common.datastore.test.util import buildStore
</span><span class="cx">
</span><ins>+from twext.enterprise.jobqueue import JobItem
+
</ins><span class="cx"> import email
</span><span class="cx"> from email.iterators import typed_subpart_iterator
</span><span class="cx"> import os
</span><span class="lines">@@ -308,7 +311,7 @@
</span><span class="cx"> ))
</span><span class="cx"> self.assertEquals(wp, self.wp)
</span><span class="cx"> yield txn.commit()
</span><del>- yield wp.whenExecuted()
</del><ins>+ yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
</ins><span class="cx">
</span><span class="cx"> txn = self.store.newTransaction()
</span><span class="cx"> token = (yield txn.imipGetToken(
</span><span class="lines">@@ -335,7 +338,7 @@
</span><span class="cx"> icalendarText=initialInviteText.replace("\n", "\r\n"),
</span><span class="cx"> ))
</span><span class="cx"> yield txn.commit()
</span><del>- yield wp.whenExecuted()
</del><ins>+ yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
</ins><span class="cx"> # Verify a new work proposal was not created
</span><span class="cx"> self.assertEquals(wp, self.wp)
</span><span class="cx">
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavdatastoreschedulingtesttest_implicitpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/test/test_implicit.py (13472 => 13473)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/test/test_implicit.py        2014-05-14 19:50:12 UTC (rev 13472)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/test/test_implicit.py        2014-05-14 20:10:58 UTC (rev 13473)
</span><span class="lines">@@ -17,7 +17,6 @@
</span><span class="cx"> from pycalendar.datetime import DateTime
</span><span class="cx"> from pycalendar.timezone import Timezone
</span><span class="cx">
</span><del>-from twext.python.clsprop import classproperty
</del><span class="cx"> from txweb2 import responsecode
</span><span class="cx"> from txweb2.http import HTTPError
</span><span class="cx">
</span><span class="lines">@@ -31,13 +30,15 @@
</span><span class="cx"> from twistedcaldav.timezones import TimezoneCache
</span><span class="cx">
</span><span class="cx"> from txdav.caldav.datastore.scheduling.cuaddress import LocalCalendarUser
</span><del>-from txdav.caldav.datastore.scheduling.implicit import ImplicitScheduler, \
- ScheduleReplyWork
</del><ins>+from txdav.caldav.datastore.scheduling.implicit import ImplicitScheduler
</ins><span class="cx"> from txdav.caldav.datastore.scheduling.scheduler import ScheduleResponseQueue
</span><span class="cx"> from txdav.caldav.icalendarstore import AttendeeAllowedError, \
</span><span class="cx"> ComponentUpdateState
</span><span class="cx"> from txdav.common.datastore.test.util import CommonCommonTests, populateCalendarsFrom
</span><span class="cx">
</span><ins>+from twext.enterprise.jobqueue import JobItem
+from twext.python.clsprop import classproperty
+
</ins><span class="cx"> import hashlib
</span><span class="cx"> import sys
</span><span class="cx">
</span><span class="lines">@@ -1370,10 +1371,7 @@
</span><span class="cx">
</span><span class="cx"> yield self._setCalendarData(data2, "user02")
</span><span class="cx">
</span><del>- while True:
- work = (yield ScheduleReplyWork.hasWork(self.transactionUnderTest()))
- if not work:
- break
</del><ins>+ yield JobItem.waitEmpty(self.storeUnderTest().newTransaction, reactor, 60)
</ins><span class="cx">
</span><span class="cx"> list1 = (yield self._listCalendarObjects("user01", "inbox"))
</span><span class="cx"> self.assertEqual(len(list1), 1)
</span><span class="lines">@@ -1445,10 +1443,7 @@
</span><span class="cx">
</span><span class="cx"> yield self._setCalendarData(data2, "user02")
</span><span class="cx">
</span><del>- while True:
- work = (yield ScheduleReplyWork.hasWork(self.transactionUnderTest()))
- if not work:
- break
</del><ins>+ yield JobItem.waitEmpty(self.storeUnderTest().newTransaction, reactor, 60)
</ins><span class="cx">
</span><span class="cx"> list1 = (yield self._listCalendarObjects("user01", "inbox"))
</span><span class="cx"> self.assertEqual(len(list1), 1)
</span><span class="lines">@@ -1534,10 +1529,7 @@
</span><span class="cx">
</span><span class="cx"> yield self._setCalendarData(data2, "user02")
</span><span class="cx">
</span><del>- while True:
- work = (yield ScheduleReplyWork.hasWork(self.transactionUnderTest()))
- if not work:
- break
</del><ins>+ yield JobItem.waitEmpty(self.storeUnderTest().newTransaction, reactor, 60)
</ins><span class="cx">
</span><span class="cx"> list1 = (yield self._listCalendarObjects("user01", "inbox"))
</span><span class="cx"> self.assertEqual(len(list1), 1)
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavdatastoreschedulingworkpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/work.py (13472 => 13473)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/work.py        2014-05-14 19:50:12 UTC (rev 13472)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/work.py        2014-05-14 20:10:58 UTC (rev 13473)
</span><span class="lines">@@ -17,7 +17,7 @@
</span><span class="cx"> from twext.enterprise.dal.record import fromTable
</span><span class="cx"> from twext.enterprise.dal.syntax import Select, Insert, Delete, Parameter
</span><span class="cx"> from twext.enterprise.locking import NamedLock
</span><del>-from twext.enterprise.jobqueue import WorkItem
</del><ins>+from twext.enterprise.jobqueue import WorkItem, WORK_PRIORITY_MEDIUM
</ins><span class="cx"> from twext.python.log import Logger
</span><span class="cx">
</span><span class="cx"> from twisted.internet.defer import inlineCallbacks, returnValue, Deferred
</span><span class="lines">@@ -60,6 +60,8 @@
</span><span class="cx">
</span><span class="cx"> # Schedule work is grouped based on calendar object UID
</span><span class="cx"> group = property(lambda self: "ScheduleWork:%s" % (self.icalendarUid,))
</span><ins>+ default_priority = WORK_PRIORITY_MEDIUM
+ default_weight = 5
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> @classmethod
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavdatastoretesttest_sqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py (13472 => 13473)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py        2014-05-14 19:50:12 UTC (rev 13472)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py        2014-05-14 20:10:58 UTC (rev 13473)
</span><span class="lines">@@ -22,9 +22,6 @@
</span><span class="cx"> from pycalendar.datetime import DateTime
</span><span class="cx"> from pycalendar.timezone import Timezone
</span><span class="cx">
</span><del>-from twext.enterprise.dal.syntax import Select, Parameter, Insert, Delete, \
- Update
-from twext.enterprise.ienterprise import AlreadyFinishedError
</del><span class="cx">
</span><span class="cx"> from txweb2 import responsecode
</span><span class="cx"> from txweb2.http_headers import MimeType
</span><span class="lines">@@ -68,6 +65,11 @@
</span><span class="cx"> from txdav.idav import ChangeCategory
</span><span class="cx"> from txdav.xml.rfc2518 import GETContentLanguage, ResourceType
</span><span class="cx">
</span><ins>+from twext.enterprise.dal.syntax import Select, Parameter, Insert, Delete, \
+ Update
+from twext.enterprise.ienterprise import AlreadyFinishedError
+from twext.enterprise.jobqueue import JobItem
+
</ins><span class="cx"> import datetime
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -2988,7 +2990,6 @@
</span><span class="cx"> component = Component.fromString(data % self.subs)
</span><span class="cx"> cobj = yield calendar.createCalendarObjectWithName("data1.ics", component)
</span><span class="cx"> self.assertTrue(hasattr(cobj, "_workItems"))
</span><del>- work = cobj._workItems[0]
</del><span class="cx"> yield self.commit()
</span><span class="cx">
</span><span class="cx"> w = schema.CALENDAR_OBJECT_SPLITTER_WORK
</span><span class="lines">@@ -3001,7 +3002,7 @@
</span><span class="cx"> yield self.abort()
</span><span class="cx">
</span><span class="cx"> # Wait for it to complete
</span><del>- yield work.whenExecuted()
</del><ins>+ yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
</ins><span class="cx">
</span><span class="cx"> rows = yield Select(
</span><span class="cx"> [w.RESOURCE_ID, ],
</span><span class="lines">@@ -3151,7 +3152,6 @@
</span><span class="cx"> component = Component.fromString(data % self.subs)
</span><span class="cx"> cobj = yield calendar.createCalendarObjectWithName("data1.ics", component)
</span><span class="cx"> self.assertTrue(hasattr(cobj, "_workItems"))
</span><del>- work = cobj._workItems[0]
</del><span class="cx"> yield self.commit()
</span><span class="cx">
</span><span class="cx"> w = schema.CALENDAR_OBJECT_SPLITTER_WORK
</span><span class="lines">@@ -3175,7 +3175,7 @@
</span><span class="cx"> yield self.abort()
</span><span class="cx">
</span><span class="cx"> # Wait for it to complete
</span><del>- yield work.whenExecuted()
</del><ins>+ yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
</ins><span class="cx">
</span><span class="cx"> rows = yield Select(
</span><span class="cx"> [w.RESOURCE_ID, ],
</span><span class="lines">@@ -3781,11 +3781,10 @@
</span><span class="cx"> cobj = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="user01")
</span><span class="cx"> yield cobj.setComponent(Component.fromString(data_split_1 % relsubs))
</span><span class="cx"> self.assertTrue(hasattr(cobj, "_workItems"))
</span><del>- work = cobj._workItems[0]
</del><span class="cx"> yield self.commit()
</span><span class="cx">
</span><span class="cx"> # Wait for it to complete
</span><del>- yield work.whenExecuted()
</del><ins>+ yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
</ins><span class="cx">
</span><span class="cx"> # Get the existing and new object data
</span><span class="cx"> ical_future, ical_past, pastUID, relID, _ignore_new_name = yield self._splitDetails("user01")
</span><span class="lines">@@ -5161,7 +5160,6 @@
</span><span class="cx"> component = Component.fromString(data % self.subs)
</span><span class="cx"> cobj = yield calendar.createCalendarObjectWithName("data1.ics", component)
</span><span class="cx"> self.assertTrue(hasattr(cobj, "_workItems"))
</span><del>- work = cobj._workItems[0]
</del><span class="cx"> yield self.commit()
</span><span class="cx">
</span><span class="cx"> self.patch(CalDAVScheduler, "doSchedulingViaPUT", _doSchedulingViaPUT)
</span><span class="lines">@@ -5176,7 +5174,7 @@
</span><span class="cx"> yield self.abort()
</span><span class="cx">
</span><span class="cx"> # Wait for it to complete
</span><del>- yield work.whenExecuted()
</del><ins>+ yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
</ins><span class="cx">
</span><span class="cx"> rows = yield Select(
</span><span class="cx"> [w.RESOURCE_ID, ],
</span><span class="lines">@@ -5594,7 +5592,6 @@
</span><span class="cx"> component = Component.fromString(data % self.subs)
</span><span class="cx"> yield self.failUnlessFailure(cobj.setComponent(component), AlreadyFinishedError)
</span><span class="cx"> self.assertTrue(self.transactionUnderTest().timedout)
</span><del>- work = cobj._workItems[0]
</del><span class="cx">
</span><span class="cx"> # Clear out timed out state
</span><span class="cx"> self.lastTransaction = None
</span><span class="lines">@@ -5610,7 +5607,7 @@
</span><span class="cx"> yield self.abort()
</span><span class="cx">
</span><span class="cx"> # Wait for it to complete
</span><del>- yield work.whenExecuted()
</del><ins>+ yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
</ins><span class="cx">
</span><span class="cx"> rows = yield Select(
</span><span class="cx"> [w.RESOURCE_ID, ],
</span></span></pre></div>
<a id="CalendarServertrunktxdavcarddavdatastoretesttest_sqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/carddav/datastore/test/test_sql.py (13472 => 13473)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/carddav/datastore/test/test_sql.py        2014-05-14 19:50:12 UTC (rev 13472)
+++ CalendarServer/trunk/txdav/carddav/datastore/test/test_sql.py        2014-05-14 20:10:58 UTC (rev 13473)
</span><span class="lines">@@ -86,7 +86,6 @@
</span><span class="cx"> self.notifierFactory.reset()
</span><span class="cx">
</span><span class="cx">
</span><del>-
</del><span class="cx"> @inlineCallbacks
</span><span class="cx"> def assertAddressbooksSimilar(self, a, b, bAddressbookFilter=None):
</span><span class="cx"> """
</span><span class="lines">@@ -532,7 +531,7 @@
</span><span class="cx"> Test that kind property vCard is stored correctly in database
</span><span class="cx"> """
</span><span class="cx"> addressbookStore = self.store
</span><del>- cleanStore(self, addressbookStore)
</del><ins>+ yield cleanStore(self, addressbookStore)
</ins><span class="cx">
</span><span class="cx"> # Provision the home and addressbook, one user and one group
</span><span class="cx"> txn = addressbookStore.newTransaction()
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql.py (13472 => 13473)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql.py        2014-05-14 19:50:12 UTC (rev 13472)
+++ CalendarServer/trunk/txdav/common/datastore/sql.py        2014-05-14 20:10:58 UTC (rev 13473)
</span><span class="lines">@@ -284,7 +284,7 @@
</span><span class="cx"> """
</span><span class="cx"> txn = CommonStoreTransaction(
</span><span class="cx"> self,
</span><del>- self.sqlTxnFactory(),
</del><ins>+ self.sqlTxnFactory(label=label),
</ins><span class="cx"> self.enableCalendars,
</span><span class="cx"> self.enableAddressBooks,
</span><span class="cx"> self._notifierFactories if self._enableNotifications else {},
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_dumppy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_dump.py (13472 => 13473)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_dump.py        2014-05-14 19:50:12 UTC (rev 13472)
+++ CalendarServer/trunk/txdav/common/datastore/sql_dump.py        2014-05-14 20:10:58 UTC (rev 13473)
</span><span class="lines">@@ -16,13 +16,27 @@
</span><span class="cx"> ##
</span><span class="cx">
</span><span class="cx"> from twisted.internet.defer import inlineCallbacks, returnValue
</span><del>-from twext.enterprise.dal.model import Schema, Table, Column, Sequence, Function
</del><ins>+from twext.enterprise.dal.model import Schema, Table, Column, Sequence, Function, \
+ SQLType, ProcedureCall
</ins><span class="cx"> from twext.enterprise.dal.parseschema import addSQLToSchema
</span><span class="cx">
</span><span class="cx"> """
</span><span class="cx"> Dump a postgres DB into an L{Schema} model object.
</span><span class="cx"> """
</span><span class="cx">
</span><ins>+DTYPE_MAP = {
+ "character": "char",
+ "character varying": "varchar",
+ "timestamp without time zone": "timestamp",
+}
+
+DEFAULTVALUE_MAP = {
+ "timezone('UTC'::text, now())": ProcedureCall("timezone", ["UTC", "CURRENT_TIMESTAMP"]),
+ "NULL::character varying": None,
+ "false": False,
+ "true": True,
+}
+
</ins><span class="cx"> @inlineCallbacks
</span><span class="cx"> def dumpSchema(txn, title, schemaname="public"):
</span><span class="cx"> """
</span><span class="lines">@@ -32,35 +46,67 @@
</span><span class="cx"> schemaname = schemaname.lower()
</span><span class="cx">
</span><span class="cx"> schema = Schema(title)
</span><del>- tables = {}
</del><span class="cx">
</span><ins>+ # Sequences
+ seqs = {}
+ rows = yield txn.execSQL("select sequence_name from information_schema.sequences where sequence_schema = '%s';" % (schemaname,))
+ for row in rows:
+ name = row[0]
+ seqs[name.upper()] = Sequence(schema, name.upper())
+
</ins><span class="cx"> # Tables
</span><ins>+ tables = {}
</ins><span class="cx"> rows = yield txn.execSQL("select table_name from information_schema.tables where table_schema = '%s';" % (schemaname,))
</span><span class="cx"> for row in rows:
</span><span class="cx"> name = row[0]
</span><del>- table = Table(schema, name)
- tables[name] = table
</del><ins>+ table = Table(schema, name.upper())
+ tables[name.upper()] = table
</ins><span class="cx">
</span><span class="cx"> # Columns
</span><del>- rows = yield txn.execSQL("select column_name from information_schema.columns where table_schema = '%s' and table_name = '%s';" % (schemaname, name,))
- for row in rows:
- name = row[0]
</del><ins>+ rows = yield txn.execSQL("select column_name, data_type, character_maximum_length, column_default from information_schema.columns where table_schema = '%s' and table_name = '%s';" % (schemaname, name,))
+ for name, datatype, charlen, default in rows:
</ins><span class="cx"> # TODO: figure out the type
</span><del>- column = Column(table, name, None)
</del><ins>+ column = Column(table, name.upper(), SQLType(DTYPE_MAP.get(datatype, datatype), charlen))
</ins><span class="cx"> table.columns.append(column)
</span><ins>+ if default:
+ if default.startswith("nextval("):
+ dname = default.split("'")[1].split(".")[-1]
+ column.default = seqs[dname.upper()]
+ elif default in DEFAULTVALUE_MAP:
+ column.default = DEFAULTVALUE_MAP[default]
+ else:
+ try:
+ column.default = int(default)
+ except ValueError:
+ column.default = default
</ins><span class="cx">
</span><ins>+ # Key columns
+ keys = {}
+ rows = yield txn.execSQL("select constraint_name, table_name, column_name from information_schema.key_column_usage where constraint_schema = '%s';" % (schemaname,))
+ for conname, tname, cname in rows:
+ keys[conname] = (tname, cname)
+
+ # Constraints
+ constraints = {}
+ rows = yield txn.execSQL("select constraint_name, table_name, column_name from information_schema.constraint_column_usage where constraint_schema = '%s';" % (schemaname,))
+ for conname, tname, cname in rows:
+ constraints[conname] = (tname, cname)
+
+ # References - referential_constraints
+ rows = yield txn.execSQL("select constraint_name, unique_constraint_name, delete_rule from information_schema.referential_constraints where constraint_schema = '%s';" % (schemaname,))
+ for conname, uconname, delete in rows:
+ table = tables[keys[conname][0].upper()]
+ column = table.columnNamed(keys[conname][1].upper())
+ column.doesReferenceName(constraints[uconname][0].upper())
+ if delete != "NO ACTION":
+ column.deleteAction = delete.lower()
+
</ins><span class="cx"> # Indexes
</span><span class="cx"> # TODO: handle implicit indexes created via primary key() and unique() statements within CREATE TABLE
</span><span class="cx"> rows = yield txn.execSQL("select indexdef from pg_indexes where schemaname = '%s';" % (schemaname,))
</span><span class="cx"> for indexdef in rows:
</span><del>- addSQLToSchema(schema, indexdef[0].replace("%s." % (schemaname,), ""))
</del><ins>+ addSQLToSchema(schema, indexdef[0].replace("%s." % (schemaname,), "").upper())
</ins><span class="cx">
</span><del>- # Sequences
- rows = yield txn.execSQL("select sequence_name from information_schema.sequences where sequence_schema = '%s';" % (schemaname,))
- for row in rows:
- name = row[0]
- Sequence(schema, name)
-
</del><span class="cx"> # Functions
</span><span class="cx"> rows = yield txn.execSQL("select routine_name from information_schema.routines where routine_schema = '%s';" % (schemaname,))
</span><span class="cx"> for row in rows:
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemacurrentoracledialectsql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/current-oracle-dialect.sql (13472 => 13473)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/current-oracle-dialect.sql        2014-05-14 19:50:12 UTC (rev 13472)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/current-oracle-dialect.sql        2014-05-14 20:10:58 UTC (rev 13473)
</span><span class="lines">@@ -21,8 +21,9 @@
</span><span class="cx"> "WORK_TYPE" nvarchar2(255),
</span><span class="cx"> "PRIORITY" integer default 0,
</span><span class="cx"> "WEIGHT" integer default 0,
</span><del>- "NOT_BEFORE" timestamp default null,
- "NOT_AFTER" timestamp default null
</del><ins>+ "NOT_BEFORE" timestamp not null,
+ "ASSIGNED" timestamp default null,
+ "FAILED" integer default 0
</ins><span class="cx"> );
</span><span class="cx">
</span><span class="cx"> create table CALENDAR_HOME (
</span><span class="lines">@@ -567,7 +568,7 @@
</span><span class="cx"> "VALUE" nvarchar2(255)
</span><span class="cx"> );
</span><span class="cx">
</span><del>-insert into CALENDARSERVER (NAME, VALUE) values ('VERSION', '41');
</del><ins>+insert into CALENDARSERVER (NAME, VALUE) values ('VERSION', '42');
</ins><span class="cx"> insert into CALENDARSERVER (NAME, VALUE) values ('CALENDAR-DATAVERSION', '6');
</span><span class="cx"> insert into CALENDARSERVER (NAME, VALUE) values ('ADDRESSBOOK-DATAVERSION', '2');
</span><span class="cx"> insert into CALENDARSERVER (NAME, VALUE) values ('NOTIFICATION-DATAVERSION', '1');
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemacurrentsql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/current.sql (13472 => 13473)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/current.sql        2014-05-14 19:50:12 UTC (rev 13472)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/current.sql        2014-05-14 20:10:58 UTC (rev 13473)
</span><span class="lines">@@ -58,8 +58,9 @@
</span><span class="cx"> WORK_TYPE varchar(255) not null,
</span><span class="cx"> PRIORITY integer default 0,
</span><span class="cx"> WEIGHT integer default 0,
</span><del>- NOT_BEFORE timestamp default null,
- NOT_AFTER timestamp default null
</del><ins>+ NOT_BEFORE timestamp not null,
+ ASSIGNED timestamp default null,
+ FAILED         integer default 0
</ins><span class="cx"> );
</span><span class="cx">
</span><span class="cx"> create or replace function next_job() returns integer as $$
</span><span class="lines">@@ -1081,7 +1082,7 @@
</span><span class="cx"> VALUE varchar(255)
</span><span class="cx"> );
</span><span class="cx">
</span><del>-insert into CALENDARSERVER values ('VERSION', '41');
</del><ins>+insert into CALENDARSERVER values ('VERSION', '42');
</ins><span class="cx"> insert into CALENDARSERVER values ('CALENDAR-DATAVERSION', '6');
</span><span class="cx"> insert into CALENDARSERVER values ('ADDRESSBOOK-DATAVERSION', '2');
</span><span class="cx"> insert into CALENDARSERVER values ('NOTIFICATION-DATAVERSION', '1');
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv35sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v35.sql (13472 => 13473)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v35.sql        2014-05-14 19:50:12 UTC (rev 13472)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v35.sql        2014-05-14 20:10:58 UTC (rev 13473)
</span><span class="lines">@@ -416,18 +416,20 @@
</span><span class="cx"> create table DELEGATES (
</span><span class="cx"> "DELEGATOR" nvarchar2(255),
</span><span class="cx"> "DELEGATE" nvarchar2(255),
</span><del>- "READ_WRITE" integer not null
</del><ins>+ "READ_WRITE" integer not null,
+ primary key("DELEGATOR", "READ_WRITE", "DELEGATE")
</ins><span class="cx"> );
</span><span class="cx">
</span><span class="cx"> create table DELEGATE_GROUPS (
</span><span class="cx"> "DELEGATOR" nvarchar2(255),
</span><span class="cx"> "GROUP_ID" integer not null,
</span><span class="cx"> "READ_WRITE" integer not null,
</span><del>- "IS_EXTERNAL" integer not null
</del><ins>+ "IS_EXTERNAL" integer not null,
+ primary key("DELEGATOR", "READ_WRITE", "GROUP_ID")
</ins><span class="cx"> );
</span><span class="cx">
</span><span class="cx"> create table EXTERNAL_DELEGATE_GROUPS (
</span><del>- "DELEGATOR" nvarchar2(255),
</del><ins>+ "DELEGATOR" nvarchar2(255) primary key,
</ins><span class="cx"> "GROUP_UID_READ" nvarchar2(255),
</span><span class="cx"> "GROUP_UID_WRITE" nvarchar2(255)
</span><span class="cx"> );
</span><span class="lines">@@ -661,6 +663,12 @@
</span><span class="cx"> MEMBER_UID
</span><span class="cx"> );
</span><span class="cx">
</span><ins>+create index DELEGATE_TO_DELEGATOR_5e149b11 on DELEGATES (
+ DELEGATE,
+ READ_WRITE,
+ DELEGATOR
+);
+
</ins><span class="cx"> create index CALENDAR_OBJECT_SPLIT_af71dcda on CALENDAR_OBJECT_SPLITTER_WORK (
</span><span class="cx"> RESOURCE_ID
</span><span class="cx"> );
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv36sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v36.sql (13472 => 13473)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v36.sql        2014-05-14 19:50:12 UTC (rev 13472)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v36.sql        2014-05-14 20:10:58 UTC (rev 13473)
</span><span class="lines">@@ -416,18 +416,20 @@
</span><span class="cx"> create table DELEGATES (
</span><span class="cx"> "DELEGATOR" nvarchar2(255),
</span><span class="cx"> "DELEGATE" nvarchar2(255),
</span><del>- "READ_WRITE" integer not null
</del><ins>+ "READ_WRITE" integer not null,
+ primary key("DELEGATOR", "READ_WRITE", "DELEGATE")
</ins><span class="cx"> );
</span><span class="cx">
</span><span class="cx"> create table DELEGATE_GROUPS (
</span><span class="cx"> "DELEGATOR" nvarchar2(255),
</span><span class="cx"> "GROUP_ID" integer not null,
</span><span class="cx"> "READ_WRITE" integer not null,
</span><del>- "IS_EXTERNAL" integer not null
</del><ins>+ "IS_EXTERNAL" integer not null,
+ primary key("DELEGATOR", "READ_WRITE", "GROUP_ID")
</ins><span class="cx"> );
</span><span class="cx">
</span><span class="cx"> create table EXTERNAL_DELEGATE_GROUPS (
</span><del>- "DELEGATOR" nvarchar2(255),
</del><ins>+ "DELEGATOR" nvarchar2(255) primary key,
</ins><span class="cx"> "GROUP_UID_READ" nvarchar2(255),
</span><span class="cx"> "GROUP_UID_WRITE" nvarchar2(255)
</span><span class="cx"> );
</span><span class="lines">@@ -672,6 +674,12 @@
</span><span class="cx"> MEMBER_UID
</span><span class="cx"> );
</span><span class="cx">
</span><ins>+create index DELEGATE_TO_DELEGATOR_5e149b11 on DELEGATES (
+ DELEGATE,
+ READ_WRITE,
+ DELEGATOR
+);
+
</ins><span class="cx"> create index CALENDAR_OBJECT_SPLIT_af71dcda on CALENDAR_OBJECT_SPLITTER_WORK (
</span><span class="cx"> RESOURCE_ID
</span><span class="cx"> );
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv41sql"></a>
<div class="addfile"><h4>Added: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v41.sql (0 => 13473)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v41.sql         (rev 0)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v41.sql        2014-05-14 20:10:58 UTC (rev 13473)
</span><span class="lines">@@ -0,0 +1,873 @@
</span><ins>+create sequence RESOURCE_ID_SEQ;
+create sequence JOB_SEQ;
+create sequence INSTANCE_ID_SEQ;
+create sequence ATTACHMENT_ID_SEQ;
+create sequence REVISION_SEQ;
+create sequence WORKITEM_SEQ;
+create table NODE_INFO (
+ "HOSTNAME" nvarchar2(255),
+ "PID" integer not null,
+ "PORT" integer not null,
+ "TIME" timestamp default CURRENT_TIMESTAMP at time zone 'UTC' not null,
+ primary key ("HOSTNAME", "PORT")
+);
+
+create table NAMED_LOCK (
+ "LOCK_NAME" nvarchar2(255) primary key
+);
+
+create table JOB (
+ "JOB_ID" integer primary key not null,
+ "WORK_TYPE" nvarchar2(255),
+ "PRIORITY" integer default 0,
+ "WEIGHT" integer default 0,
+ "NOT_BEFORE" timestamp default null,
+ "NOT_AFTER" timestamp default null
+);
+
+create table CALENDAR_HOME (
+ "RESOURCE_ID" integer primary key,
+ "OWNER_UID" nvarchar2(255) unique,
+ "STATUS" integer default 0 not null,
+ "DATAVERSION" integer default 0 not null
+);
+
+create table HOME_STATUS (
+ "ID" integer primary key,
+ "DESCRIPTION" nvarchar2(16) unique
+);
+
+insert into HOME_STATUS (DESCRIPTION, ID) values ('normal', 0);
+insert into HOME_STATUS (DESCRIPTION, ID) values ('external', 1);
+insert into HOME_STATUS (DESCRIPTION, ID) values ('purging', 2);
+create table CALENDAR (
+ "RESOURCE_ID" integer primary key
+);
+
+create table CALENDAR_HOME_METADATA (
+ "RESOURCE_ID" integer primary key references CALENDAR_HOME on delete cascade,
+ "QUOTA_USED_BYTES" integer default 0 not null,
+ "DEFAULT_EVENTS" integer default null references CALENDAR on delete set null,
+ "DEFAULT_TASKS" integer default null references CALENDAR on delete set null,
+ "DEFAULT_POLLS" integer default null references CALENDAR on delete set null,
+ "ALARM_VEVENT_TIMED" nclob default null,
+ "ALARM_VEVENT_ALLDAY" nclob default null,
+ "ALARM_VTODO_TIMED" nclob default null,
+ "ALARM_VTODO_ALLDAY" nclob default null,
+ "AVAILABILITY" nclob default null,
+ "CREATED" timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+ "MODIFIED" timestamp default CURRENT_TIMESTAMP at time zone 'UTC'
+);
+
+create table CALENDAR_METADATA (
+ "RESOURCE_ID" integer primary key references CALENDAR on delete cascade,
+ "SUPPORTED_COMPONENTS" nvarchar2(255) default null,
+ "CREATED" timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+ "MODIFIED" timestamp default CURRENT_TIMESTAMP at time zone 'UTC'
+);
+
+create table NOTIFICATION_HOME (
+ "RESOURCE_ID" integer primary key,
+ "OWNER_UID" nvarchar2(255) unique,
+ "STATUS" integer default 0 not null,
+ "DATAVERSION" integer default 0 not null
+);
+
+create table NOTIFICATION (
+ "RESOURCE_ID" integer primary key,
+ "NOTIFICATION_HOME_RESOURCE_ID" integer not null references NOTIFICATION_HOME,
+ "NOTIFICATION_UID" nvarchar2(255),
+ "NOTIFICATION_TYPE" nvarchar2(255),
+ "NOTIFICATION_DATA" nclob,
+ "MD5" nchar(32),
+ "CREATED" timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+ "MODIFIED" timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+ unique ("NOTIFICATION_UID", "NOTIFICATION_HOME_RESOURCE_ID")
+);
+
+create table CALENDAR_BIND (
+ "CALENDAR_HOME_RESOURCE_ID" integer not null references CALENDAR_HOME,
+ "CALENDAR_RESOURCE_ID" integer not null references CALENDAR on delete cascade,
+ "EXTERNAL_ID" integer default null,
+ "CALENDAR_RESOURCE_NAME" nvarchar2(255),
+ "BIND_MODE" integer not null,
+ "BIND_STATUS" integer not null,
+ "BIND_REVISION" integer default 0 not null,
+ "MESSAGE" nclob,
+ "TRANSP" integer default 0 not null,
+ "ALARM_VEVENT_TIMED" nclob default null,
+ "ALARM_VEVENT_ALLDAY" nclob default null,
+ "ALARM_VTODO_TIMED" nclob default null,
+ "ALARM_VTODO_ALLDAY" nclob default null,
+ "TIMEZONE" nclob default null,
+ primary key ("CALENDAR_HOME_RESOURCE_ID", "CALENDAR_RESOURCE_ID"),
+ unique ("CALENDAR_HOME_RESOURCE_ID", "CALENDAR_RESOURCE_NAME")
+);
+
+create table CALENDAR_BIND_MODE (
+ "ID" integer primary key,
+ "DESCRIPTION" nvarchar2(16) unique
+);
+
+insert into CALENDAR_BIND_MODE (DESCRIPTION, ID) values ('own', 0);
+insert into CALENDAR_BIND_MODE (DESCRIPTION, ID) values ('read', 1);
+insert into CALENDAR_BIND_MODE (DESCRIPTION, ID) values ('write', 2);
+insert into CALENDAR_BIND_MODE (DESCRIPTION, ID) values ('direct', 3);
+insert into CALENDAR_BIND_MODE (DESCRIPTION, ID) values ('indirect', 4);
+create table CALENDAR_BIND_STATUS (
+ "ID" integer primary key,
+ "DESCRIPTION" nvarchar2(16) unique
+);
+
+insert into CALENDAR_BIND_STATUS (DESCRIPTION, ID) values ('invited', 0);
+insert into CALENDAR_BIND_STATUS (DESCRIPTION, ID) values ('accepted', 1);
+insert into CALENDAR_BIND_STATUS (DESCRIPTION, ID) values ('declined', 2);
+insert into CALENDAR_BIND_STATUS (DESCRIPTION, ID) values ('invalid', 3);
+insert into CALENDAR_BIND_STATUS (DESCRIPTION, ID) values ('deleted', 4);
+create table CALENDAR_TRANSP (
+ "ID" integer primary key,
+ "DESCRIPTION" nvarchar2(16) unique
+);
+
+insert into CALENDAR_TRANSP (DESCRIPTION, ID) values ('opaque', 0);
+insert into CALENDAR_TRANSP (DESCRIPTION, ID) values ('transparent', 1);
+create table CALENDAR_OBJECT (
+ "RESOURCE_ID" integer primary key,
+ "CALENDAR_RESOURCE_ID" integer not null references CALENDAR on delete cascade,
+ "RESOURCE_NAME" nvarchar2(255),
+ "ICALENDAR_TEXT" nclob,
+ "ICALENDAR_UID" nvarchar2(255),
+ "ICALENDAR_TYPE" nvarchar2(255),
+ "ATTACHMENTS_MODE" integer default 0 not null,
+ "DROPBOX_ID" nvarchar2(255),
+ "ORGANIZER" nvarchar2(255),
+ "RECURRANCE_MIN" date,
+ "RECURRANCE_MAX" date,
+ "ACCESS" integer default 0 not null,
+ "SCHEDULE_OBJECT" integer default 0,
+ "SCHEDULE_TAG" nvarchar2(36) default null,
+ "SCHEDULE_ETAGS" nclob default null,
+ "PRIVATE_COMMENTS" integer default 0 not null,
+ "MD5" nchar(32),
+ "CREATED" timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+ "MODIFIED" timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+ unique ("CALENDAR_RESOURCE_ID", "RESOURCE_NAME")
+);
+
+create table CALENDAR_OBJ_ATTACHMENTS_MODE (
+ "ID" integer primary key,
+ "DESCRIPTION" nvarchar2(16) unique
+);
+
+insert into CALENDAR_OBJ_ATTACHMENTS_MODE (DESCRIPTION, ID) values ('none', 0);
+insert into CALENDAR_OBJ_ATTACHMENTS_MODE (DESCRIPTION, ID) values ('read', 1);
+insert into CALENDAR_OBJ_ATTACHMENTS_MODE (DESCRIPTION, ID) values ('write', 2);
+create table CALENDAR_ACCESS_TYPE (
+ "ID" integer primary key,
+ "DESCRIPTION" nvarchar2(32) unique
+);
+
+insert into CALENDAR_ACCESS_TYPE (DESCRIPTION, ID) values ('', 0);
+insert into CALENDAR_ACCESS_TYPE (DESCRIPTION, ID) values ('public', 1);
+insert into CALENDAR_ACCESS_TYPE (DESCRIPTION, ID) values ('private', 2);
+insert into CALENDAR_ACCESS_TYPE (DESCRIPTION, ID) values ('confidential', 3);
+insert into CALENDAR_ACCESS_TYPE (DESCRIPTION, ID) values ('restricted', 4);
+create table TIME_RANGE (
+ "INSTANCE_ID" integer primary key,
+ "CALENDAR_RESOURCE_ID" integer not null references CALENDAR on delete cascade,
+ "CALENDAR_OBJECT_RESOURCE_ID" integer not null references CALENDAR_OBJECT on delete cascade,
+ "FLOATING" integer not null,
+ "START_DATE" timestamp not null,
+ "END_DATE" timestamp not null,
+ "FBTYPE" integer not null,
+ "TRANSPARENT" integer not null
+);
+
+create table FREE_BUSY_TYPE (
+ "ID" integer primary key,
+ "DESCRIPTION" nvarchar2(16) unique
+);
+
+insert into FREE_BUSY_TYPE (DESCRIPTION, ID) values ('unknown', 0);
+insert into FREE_BUSY_TYPE (DESCRIPTION, ID) values ('free', 1);
+insert into FREE_BUSY_TYPE (DESCRIPTION, ID) values ('busy', 2);
+insert into FREE_BUSY_TYPE (DESCRIPTION, ID) values ('busy-unavailable', 3);
+insert into FREE_BUSY_TYPE (DESCRIPTION, ID) values ('busy-tentative', 4);
+create table PERUSER (
+ "TIME_RANGE_INSTANCE_ID" integer not null references TIME_RANGE on delete cascade,
+ "USER_ID" nvarchar2(255),
+ "TRANSPARENT" integer not null,
+ "ADJUSTED_START_DATE" timestamp default null,
+ "ADJUSTED_END_DATE" timestamp default null
+);
+
+create table ATTACHMENT (
+ "ATTACHMENT_ID" integer primary key,
+ "CALENDAR_HOME_RESOURCE_ID" integer not null references CALENDAR_HOME,
+ "DROPBOX_ID" nvarchar2(255),
+ "CONTENT_TYPE" nvarchar2(255),
+ "SIZE" integer not null,
+ "MD5" nchar(32),
+ "CREATED" timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+ "MODIFIED" timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+ "PATH" nvarchar2(1024)
+);
+
+create table ATTACHMENT_CALENDAR_OBJECT (
+ "ATTACHMENT_ID" integer not null references ATTACHMENT on delete cascade,
+ "MANAGED_ID" nvarchar2(255),
+ "CALENDAR_OBJECT_RESOURCE_ID" integer not null references CALENDAR_OBJECT on delete cascade,
+ primary key ("ATTACHMENT_ID", "CALENDAR_OBJECT_RESOURCE_ID"),
+ unique ("MANAGED_ID", "CALENDAR_OBJECT_RESOURCE_ID")
+);
+
+create table RESOURCE_PROPERTY (
+ "RESOURCE_ID" integer not null,
+ "NAME" nvarchar2(255),
+ "VALUE" nclob,
+ "VIEWER_UID" nvarchar2(255),
+ primary key ("RESOURCE_ID", "NAME", "VIEWER_UID")
+);
+
+create table ADDRESSBOOK_HOME (
+ "RESOURCE_ID" integer primary key,
+ "ADDRESSBOOK_PROPERTY_STORE_ID" integer not null,
+ "OWNER_UID" nvarchar2(255) unique,
+ "STATUS" integer default 0 not null,
+ "DATAVERSION" integer default 0 not null
+);
+
+create table ADDRESSBOOK_HOME_METADATA (
+ "RESOURCE_ID" integer primary key references ADDRESSBOOK_HOME on delete cascade,
+ "QUOTA_USED_BYTES" integer default 0 not null,
+ "CREATED" timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+ "MODIFIED" timestamp default CURRENT_TIMESTAMP at time zone 'UTC'
+);
+
+create table SHARED_ADDRESSBOOK_BIND (
+ "ADDRESSBOOK_HOME_RESOURCE_ID" integer not null references ADDRESSBOOK_HOME,
+ "OWNER_HOME_RESOURCE_ID" integer not null references ADDRESSBOOK_HOME on delete cascade,
+ "EXTERNAL_ID" integer default null,
+ "ADDRESSBOOK_RESOURCE_NAME" nvarchar2(255),
+ "BIND_MODE" integer not null,
+ "BIND_STATUS" integer not null,
+ "BIND_REVISION" integer default 0 not null,
+ "MESSAGE" nclob,
+ primary key ("ADDRESSBOOK_HOME_RESOURCE_ID", "OWNER_HOME_RESOURCE_ID"),
+ unique ("ADDRESSBOOK_HOME_RESOURCE_ID", "ADDRESSBOOK_RESOURCE_NAME")
+);
+
+create table ADDRESSBOOK_OBJECT (
+ "RESOURCE_ID" integer primary key,
+ "ADDRESSBOOK_HOME_RESOURCE_ID" integer not null references ADDRESSBOOK_HOME on delete cascade,
+ "RESOURCE_NAME" nvarchar2(255),
+ "VCARD_TEXT" nclob,
+ "VCARD_UID" nvarchar2(255),
+ "KIND" integer not null,
+ "MD5" nchar(32),
+ "CREATED" timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+ "MODIFIED" timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+ unique ("ADDRESSBOOK_HOME_RESOURCE_ID", "RESOURCE_NAME"),
+ unique ("ADDRESSBOOK_HOME_RESOURCE_ID", "VCARD_UID")
+);
+
+create table ADDRESSBOOK_OBJECT_KIND (
+ "ID" integer primary key,
+ "DESCRIPTION" nvarchar2(16) unique
+);
+
+insert into ADDRESSBOOK_OBJECT_KIND (DESCRIPTION, ID) values ('person', 0);
+insert into ADDRESSBOOK_OBJECT_KIND (DESCRIPTION, ID) values ('group', 1);
+insert into ADDRESSBOOK_OBJECT_KIND (DESCRIPTION, ID) values ('resource', 2);
+insert into ADDRESSBOOK_OBJECT_KIND (DESCRIPTION, ID) values ('location', 3);
+create table ABO_MEMBERS (
+ "GROUP_ID" integer not null,
+ "ADDRESSBOOK_ID" integer not null references ADDRESSBOOK_HOME on delete cascade,
+ "MEMBER_ID" integer not null,
+ "REVISION" integer not null,
+ "REMOVED" integer default 0 not null,
+ "MODIFIED" timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+ primary key ("GROUP_ID", "MEMBER_ID", "REVISION")
+);
+
+create table ABO_FOREIGN_MEMBERS (
+ "GROUP_ID" integer not null references ADDRESSBOOK_OBJECT on delete cascade,
+ "ADDRESSBOOK_ID" integer not null references ADDRESSBOOK_HOME on delete cascade,
+ "MEMBER_ADDRESS" nvarchar2(255),
+ primary key ("GROUP_ID", "MEMBER_ADDRESS")
+);
+
+create table SHARED_GROUP_BIND (
+ "ADDRESSBOOK_HOME_RESOURCE_ID" integer not null references ADDRESSBOOK_HOME,
+ "GROUP_RESOURCE_ID" integer not null references ADDRESSBOOK_OBJECT on delete cascade,
+ "EXTERNAL_ID" integer default null,
+ "GROUP_ADDRESSBOOK_NAME" nvarchar2(255),
+ "BIND_MODE" integer not null,
+ "BIND_STATUS" integer not null,
+ "BIND_REVISION" integer default 0 not null,
+ "MESSAGE" nclob,
+ primary key ("ADDRESSBOOK_HOME_RESOURCE_ID", "GROUP_RESOURCE_ID"),
+ unique ("ADDRESSBOOK_HOME_RESOURCE_ID", "GROUP_ADDRESSBOOK_NAME")
+);
+
+create table CALENDAR_OBJECT_REVISIONS (
+ "CALENDAR_HOME_RESOURCE_ID" integer not null references CALENDAR_HOME,
+ "CALENDAR_RESOURCE_ID" integer references CALENDAR,
+ "CALENDAR_NAME" nvarchar2(255) default null,
+ "RESOURCE_NAME" nvarchar2(255),
+ "REVISION" integer not null,
+ "DELETED" integer not null,
+ "MODIFIED" timestamp default CURRENT_TIMESTAMP at time zone 'UTC'
+);
+
+create table ADDRESSBOOK_OBJECT_REVISIONS (
+ "ADDRESSBOOK_HOME_RESOURCE_ID" integer not null references ADDRESSBOOK_HOME,
+ "OWNER_HOME_RESOURCE_ID" integer references ADDRESSBOOK_HOME,
+ "ADDRESSBOOK_NAME" nvarchar2(255) default null,
+ "OBJECT_RESOURCE_ID" integer default 0,
+ "RESOURCE_NAME" nvarchar2(255),
+ "REVISION" integer not null,
+ "DELETED" integer not null,
+ "MODIFIED" timestamp default CURRENT_TIMESTAMP at time zone 'UTC'
+);
+
+create table NOTIFICATION_OBJECT_REVISIONS (
+ "NOTIFICATION_HOME_RESOURCE_ID" integer not null references NOTIFICATION_HOME on delete cascade,
+ "RESOURCE_NAME" nvarchar2(255),
+ "REVISION" integer not null,
+ "DELETED" integer not null,
+ "MODIFIED" timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+ unique ("NOTIFICATION_HOME_RESOURCE_ID", "RESOURCE_NAME")
+);
+
+create table APN_SUBSCRIPTIONS (
+ "TOKEN" nvarchar2(255),
+ "RESOURCE_KEY" nvarchar2(255),
+ "MODIFIED" integer not null,
+ "SUBSCRIBER_GUID" nvarchar2(255),
+ "USER_AGENT" nvarchar2(255) default null,
+ "IP_ADDR" nvarchar2(255) default null,
+ primary key ("TOKEN", "RESOURCE_KEY")
+);
+
+create table IMIP_TOKENS (
+ "TOKEN" nvarchar2(255),
+ "ORGANIZER" nvarchar2(255),
+ "ATTENDEE" nvarchar2(255),
+ "ICALUID" nvarchar2(255),
+ "ACCESSED" timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+ primary key ("ORGANIZER", "ATTENDEE", "ICALUID")
+);
+
+create table IMIP_INVITATION_WORK (
+ "WORK_ID" integer primary key not null,
+ "JOB_ID" integer not null references JOB,
+ "FROM_ADDR" nvarchar2(255),
+ "TO_ADDR" nvarchar2(255),
+ "ICALENDAR_TEXT" nclob
+);
+
+create table IMIP_POLLING_WORK (
+ "WORK_ID" integer primary key not null,
+ "JOB_ID" integer not null references JOB
+);
+
+create table IMIP_REPLY_WORK (
+ "WORK_ID" integer primary key not null,
+ "JOB_ID" integer not null references JOB,
+ "ORGANIZER" nvarchar2(255),
+ "ATTENDEE" nvarchar2(255),
+ "ICALENDAR_TEXT" nclob
+);
+
+create table PUSH_NOTIFICATION_WORK (
+ "WORK_ID" integer primary key not null,
+ "JOB_ID" integer not null references JOB,
+ "PUSH_ID" nvarchar2(255),
+ "PUSH_PRIORITY" integer not null
+);
+
+create table GROUP_CACHER_POLLING_WORK (
+ "WORK_ID" integer primary key not null,
+ "JOB_ID" integer not null references JOB
+);
+
+create table GROUP_REFRESH_WORK (
+ "WORK_ID" integer primary key not null,
+ "JOB_ID" integer not null references JOB,
+ "GROUP_UID" nvarchar2(255)
+);
+
+create table GROUP_ATTENDEE_RECONCILE_WORK (
+ "WORK_ID" integer primary key not null,
+ "JOB_ID" integer not null references JOB,
+ "RESOURCE_ID" integer,
+ "GROUP_ID" integer
+);
+
+create table GROUPS (
+ "GROUP_ID" integer primary key,
+ "NAME" nvarchar2(255),
+ "GROUP_UID" nvarchar2(255),
+ "MEMBERSHIP_HASH" nvarchar2(255),
+ "EXTANT" integer default 1,
+ "CREATED" timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+ "MODIFIED" timestamp default CURRENT_TIMESTAMP at time zone 'UTC'
+);
+
+create table GROUP_MEMBERSHIP (
+ "GROUP_ID" integer not null references GROUPS on delete cascade,
+ "MEMBER_UID" nvarchar2(255),
+ primary key ("GROUP_ID", "MEMBER_UID")
+);
+
+create table GROUP_ATTENDEE (
+ "GROUP_ID" integer not null references GROUPS on delete cascade,
+ "RESOURCE_ID" integer not null references CALENDAR_OBJECT on delete cascade,
+ "MEMBERSHIP_HASH" nvarchar2(255),
+ primary key ("GROUP_ID", "RESOURCE_ID")
+);
+
+create table DELEGATES (
+ "DELEGATOR" nvarchar2(255),
+ "DELEGATE" nvarchar2(255),
+ "READ_WRITE" integer not null,
+ primary key ("DELEGATOR", "READ_WRITE", "DELEGATE")
+);
+
+create table DELEGATE_GROUPS (
+ "DELEGATOR" nvarchar2(255),
+ "GROUP_ID" integer not null references GROUPS on delete cascade,
+ "READ_WRITE" integer not null,
+ "IS_EXTERNAL" integer not null,
+ primary key ("DELEGATOR", "READ_WRITE", "GROUP_ID")
+);
+
+create table EXTERNAL_DELEGATE_GROUPS (
+ "DELEGATOR" nvarchar2(255) primary key,
+ "GROUP_UID_READ" nvarchar2(255),
+ "GROUP_UID_WRITE" nvarchar2(255)
+);
+
+create table CALENDAR_OBJECT_SPLITTER_WORK (
+ "WORK_ID" integer primary key not null,
+ "JOB_ID" integer not null references JOB,
+ "RESOURCE_ID" integer not null references CALENDAR_OBJECT on delete cascade
+);
+
+create table FIND_MIN_VALID_REVISION_WORK (
+ "WORK_ID" integer primary key not null,
+ "JOB_ID" integer not null references JOB
+);
+
+create table REVISION_CLEANUP_WORK (
+ "WORK_ID" integer primary key not null,
+ "JOB_ID" integer not null references JOB
+);
+
+create table INBOX_CLEANUP_WORK (
+ "WORK_ID" integer primary key not null,
+ "JOB_ID" integer not null references JOB
+);
+
+create table CLEANUP_ONE_INBOX_WORK (
+ "WORK_ID" integer primary key not null,
+ "JOB_ID" integer not null references JOB,
+ "HOME_ID" integer not null unique references CALENDAR_HOME on delete cascade
+);
+
+create table SCHEDULE_REFRESH_WORK (
+ "WORK_ID" integer primary key not null,
+ "JOB_ID" integer not null references JOB,
+ "ICALENDAR_UID" nvarchar2(255),
+ "HOME_RESOURCE_ID" integer not null references CALENDAR_HOME on delete cascade,
+ "RESOURCE_ID" integer not null references CALENDAR_OBJECT on delete cascade,
+ "ATTENDEE_COUNT" integer
+);
+
+create table SCHEDULE_REFRESH_ATTENDEES (
+ "RESOURCE_ID" integer not null references CALENDAR_OBJECT on delete cascade,
+ "ATTENDEE" nvarchar2(255),
+ primary key ("RESOURCE_ID", "ATTENDEE")
+);
+
+create table SCHEDULE_AUTO_REPLY_WORK (
+ "WORK_ID" integer primary key not null,
+ "JOB_ID" integer not null references JOB,
+ "ICALENDAR_UID" nvarchar2(255),
+ "HOME_RESOURCE_ID" integer not null references CALENDAR_HOME on delete cascade,
+ "RESOURCE_ID" integer not null references CALENDAR_OBJECT on delete cascade,
+ "PARTSTAT" nvarchar2(255)
+);
+
+create table SCHEDULE_ORGANIZER_WORK (
+ "WORK_ID" integer primary key not null,
+ "JOB_ID" integer not null references JOB,
+ "ICALENDAR_UID" nvarchar2(255),
+ "SCHEDULE_ACTION" integer not null,
+ "HOME_RESOURCE_ID" integer not null references CALENDAR_HOME on delete cascade,
+ "RESOURCE_ID" integer,
+ "ICALENDAR_TEXT_OLD" nclob,
+ "ICALENDAR_TEXT_NEW" nclob,
+ "ATTENDEE_COUNT" integer,
+ "SMART_MERGE" integer
+);
+
+create table SCHEDULE_ACTION (
+ "ID" integer primary key,
+ "DESCRIPTION" nvarchar2(16) unique
+);
+
+insert into SCHEDULE_ACTION (DESCRIPTION, ID) values ('create', 0);
+insert into SCHEDULE_ACTION (DESCRIPTION, ID) values ('modify', 1);
+insert into SCHEDULE_ACTION (DESCRIPTION, ID) values ('modify-cancelled', 2);
+insert into SCHEDULE_ACTION (DESCRIPTION, ID) values ('remove', 3);
+create table SCHEDULE_REPLY_WORK (
+ "WORK_ID" integer primary key not null,
+ "JOB_ID" integer not null references JOB,
+ "ICALENDAR_UID" nvarchar2(255),
+ "HOME_RESOURCE_ID" integer not null references CALENDAR_HOME on delete cascade,
+ "RESOURCE_ID" integer not null references CALENDAR_OBJECT on delete cascade,
+ "CHANGED_RIDS" nclob
+);
+
+create table SCHEDULE_REPLY_CANCEL_WORK (
+ "WORK_ID" integer primary key not null,
+ "JOB_ID" integer not null references JOB,
+ "ICALENDAR_UID" nvarchar2(255),
+ "HOME_RESOURCE_ID" integer not null references CALENDAR_HOME on delete cascade,
+ "ICALENDAR_TEXT" nclob
+);
+
+create table PRINCIPAL_PURGE_POLLING_WORK (
+ "WORK_ID" integer primary key not null,
+ "JOB_ID" integer not null references JOB
+);
+
+create table PRINCIPAL_PURGE_CHECK_WORK (
+ "WORK_ID" integer primary key not null,
+ "JOB_ID" integer not null references JOB,
+ "UID" nvarchar2(255)
+);
+
+create table PRINCIPAL_PURGE_WORK (
+ "WORK_ID" integer primary key not null,
+ "JOB_ID" integer not null references JOB,
+ "UID" nvarchar2(255)
+);
+
+create table PRINCIPAL_PURGE_HOME_WORK (
+ "WORK_ID" integer primary key not null,
+ "JOB_ID" integer not null references JOB,
+ "HOME_RESOURCE_ID" integer not null references CALENDAR_HOME on delete cascade
+);
+
+create table CALENDARSERVER (
+ "NAME" nvarchar2(255) primary key,
+ "VALUE" nvarchar2(255)
+);
+
+insert into CALENDARSERVER (NAME, VALUE) values ('VERSION', '41');
+insert into CALENDARSERVER (NAME, VALUE) values ('CALENDAR-DATAVERSION', '6');
+insert into CALENDARSERVER (NAME, VALUE) values ('ADDRESSBOOK-DATAVERSION', '2');
+insert into CALENDARSERVER (NAME, VALUE) values ('NOTIFICATION-DATAVERSION', '1');
+insert into CALENDARSERVER (NAME, VALUE) values ('MIN-VALID-REVISION', '1');
+create index CALENDAR_HOME_METADAT_3cb9049e on CALENDAR_HOME_METADATA (
+ DEFAULT_EVENTS
+);
+
+create index CALENDAR_HOME_METADAT_d55e5548 on CALENDAR_HOME_METADATA (
+ DEFAULT_TASKS
+);
+
+create index CALENDAR_HOME_METADAT_910264ce on CALENDAR_HOME_METADATA (
+ DEFAULT_POLLS
+);
+
+create index NOTIFICATION_NOTIFICA_f891f5f9 on NOTIFICATION (
+ NOTIFICATION_HOME_RESOURCE_ID
+);
+
+create index CALENDAR_BIND_RESOURC_e57964d4 on CALENDAR_BIND (
+ CALENDAR_RESOURCE_ID
+);
+
+create index CALENDAR_OBJECT_CALEN_a9a453a9 on CALENDAR_OBJECT (
+ CALENDAR_RESOURCE_ID,
+ ICALENDAR_UID
+);
+
+create index CALENDAR_OBJECT_CALEN_96e83b73 on CALENDAR_OBJECT (
+ CALENDAR_RESOURCE_ID,
+ RECURRANCE_MAX
+);
+
+create index CALENDAR_OBJECT_ICALE_82e731d5 on CALENDAR_OBJECT (
+ ICALENDAR_UID
+);
+
+create index CALENDAR_OBJECT_DROPB_de041d80 on CALENDAR_OBJECT (
+ DROPBOX_ID
+);
+
+create index TIME_RANGE_CALENDAR_R_beb6e7eb on TIME_RANGE (
+ CALENDAR_RESOURCE_ID
+);
+
+create index TIME_RANGE_CALENDAR_O_acf37bd1 on TIME_RANGE (
+ CALENDAR_OBJECT_RESOURCE_ID
+);
+
+create index PERUSER_TIME_RANGE_IN_5468a226 on PERUSER (
+ TIME_RANGE_INSTANCE_ID
+);
+
+create index ATTACHMENT_CALENDAR_H_0078845c on ATTACHMENT (
+ CALENDAR_HOME_RESOURCE_ID
+);
+
+create index ATTACHMENT_DROPBOX_ID_5073cf23 on ATTACHMENT (
+ DROPBOX_ID
+);
+
+create index ATTACHMENT_CALENDAR_O_81508484 on ATTACHMENT_CALENDAR_OBJECT (
+ CALENDAR_OBJECT_RESOURCE_ID
+);
+
+create index SHARED_ADDRESSBOOK_BI_e9a2e6d4 on SHARED_ADDRESSBOOK_BIND (
+ OWNER_HOME_RESOURCE_ID
+);
+
+create index ABO_MEMBERS_ADDRESSBO_4effa879 on ABO_MEMBERS (
+ ADDRESSBOOK_ID
+);
+
+create index ABO_MEMBERS_MEMBER_ID_8d66adcf on ABO_MEMBERS (
+ MEMBER_ID
+);
+
+create index ABO_FOREIGN_MEMBERS_A_1fd2c5e9 on ABO_FOREIGN_MEMBERS (
+ ADDRESSBOOK_ID
+);
+
+create index SHARED_GROUP_BIND_RES_cf52f95d on SHARED_GROUP_BIND (
+ GROUP_RESOURCE_ID
+);
+
+create index CALENDAR_OBJECT_REVIS_3a3956c4 on CALENDAR_OBJECT_REVISIONS (
+ CALENDAR_HOME_RESOURCE_ID,
+ CALENDAR_RESOURCE_ID
+);
+
+create index CALENDAR_OBJECT_REVIS_6d9d929c on CALENDAR_OBJECT_REVISIONS (
+ CALENDAR_RESOURCE_ID,
+ RESOURCE_NAME,
+ DELETED,
+ REVISION
+);
+
+create index CALENDAR_OBJECT_REVIS_265c8acf on CALENDAR_OBJECT_REVISIONS (
+ CALENDAR_RESOURCE_ID,
+ REVISION
+);
+
+create index ADDRESSBOOK_OBJECT_RE_2bfcf757 on ADDRESSBOOK_OBJECT_REVISIONS (
+ ADDRESSBOOK_HOME_RESOURCE_ID,
+ OWNER_HOME_RESOURCE_ID
+);
+
+create index ADDRESSBOOK_OBJECT_RE_00fe8288 on ADDRESSBOOK_OBJECT_REVISIONS (
+ OWNER_HOME_RESOURCE_ID,
+ RESOURCE_NAME,
+ DELETED,
+ REVISION
+);
+
+create index ADDRESSBOOK_OBJECT_RE_45004780 on ADDRESSBOOK_OBJECT_REVISIONS (
+ OWNER_HOME_RESOURCE_ID,
+ REVISION
+);
+
+create index NOTIFICATION_OBJECT_R_036a9cee on NOTIFICATION_OBJECT_REVISIONS (
+ NOTIFICATION_HOME_RESOURCE_ID,
+ REVISION
+);
+
+create index APN_SUBSCRIPTIONS_RES_9610d78e on APN_SUBSCRIPTIONS (
+ RESOURCE_KEY
+);
+
+create index IMIP_TOKENS_TOKEN_e94b918f on IMIP_TOKENS (
+ TOKEN
+);
+
+create index IMIP_INVITATION_WORK__586d064c on IMIP_INVITATION_WORK (
+ JOB_ID
+);
+
+create index IMIP_POLLING_WORK_JOB_d5535891 on IMIP_POLLING_WORK (
+ JOB_ID
+);
+
+create index IMIP_REPLY_WORK_JOB_I_bf4ae73e on IMIP_REPLY_WORK (
+ JOB_ID
+);
+
+create index PUSH_NOTIFICATION_WOR_8bbab117 on PUSH_NOTIFICATION_WORK (
+ JOB_ID
+);
+
+create index GROUP_CACHER_POLLING__6eb3151c on GROUP_CACHER_POLLING_WORK (
+ JOB_ID
+);
+
+create index GROUP_REFRESH_WORK_JO_717ede20 on GROUP_REFRESH_WORK (
+ JOB_ID
+);
+
+create index GROUP_ATTENDEE_RECONC_da73d3c2 on GROUP_ATTENDEE_RECONCILE_WORK (
+ JOB_ID
+);
+
+create index GROUPS_GROUP_UID_b35cce23 on GROUPS (
+ GROUP_UID
+);
+
+create index GROUP_MEMBERSHIP_MEMB_0ca508e8 on GROUP_MEMBERSHIP (
+ MEMBER_UID
+);
+
+create index GROUP_ATTENDEE_RESOUR_855124dc on GROUP_ATTENDEE (
+ RESOURCE_ID
+);
+
+create index DELEGATE_TO_DELEGATOR_5e149b11 on DELEGATES (
+ DELEGATE,
+ READ_WRITE,
+ DELEGATOR
+);
+
+create index DELEGATE_GROUPS_GROUP_25117446 on DELEGATE_GROUPS (
+ GROUP_ID
+);
+
+create index CALENDAR_OBJECT_SPLIT_af71dcda on CALENDAR_OBJECT_SPLITTER_WORK (
+ RESOURCE_ID
+);
+
+create index CALENDAR_OBJECT_SPLIT_33603b72 on CALENDAR_OBJECT_SPLITTER_WORK (
+ JOB_ID
+);
+
+create index FIND_MIN_VALID_REVISI_78d17400 on FIND_MIN_VALID_REVISION_WORK (
+ JOB_ID
+);
+
+create index REVISION_CLEANUP_WORK_eb062686 on REVISION_CLEANUP_WORK (
+ JOB_ID
+);
+
+create index INBOX_CLEANUP_WORK_JO_799132bd on INBOX_CLEANUP_WORK (
+ JOB_ID
+);
+
+create index CLEANUP_ONE_INBOX_WOR_375dac36 on CLEANUP_ONE_INBOX_WORK (
+ JOB_ID
+);
+
+create index SCHEDULE_REFRESH_WORK_26084c7b on SCHEDULE_REFRESH_WORK (
+ HOME_RESOURCE_ID
+);
+
+create index SCHEDULE_REFRESH_WORK_989efe54 on SCHEDULE_REFRESH_WORK (
+ RESOURCE_ID
+);
+
+create index SCHEDULE_REFRESH_WORK_3ffa2718 on SCHEDULE_REFRESH_WORK (
+ JOB_ID
+);
+
+create index SCHEDULE_REFRESH_ATTE_83053b91 on SCHEDULE_REFRESH_ATTENDEES (
+ RESOURCE_ID,
+ ATTENDEE
+);
+
+create index SCHEDULE_AUTO_REPLY_W_0256478d on SCHEDULE_AUTO_REPLY_WORK (
+ HOME_RESOURCE_ID
+);
+
+create index SCHEDULE_AUTO_REPLY_W_0755e754 on SCHEDULE_AUTO_REPLY_WORK (
+ RESOURCE_ID
+);
+
+create index SCHEDULE_AUTO_REPLY_W_4d7bb5a8 on SCHEDULE_AUTO_REPLY_WORK (
+ JOB_ID
+);
+
+create index SCHEDULE_ORGANIZER_WO_18ce4edd on SCHEDULE_ORGANIZER_WORK (
+ HOME_RESOURCE_ID
+);
+
+create index SCHEDULE_ORGANIZER_WO_14702035 on SCHEDULE_ORGANIZER_WORK (
+ RESOURCE_ID
+);
+
+create index SCHEDULE_ORGANIZER_WO_1e9f246d on SCHEDULE_ORGANIZER_WORK (
+ JOB_ID
+);
+
+create index SCHEDULE_REPLY_WORK_H_745af8cf on SCHEDULE_REPLY_WORK (
+ HOME_RESOURCE_ID
+);
+
+create index SCHEDULE_REPLY_WORK_R_11bd3fbb on SCHEDULE_REPLY_WORK (
+ RESOURCE_ID
+);
+
+create index SCHEDULE_REPLY_WORK_J_5913b4a4 on SCHEDULE_REPLY_WORK (
+ JOB_ID
+);
+
+create index SCHEDULE_REPLY_CANCEL_dab513ef on SCHEDULE_REPLY_CANCEL_WORK (
+ HOME_RESOURCE_ID
+);
+
+create index SCHEDULE_REPLY_CANCEL_94a0c766 on SCHEDULE_REPLY_CANCEL_WORK (
+ JOB_ID
+);
+
+create index PRINCIPAL_PURGE_POLLI_6383e68a on PRINCIPAL_PURGE_POLLING_WORK (
+ JOB_ID
+);
+
+create index PRINCIPAL_PURGE_CHECK_b0c024c1 on PRINCIPAL_PURGE_CHECK_WORK (
+ JOB_ID
+);
+
+create index PRINCIPAL_PURGE_WORK__7a8141a3 on PRINCIPAL_PURGE_WORK (
+ JOB_ID
+);
+
+create index PRINCIPAL_PURGE_HOME__f35eea7a on PRINCIPAL_PURGE_HOME_WORK (
+ JOB_ID
+);
+
+create index PRINCIPAL_PURGE_HOME__967e4480 on PRINCIPAL_PURGE_HOME_WORK (
+ HOME_RESOURCE_ID
+);
+
+-- Skipped Function next_job
+
+-- Extras
+
+create or replace function next_job return integer is
+declare
+ cursor c1 is select JOB_ID from JOB for update skip locked;
+ result integer;
+begin
+ open c1;
+ fetch c1 into result;
+ select JOB_ID from JOB where ID = result for update;
+ return result;
+end;
+/
</ins></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaoldpostgresdialectv35sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v35.sql (13472 => 13473)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v35.sql        2014-05-14 19:50:12 UTC (rev 13472)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v35.sql        2014-05-14 20:10:58 UTC (rev 13473)
</span><span class="lines">@@ -759,18 +759,24 @@
</span><span class="cx"> create table DELEGATES (
</span><span class="cx"> DELEGATOR varchar(255) not null,
</span><span class="cx"> DELEGATE varchar(255) not null,
</span><del>- READ_WRITE integer not null -- 1 = ReadWrite, 0 = ReadOnly
</del><ins>+ READ_WRITE integer not null, -- 1 = ReadWrite, 0 = ReadOnly
+
+ primary key (DELEGATOR, READ_WRITE, DELEGATE)
</ins><span class="cx"> );
</span><ins>+create index DELEGATE_TO_DELEGATOR on
+ DELEGATES(DELEGATE, READ_WRITE, DELEGATOR);
</ins><span class="cx">
</span><span class="cx"> create table DELEGATE_GROUPS (
</span><span class="cx"> DELEGATOR varchar(255) not null,
</span><span class="cx"> GROUP_ID integer not null,
</span><span class="cx"> READ_WRITE integer not null, -- 1 = ReadWrite, 0 = ReadOnly
</span><del>- IS_EXTERNAL integer not null -- 1 = ReadWrite, 0 = ReadOnly
</del><ins>+ IS_EXTERNAL integer not null, -- 1 = ReadWrite, 0 = ReadOnly
+
+ primary key (DELEGATOR, READ_WRITE, GROUP_ID)
</ins><span class="cx"> );
</span><span class="cx">
</span><span class="cx"> create table EXTERNAL_DELEGATE_GROUPS (
</span><del>- DELEGATOR varchar(255) not null,
</del><ins>+ DELEGATOR varchar(255) primary key not null,
</ins><span class="cx"> GROUP_UID_READ varchar(255),
</span><span class="cx"> GROUP_UID_WRITE varchar(255)
</span><span class="cx"> );
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaoldpostgresdialectv36sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v36.sql (13472 => 13473)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v36.sql        2014-05-14 19:50:12 UTC (rev 13472)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v36.sql        2014-05-14 20:10:58 UTC (rev 13473)
</span><span class="lines">@@ -759,18 +759,24 @@
</span><span class="cx"> create table DELEGATES (
</span><span class="cx"> DELEGATOR varchar(255) not null,
</span><span class="cx"> DELEGATE varchar(255) not null,
</span><del>- READ_WRITE integer not null -- 1 = ReadWrite, 0 = ReadOnly
</del><ins>+ READ_WRITE integer not null, -- 1 = ReadWrite, 0 = ReadOnly
+
+ primary key (DELEGATOR, READ_WRITE, DELEGATE)
</ins><span class="cx"> );
</span><ins>+create index DELEGATE_TO_DELEGATOR on
+ DELEGATES(DELEGATE, READ_WRITE, DELEGATOR);
</ins><span class="cx">
</span><span class="cx"> create table DELEGATE_GROUPS (
</span><span class="cx"> DELEGATOR varchar(255) not null,
</span><span class="cx"> GROUP_ID integer not null,
</span><span class="cx"> READ_WRITE integer not null, -- 1 = ReadWrite, 0 = ReadOnly
</span><del>- IS_EXTERNAL integer not null -- 1 = ReadWrite, 0 = ReadOnly
</del><ins>+ IS_EXTERNAL integer not null, -- 1 = ReadWrite, 0 = ReadOnly
+
+ primary key (DELEGATOR, READ_WRITE, GROUP_ID)
</ins><span class="cx"> );
</span><span class="cx">
</span><span class="cx"> create table EXTERNAL_DELEGATE_GROUPS (
</span><del>- DELEGATOR varchar(255) not null,
</del><ins>+ DELEGATOR varchar(255) primary key not null,
</ins><span class="cx"> GROUP_UID_READ varchar(255),
</span><span class="cx"> GROUP_UID_WRITE varchar(255)
</span><span class="cx"> );
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaoldpostgresdialectv41sql"></a>
<div class="addfile"><h4>Added: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v41.sql (0 => 13473)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v41.sql         (rev 0)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v41.sql        2014-05-14 20:10:58 UTC (rev 13473)
</span><span class="lines">@@ -0,0 +1,1088 @@
</span><ins>+-- -*- test-case-name: txdav.caldav.datastore.test.test_sql,txdav.carddav.datastore.test.test_sql -*-
+
+----
+-- Copyright (c) 2010-2014 Apple Inc. All rights reserved.
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+----
+
+
+-----------------
+-- Resource ID --
+-----------------
+
+create sequence RESOURCE_ID_SEQ;
+
+
+-------------------------
+-- Cluster Bookkeeping --
+-------------------------
+
+-- Information about a process connected to this database.
+
+-- Note that this must match the node info schema in twext.enterprise.queue.
+create table NODE_INFO (
+ HOSTNAME varchar(255) not null,
+ PID integer not null,
+ PORT integer not null,
+ TIME timestamp not null default timezone('UTC', CURRENT_TIMESTAMP),
+
+ primary key (HOSTNAME, PORT)
+);
+
+-- Unique named locks. This table should always be empty, but rows are
+-- temporarily created in order to prevent undesirable concurrency.
+create table NAMED_LOCK (
+ LOCK_NAME varchar(255) primary key
+);
+
+
+--------------------
+-- Jobs --
+--------------------
+
+create sequence JOB_SEQ;
+
+create table JOB (
+ JOB_ID integer primary key default nextval('JOB_SEQ') not null, --implicit index
+ WORK_TYPE varchar(255) not null,
+ PRIORITY integer default 0,
+ WEIGHT integer default 0,
+ NOT_BEFORE timestamp default null,
+ NOT_AFTER timestamp default null
+);
+
+create or replace function next_job() returns integer as $$
+declare
+ result integer;
+begin
+ select JOB_ID into result from JOB where pg_try_advisory_xact_lock(JOB_ID) limit 1 for update;
+ return result;
+end
+$$ LANGUAGE plpgsql;
+
+-------------------
+-- Calendar Home --
+-------------------
+
+create table CALENDAR_HOME (
+ RESOURCE_ID integer primary key default nextval('RESOURCE_ID_SEQ'), -- implicit index
+ OWNER_UID varchar(255) not null unique, -- implicit index
+ STATUS integer default 0 not null, -- enum HOME_STATUS
+ DATAVERSION integer default 0 not null
+);
+
+-- Enumeration of statuses
+
+create table HOME_STATUS (
+ ID integer primary key,
+ DESCRIPTION varchar(16) not null unique
+);
+
+insert into HOME_STATUS values (0, 'normal' );
+insert into HOME_STATUS values (1, 'external');
+insert into HOME_STATUS values (2, 'purging');
+
+
+--------------
+-- Calendar --
+--------------
+
+create table CALENDAR (
+ RESOURCE_ID integer primary key default nextval('RESOURCE_ID_SEQ') -- implicit index
+);
+
+
+----------------------------
+-- Calendar Home Metadata --
+----------------------------
+
+create table CALENDAR_HOME_METADATA (
+ RESOURCE_ID integer primary key references CALENDAR_HOME on delete cascade, -- implicit index
+ QUOTA_USED_BYTES integer default 0 not null,
+ DEFAULT_EVENTS integer default null references CALENDAR on delete set null,
+ DEFAULT_TASKS integer default null references CALENDAR on delete set null,
+ DEFAULT_POLLS integer default null references CALENDAR on delete set null,
+ ALARM_VEVENT_TIMED text default null,
+ ALARM_VEVENT_ALLDAY text default null,
+ ALARM_VTODO_TIMED text default null,
+ ALARM_VTODO_ALLDAY text default null,
+ AVAILABILITY text default null,
+ CREATED timestamp default timezone('UTC', CURRENT_TIMESTAMP),
+ MODIFIED timestamp default timezone('UTC', CURRENT_TIMESTAMP)
+);
+
+create index CALENDAR_HOME_METADATA_DEFAULT_EVENTS on
+ CALENDAR_HOME_METADATA(DEFAULT_EVENTS);
+create index CALENDAR_HOME_METADATA_DEFAULT_TASKS on
+ CALENDAR_HOME_METADATA(DEFAULT_TASKS);
+create index CALENDAR_HOME_METADATA_DEFAULT_POLLS on
+ CALENDAR_HOME_METADATA(DEFAULT_POLLS);
+
+
+-----------------------
+-- Calendar Metadata --
+-----------------------
+
+create table CALENDAR_METADATA (
+ RESOURCE_ID integer primary key references CALENDAR on delete cascade, -- implicit index
+ SUPPORTED_COMPONENTS varchar(255) default null,
+ CREATED timestamp default timezone('UTC', CURRENT_TIMESTAMP),
+ MODIFIED timestamp default timezone('UTC', CURRENT_TIMESTAMP)
+);
+
+
+---------------------------
+-- Sharing Notifications --
+---------------------------
+
+create table NOTIFICATION_HOME (
+ RESOURCE_ID integer primary key default nextval('RESOURCE_ID_SEQ'), -- implicit index
+ OWNER_UID varchar(255) not null unique, -- implicit index
+ STATUS integer default 0 not null, -- enum HOME_STATUS
+ DATAVERSION integer default 0 not null
+);
+
+create table NOTIFICATION (
+ RESOURCE_ID integer primary key default nextval('RESOURCE_ID_SEQ'), -- implicit index
+ NOTIFICATION_HOME_RESOURCE_ID integer not null references NOTIFICATION_HOME,
+ NOTIFICATION_UID varchar(255) not null,
+ NOTIFICATION_TYPE varchar(255) not null,
+ NOTIFICATION_DATA text not null,
+ MD5 char(32) not null,
+ CREATED timestamp default timezone('UTC', CURRENT_TIMESTAMP),
+ MODIFIED timestamp default timezone('UTC', CURRENT_TIMESTAMP),
+
+ unique (NOTIFICATION_UID, NOTIFICATION_HOME_RESOURCE_ID) -- implicit index
+);
+
+create index NOTIFICATION_NOTIFICATION_HOME_RESOURCE_ID on
+ NOTIFICATION(NOTIFICATION_HOME_RESOURCE_ID);
+
+
+-------------------
+-- Calendar Bind --
+-------------------
+
+-- Joins CALENDAR_HOME and CALENDAR
+
+create table CALENDAR_BIND (
+ CALENDAR_HOME_RESOURCE_ID integer not null references CALENDAR_HOME,
+ CALENDAR_RESOURCE_ID integer not null references CALENDAR on delete cascade,
+ EXTERNAL_ID integer default null,
+ CALENDAR_RESOURCE_NAME varchar(255) not null,
+ BIND_MODE integer not null, -- enum CALENDAR_BIND_MODE
+ BIND_STATUS integer not null, -- enum CALENDAR_BIND_STATUS
+ BIND_REVISION integer default 0 not null,
+ MESSAGE text,
+ TRANSP integer default 0 not null, -- enum CALENDAR_TRANSP
+ ALARM_VEVENT_TIMED text default null,
+ ALARM_VEVENT_ALLDAY text default null,
+ ALARM_VTODO_TIMED text default null,
+ ALARM_VTODO_ALLDAY text default null,
+ TIMEZONE text default null,
+
+ primary key (CALENDAR_HOME_RESOURCE_ID, CALENDAR_RESOURCE_ID), -- implicit index
+ unique (CALENDAR_HOME_RESOURCE_ID, CALENDAR_RESOURCE_NAME) -- implicit index
+);
+
+create index CALENDAR_BIND_RESOURCE_ID on
+ CALENDAR_BIND(CALENDAR_RESOURCE_ID);
+
+-- Enumeration of calendar bind modes
+
+create table CALENDAR_BIND_MODE (
+ ID integer primary key,
+ DESCRIPTION varchar(16) not null unique
+);
+
+insert into CALENDAR_BIND_MODE values (0, 'own' );
+insert into CALENDAR_BIND_MODE values (1, 'read' );
+insert into CALENDAR_BIND_MODE values (2, 'write');
+insert into CALENDAR_BIND_MODE values (3, 'direct');
+insert into CALENDAR_BIND_MODE values (4, 'indirect');
+
+-- Enumeration of statuses
+
+create table CALENDAR_BIND_STATUS (
+ ID integer primary key,
+ DESCRIPTION varchar(16) not null unique
+);
+
+insert into CALENDAR_BIND_STATUS values (0, 'invited' );
+insert into CALENDAR_BIND_STATUS values (1, 'accepted');
+insert into CALENDAR_BIND_STATUS values (2, 'declined');
+insert into CALENDAR_BIND_STATUS values (3, 'invalid');
+insert into CALENDAR_BIND_STATUS values (4, 'deleted');
+
+
+-- Enumeration of transparency
+
+create table CALENDAR_TRANSP (
+ ID integer primary key,
+ DESCRIPTION varchar(16) not null unique
+);
+
+insert into CALENDAR_TRANSP values (0, 'opaque' );
+insert into CALENDAR_TRANSP values (1, 'transparent');
+
+
+---------------------
+-- Calendar Object --
+---------------------
+
+create table CALENDAR_OBJECT (
+ RESOURCE_ID integer primary key default nextval('RESOURCE_ID_SEQ'), -- implicit index
+ CALENDAR_RESOURCE_ID integer not null references CALENDAR on delete cascade,
+ RESOURCE_NAME varchar(255) not null,
+ ICALENDAR_TEXT text not null,
+ ICALENDAR_UID varchar(255) not null,
+ ICALENDAR_TYPE varchar(255) not null,
+ ATTACHMENTS_MODE integer default 0 not null, -- enum CALENDAR_OBJ_ATTACHMENTS_MODE
+ DROPBOX_ID varchar(255),
+ ORGANIZER varchar(255),
+ RECURRANCE_MIN date, -- minimum date that recurrences have been expanded to.
+ RECURRANCE_MAX date, -- maximum date that recurrences have been expanded to.
+ ACCESS integer default 0 not null,
+ SCHEDULE_OBJECT boolean default false,
+ SCHEDULE_TAG varchar(36) default null,
+ SCHEDULE_ETAGS text default null,
+ PRIVATE_COMMENTS boolean default false not null,
+ MD5 char(32) not null,
+ CREATED timestamp default timezone('UTC', CURRENT_TIMESTAMP),
+ MODIFIED timestamp default timezone('UTC', CURRENT_TIMESTAMP),
+
+ unique (CALENDAR_RESOURCE_ID, RESOURCE_NAME) -- implicit index
+
+ -- since the 'inbox' is a 'calendar resource' for the purpose of storing
+ -- calendar objects, this constraint has to be selectively enforced by the
+ -- application layer.
+
+ -- unique (CALENDAR_RESOURCE_ID, ICALENDAR_UID)
+);
+
+create index CALENDAR_OBJECT_CALENDAR_RESOURCE_ID_AND_ICALENDAR_UID on
+ CALENDAR_OBJECT(CALENDAR_RESOURCE_ID, ICALENDAR_UID);
+
+create index CALENDAR_OBJECT_CALENDAR_RESOURCE_ID_RECURRANCE_MAX on
+ CALENDAR_OBJECT(CALENDAR_RESOURCE_ID, RECURRANCE_MAX);
+
+create index CALENDAR_OBJECT_ICALENDAR_UID on
+ CALENDAR_OBJECT(ICALENDAR_UID);
+
+create index CALENDAR_OBJECT_DROPBOX_ID on
+ CALENDAR_OBJECT(DROPBOX_ID);
+
+-- Enumeration of attachment modes
+
+create table CALENDAR_OBJ_ATTACHMENTS_MODE (
+ ID integer primary key,
+ DESCRIPTION varchar(16) not null unique
+);
+
+insert into CALENDAR_OBJ_ATTACHMENTS_MODE values (0, 'none' );
+insert into CALENDAR_OBJ_ATTACHMENTS_MODE values (1, 'read' );
+insert into CALENDAR_OBJ_ATTACHMENTS_MODE values (2, 'write');
+
+
+-- Enumeration of calendar access types
+
+create table CALENDAR_ACCESS_TYPE (
+ ID integer primary key,
+ DESCRIPTION varchar(32) not null unique
+);
+
+insert into CALENDAR_ACCESS_TYPE values (0, '' );
+insert into CALENDAR_ACCESS_TYPE values (1, 'public' );
+insert into CALENDAR_ACCESS_TYPE values (2, 'private' );
+insert into CALENDAR_ACCESS_TYPE values (3, 'confidential' );
+insert into CALENDAR_ACCESS_TYPE values (4, 'restricted' );
+
+
+-----------------
+-- Instance ID --
+-----------------
+
+create sequence INSTANCE_ID_SEQ;
+
+
+----------------
+-- Time Range --
+----------------
+
+create table TIME_RANGE (
+ INSTANCE_ID integer primary key default nextval('INSTANCE_ID_SEQ'), -- implicit index
+ CALENDAR_RESOURCE_ID integer not null references CALENDAR on delete cascade,
+ CALENDAR_OBJECT_RESOURCE_ID integer not null references CALENDAR_OBJECT on delete cascade,
+ FLOATING boolean not null,
+ START_DATE timestamp not null,
+ END_DATE timestamp not null,
+ FBTYPE integer not null,
+ TRANSPARENT boolean not null
+);
+
+create index TIME_RANGE_CALENDAR_RESOURCE_ID on
+ TIME_RANGE(CALENDAR_RESOURCE_ID);
+create index TIME_RANGE_CALENDAR_OBJECT_RESOURCE_ID on
+ TIME_RANGE(CALENDAR_OBJECT_RESOURCE_ID);
+
+
+-- Enumeration of free/busy types
+
+create table FREE_BUSY_TYPE (
+ ID integer primary key,
+ DESCRIPTION varchar(16) not null unique
+);
+
+insert into FREE_BUSY_TYPE values (0, 'unknown' );
+insert into FREE_BUSY_TYPE values (1, 'free' );
+insert into FREE_BUSY_TYPE values (2, 'busy' );
+insert into FREE_BUSY_TYPE values (3, 'busy-unavailable');
+insert into FREE_BUSY_TYPE values (4, 'busy-tentative' );
+
+
+-------------------
+-- Per-user data --
+-------------------
+
+create table PERUSER (
+ TIME_RANGE_INSTANCE_ID integer not null references TIME_RANGE on delete cascade,
+ USER_ID varchar(255) not null,
+ TRANSPARENT boolean not null,
+ ADJUSTED_START_DATE timestamp         default null,
+ ADJUSTED_END_DATE timestamp default null
+);
+
+create index PERUSER_TIME_RANGE_INSTANCE_ID on
+ PERUSER(TIME_RANGE_INSTANCE_ID);
+
+
+----------------
+-- Attachment --
+----------------
+
+create sequence ATTACHMENT_ID_SEQ;
+
+create table ATTACHMENT (
+ ATTACHMENT_ID integer primary key default nextval('ATTACHMENT_ID_SEQ'), -- implicit index
+ CALENDAR_HOME_RESOURCE_ID integer not null references CALENDAR_HOME,
+ DROPBOX_ID varchar(255),
+ CONTENT_TYPE varchar(255) not null,
+ SIZE integer not null,
+ MD5 char(32) not null,
+ CREATED timestamp default timezone('UTC', CURRENT_TIMESTAMP),
+ MODIFIED timestamp default timezone('UTC', CURRENT_TIMESTAMP),
+ PATH varchar(1024) not null
+);
+
+create index ATTACHMENT_CALENDAR_HOME_RESOURCE_ID on
+ ATTACHMENT(CALENDAR_HOME_RESOURCE_ID);
+
+create index ATTACHMENT_DROPBOX_ID on
+ ATTACHMENT(DROPBOX_ID);
+
+-- Many-to-many relationship between attachments and calendar objects
+create table ATTACHMENT_CALENDAR_OBJECT (
+ ATTACHMENT_ID integer not null references ATTACHMENT on delete cascade,
+ MANAGED_ID varchar(255) not null,
+ CALENDAR_OBJECT_RESOURCE_ID integer not null references CALENDAR_OBJECT on delete cascade,
+
+ primary key (ATTACHMENT_ID, CALENDAR_OBJECT_RESOURCE_ID), -- implicit index
+ unique (MANAGED_ID, CALENDAR_OBJECT_RESOURCE_ID) --implicit index
+);
+
+create index ATTACHMENT_CALENDAR_OBJECT_CALENDAR_OBJECT_RESOURCE_ID on
+ ATTACHMENT_CALENDAR_OBJECT(CALENDAR_OBJECT_RESOURCE_ID);
+
+-----------------------
+-- Resource Property --
+-----------------------
+
+create table RESOURCE_PROPERTY (
+ RESOURCE_ID integer not null, -- foreign key: *.RESOURCE_ID
+ NAME varchar(255) not null,
+ VALUE text not null, -- FIXME: xml?
+ VIEWER_UID varchar(255),
+
+ primary key (RESOURCE_ID, NAME, VIEWER_UID) -- implicit index
+);
+
+
+----------------------
+-- AddressBook Home --
+----------------------
+
+create table ADDRESSBOOK_HOME (
+ RESOURCE_ID integer primary key default nextval('RESOURCE_ID_SEQ'), -- implicit index
+ ADDRESSBOOK_PROPERTY_STORE_ID integer default nextval('RESOURCE_ID_SEQ') not null, -- implicit index
+ OWNER_UID varchar(255) not null unique, -- implicit index
+ STATUS integer default 0 not null, -- enum HOME_STATUS
+ DATAVERSION integer default 0 not null
+);
+
+
+-------------------------------
+-- AddressBook Home Metadata --
+-------------------------------
+
+create table ADDRESSBOOK_HOME_METADATA (
+ RESOURCE_ID integer primary key references ADDRESSBOOK_HOME on delete cascade, -- implicit index
+ QUOTA_USED_BYTES integer default 0 not null,
+ CREATED timestamp default timezone('UTC', CURRENT_TIMESTAMP),
+ MODIFIED timestamp default timezone('UTC', CURRENT_TIMESTAMP)
+);
+
+
+-----------------------------
+-- Shared AddressBook Bind --
+-----------------------------
+
+-- Joins sharee ADDRESSBOOK_HOME and owner ADDRESSBOOK_HOME
+
+create table SHARED_ADDRESSBOOK_BIND (
+ ADDRESSBOOK_HOME_RESOURCE_ID integer not null references ADDRESSBOOK_HOME,
+ OWNER_HOME_RESOURCE_ID integer not null references ADDRESSBOOK_HOME on delete cascade,
+ EXTERNAL_ID integer default null,
+ ADDRESSBOOK_RESOURCE_NAME varchar(255) not null,
+ BIND_MODE integer not null, -- enum CALENDAR_BIND_MODE
+ BIND_STATUS integer not null, -- enum CALENDAR_BIND_STATUS
+ BIND_REVISION integer default 0 not null,
+ MESSAGE text, -- FIXME: xml?
+
+ primary key (ADDRESSBOOK_HOME_RESOURCE_ID, OWNER_HOME_RESOURCE_ID), -- implicit index
+ unique (ADDRESSBOOK_HOME_RESOURCE_ID, ADDRESSBOOK_RESOURCE_NAME) -- implicit index
+);
+
+create index SHARED_ADDRESSBOOK_BIND_RESOURCE_ID on
+ SHARED_ADDRESSBOOK_BIND(OWNER_HOME_RESOURCE_ID);
+
+
+------------------------
+-- AddressBook Object --
+------------------------
+
+create table ADDRESSBOOK_OBJECT (
+ RESOURCE_ID integer primary key default nextval('RESOURCE_ID_SEQ'), -- implicit index
+ ADDRESSBOOK_HOME_RESOURCE_ID integer not null references ADDRESSBOOK_HOME on delete cascade,
+ RESOURCE_NAME varchar(255) not null,
+ VCARD_TEXT text not null,
+ VCARD_UID varchar(255) not null,
+ KIND integer not null, -- enum ADDRESSBOOK_OBJECT_KIND
+ MD5 char(32) not null,
+ CREATED timestamp default timezone('UTC', CURRENT_TIMESTAMP),
+ MODIFIED timestamp default timezone('UTC', CURRENT_TIMESTAMP),
+
+ unique (ADDRESSBOOK_HOME_RESOURCE_ID, RESOURCE_NAME), -- implicit index
+ unique (ADDRESSBOOK_HOME_RESOURCE_ID, VCARD_UID) -- implicit index
+);
+
+
+-----------------------------
+-- AddressBook Object kind --
+-----------------------------
+
+create table ADDRESSBOOK_OBJECT_KIND (
+ ID integer primary key,
+ DESCRIPTION varchar(16) not null unique
+);
+
+insert into ADDRESSBOOK_OBJECT_KIND values (0, 'person');
+insert into ADDRESSBOOK_OBJECT_KIND values (1, 'group' );
+insert into ADDRESSBOOK_OBJECT_KIND values (2, 'resource');
+insert into ADDRESSBOOK_OBJECT_KIND values (3, 'location');
+
+
+----------------------------------
+-- Revisions, forward reference --
+----------------------------------
+
+create sequence REVISION_SEQ;
+
+---------------------------------
+-- Address Book Object Members --
+---------------------------------
+
+create table ABO_MEMBERS (
+ GROUP_ID integer not null, -- references ADDRESSBOOK_OBJECT on delete cascade, -- AddressBook Object's (kind=='group') RESOURCE_ID
+ ADDRESSBOOK_ID integer not null references ADDRESSBOOK_HOME on delete cascade,
+ MEMBER_ID integer not null, -- references ADDRESSBOOK_OBJECT, -- member AddressBook Object's RESOURCE_ID
+ REVISION integer default nextval('REVISION_SEQ') not null,
+ REMOVED boolean default false not null,
+ MODIFIED timestamp default timezone('UTC', CURRENT_TIMESTAMP),
+
+ primary key (GROUP_ID, MEMBER_ID, REVISION) -- implicit index
+);
+
+create index ABO_MEMBERS_ADDRESSBOOK_ID on
+ ABO_MEMBERS(ADDRESSBOOK_ID);
+create index ABO_MEMBERS_MEMBER_ID on
+ ABO_MEMBERS(MEMBER_ID);
+
+------------------------------------------
+-- Address Book Object Foreign Members --
+------------------------------------------
+
+create table ABO_FOREIGN_MEMBERS (
+ GROUP_ID integer not null references ADDRESSBOOK_OBJECT on delete cascade, -- AddressBook Object's (kind=='group') RESOURCE_ID
+ ADDRESSBOOK_ID integer not null references ADDRESSBOOK_HOME on delete cascade,
+ MEMBER_ADDRESS varchar(255) not null, -- member AddressBook Object's 'calendar' address
+
+ primary key (GROUP_ID, MEMBER_ADDRESS) -- implicit index
+);
+
+create index ABO_FOREIGN_MEMBERS_ADDRESSBOOK_ID on
+ ABO_FOREIGN_MEMBERS(ADDRESSBOOK_ID);
+
+-----------------------
+-- Shared Group Bind --
+-----------------------
+
+-- Joins ADDRESSBOOK_HOME and ADDRESSBOOK_OBJECT (kind == group)
+
+create table SHARED_GROUP_BIND (
+ ADDRESSBOOK_HOME_RESOURCE_ID integer not null references ADDRESSBOOK_HOME,
+ GROUP_RESOURCE_ID integer not null references ADDRESSBOOK_OBJECT on delete cascade,
+ EXTERNAL_ID integer default null,
+ GROUP_ADDRESSBOOK_NAME varchar(255) not null,
+ BIND_MODE integer not null, -- enum CALENDAR_BIND_MODE
+ BIND_STATUS integer not null, -- enum CALENDAR_BIND_STATUS
+ BIND_REVISION integer default 0 not null,
+ MESSAGE text, -- FIXME: xml?
+
+ primary key (ADDRESSBOOK_HOME_RESOURCE_ID, GROUP_RESOURCE_ID), -- implicit index
+ unique (ADDRESSBOOK_HOME_RESOURCE_ID, GROUP_ADDRESSBOOK_NAME) -- implicit index
+);
+
+create index SHARED_GROUP_BIND_RESOURCE_ID on
+ SHARED_GROUP_BIND(GROUP_RESOURCE_ID);
+
+
+---------------
+-- Revisions --
+---------------
+
+-- create sequence REVISION_SEQ;
+
+
+-------------------------------
+-- Calendar Object Revisions --
+-------------------------------
+
+create table CALENDAR_OBJECT_REVISIONS (
+ CALENDAR_HOME_RESOURCE_ID integer not null references CALENDAR_HOME,
+ CALENDAR_RESOURCE_ID integer references CALENDAR,
+ CALENDAR_NAME varchar(255) default null,
+ RESOURCE_NAME varchar(255),
+ REVISION integer default nextval('REVISION_SEQ') not null,
+ DELETED boolean not null,
+ MODIFIED timestamp default timezone('UTC', CURRENT_TIMESTAMP)
+);
+
+create index CALENDAR_OBJECT_REVISIONS_HOME_RESOURCE_ID_CALENDAR_RESOURCE_ID
+ on CALENDAR_OBJECT_REVISIONS(CALENDAR_HOME_RESOURCE_ID, CALENDAR_RESOURCE_ID);
+
+create index CALENDAR_OBJECT_REVISIONS_RESOURCE_ID_RESOURCE_NAME_DELETED_REVISION
+ on CALENDAR_OBJECT_REVISIONS(CALENDAR_RESOURCE_ID, RESOURCE_NAME, DELETED, REVISION);
+
+create index CALENDAR_OBJECT_REVISIONS_RESOURCE_ID_REVISION
+ on CALENDAR_OBJECT_REVISIONS(CALENDAR_RESOURCE_ID, REVISION);
+
+
+----------------------------------
+-- AddressBook Object Revisions --
+----------------------------------
+
+create table ADDRESSBOOK_OBJECT_REVISIONS (
+ ADDRESSBOOK_HOME_RESOURCE_ID integer not null references ADDRESSBOOK_HOME,
+ OWNER_HOME_RESOURCE_ID integer references ADDRESSBOOK_HOME,
+ ADDRESSBOOK_NAME varchar(255) default null,
+ OBJECT_RESOURCE_ID integer default 0,
+ RESOURCE_NAME varchar(255),
+ REVISION integer default nextval('REVISION_SEQ') not null,
+ DELETED boolean not null,
+ MODIFIED timestamp default timezone('UTC', CURRENT_TIMESTAMP)
+);
+
+create index ADDRESSBOOK_OBJECT_REVISIONS_HOME_RESOURCE_ID_OWNER_HOME_RESOURCE_ID
+ on ADDRESSBOOK_OBJECT_REVISIONS(ADDRESSBOOK_HOME_RESOURCE_ID, OWNER_HOME_RESOURCE_ID);
+
+create index ADDRESSBOOK_OBJECT_REVISIONS_OWNER_HOME_RESOURCE_ID_RESOURCE_NAME_DELETED_REVISION
+ on ADDRESSBOOK_OBJECT_REVISIONS(OWNER_HOME_RESOURCE_ID, RESOURCE_NAME, DELETED, REVISION);
+
+create index ADDRESSBOOK_OBJECT_REVISIONS_OWNER_HOME_RESOURCE_ID_REVISION
+ on ADDRESSBOOK_OBJECT_REVISIONS(OWNER_HOME_RESOURCE_ID, REVISION);
+
+
+-----------------------------------
+-- Notification Object Revisions --
+-----------------------------------
+
+create table NOTIFICATION_OBJECT_REVISIONS (
+ NOTIFICATION_HOME_RESOURCE_ID integer not null references NOTIFICATION_HOME on delete cascade,
+ RESOURCE_NAME varchar(255),
+ REVISION integer default nextval('REVISION_SEQ') not null,
+ DELETED boolean not null,
+ MODIFIED timestamp default timezone('UTC', CURRENT_TIMESTAMP),
+
+ unique (NOTIFICATION_HOME_RESOURCE_ID, RESOURCE_NAME) -- implicit index
+);
+
+create index NOTIFICATION_OBJECT_REVISIONS_RESOURCE_ID_REVISION
+ on NOTIFICATION_OBJECT_REVISIONS(NOTIFICATION_HOME_RESOURCE_ID, REVISION);
+
+
+-------------------------------------------
+-- Apple Push Notification Subscriptions --
+-------------------------------------------
+
+create table APN_SUBSCRIPTIONS (
+ TOKEN varchar(255) not null,
+ RESOURCE_KEY varchar(255) not null,
+ MODIFIED integer not null,
+ SUBSCRIBER_GUID varchar(255) not null,
+ USER_AGENT varchar(255) default null,
+ IP_ADDR varchar(255) default null,
+
+ primary key (TOKEN, RESOURCE_KEY) -- implicit index
+);
+
+create index APN_SUBSCRIPTIONS_RESOURCE_KEY
+ on APN_SUBSCRIPTIONS(RESOURCE_KEY);
+
+
+-----------------
+-- IMIP Tokens --
+-----------------
+
+create table IMIP_TOKENS (
+ TOKEN varchar(255) not null,
+ ORGANIZER varchar(255) not null,
+ ATTENDEE varchar(255) not null,
+ ICALUID varchar(255) not null,
+ ACCESSED timestamp default timezone('UTC', CURRENT_TIMESTAMP),
+
+ primary key (ORGANIZER, ATTENDEE, ICALUID) -- implicit index
+);
+
+create index IMIP_TOKENS_TOKEN
+ on IMIP_TOKENS(TOKEN);
+
+
+----------------
+-- Work Items --
+----------------
+
+create sequence WORKITEM_SEQ;
+
+
+---------------------------
+-- IMIP Inivitation Work --
+---------------------------
+
+create table IMIP_INVITATION_WORK (
+ WORK_ID integer primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+ JOB_ID integer references JOB not null,
+ FROM_ADDR varchar(255) not null,
+ TO_ADDR varchar(255) not null,
+ ICALENDAR_TEXT text not null
+);
+
+create index IMIP_INVITATION_WORK_JOB_ID on
+ IMIP_INVITATION_WORK(JOB_ID);
+
+-----------------------
+-- IMIP Polling Work --
+-----------------------
+
+create table IMIP_POLLING_WORK (
+ WORK_ID integer primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+ JOB_ID integer references JOB not null
+);
+
+create index IMIP_POLLING_WORK_JOB_ID on
+ IMIP_POLLING_WORK(JOB_ID);
+
+
+---------------------
+-- IMIP Reply Work --
+---------------------
+
+create table IMIP_REPLY_WORK (
+ WORK_ID integer primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+ JOB_ID integer references JOB not null,
+ ORGANIZER varchar(255) not null,
+ ATTENDEE varchar(255) not null,
+ ICALENDAR_TEXT text not null
+);
+
+create index IMIP_REPLY_WORK_JOB_ID on
+ IMIP_REPLY_WORK(JOB_ID);
+
+
+------------------------
+-- Push Notifications --
+------------------------
+
+create table PUSH_NOTIFICATION_WORK (
+ WORK_ID integer primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+ JOB_ID integer references JOB not null,
+ PUSH_ID varchar(255) not null,
+ PUSH_PRIORITY integer not null -- 1:low 5:medium 10:high
+);
+
+create index PUSH_NOTIFICATION_WORK_JOB_ID on
+ PUSH_NOTIFICATION_WORK(JOB_ID);
+
+-----------------
+-- GroupCacher --
+-----------------
+
+create table GROUP_CACHER_POLLING_WORK (
+ WORK_ID integer primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+ JOB_ID integer references JOB not null
+);
+
+create index GROUP_CACHER_POLLING_WORK_JOB_ID on
+ GROUP_CACHER_POLLING_WORK(JOB_ID);
+
+create table GROUP_REFRESH_WORK (
+ WORK_ID integer primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+ JOB_ID integer references JOB not null,
+ GROUP_UID varchar(255) not null
+);
+
+create index GROUP_REFRESH_WORK_JOB_ID on
+ GROUP_REFRESH_WORK(JOB_ID);
+
+create table GROUP_ATTENDEE_RECONCILE_WORK (
+ WORK_ID integer primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+ JOB_ID integer references JOB not null,
+ RESOURCE_ID integer,
+ GROUP_ID integer
+);
+
+create index GROUP_ATTENDEE_RECONCILE_WORK_JOB_ID on
+ GROUP_ATTENDEE_RECONCILE_WORK(JOB_ID);
+
+
+create table GROUPS (
+ GROUP_ID integer primary key default nextval('RESOURCE_ID_SEQ'), -- implicit index
+ NAME varchar(255) not null,
+ GROUP_UID varchar(255) not null,
+ MEMBERSHIP_HASH varchar(255) not null,
+ EXTANT integer default 1,
+ CREATED timestamp default timezone('UTC', CURRENT_TIMESTAMP),
+ MODIFIED timestamp default timezone('UTC', CURRENT_TIMESTAMP)
+);
+create index GROUPS_GROUP_UID on
+ GROUPS(GROUP_UID);
+
+create table GROUP_MEMBERSHIP (
+ GROUP_ID integer not null references GROUPS on delete cascade,
+ MEMBER_UID varchar(255) not null,
+
+ primary key (GROUP_ID, MEMBER_UID)
+);
+
+create index GROUP_MEMBERSHIP_MEMBER on
+ GROUP_MEMBERSHIP(MEMBER_UID);
+
+create table GROUP_ATTENDEE (
+ GROUP_ID integer not null references GROUPS on delete cascade,
+ RESOURCE_ID integer not null references CALENDAR_OBJECT on delete cascade,
+ MEMBERSHIP_HASH varchar(255) not null,
+
+ primary key (GROUP_ID, RESOURCE_ID)
+);
+create index GROUP_ATTENDEE_RESOURCE_ID on
+ GROUP_ATTENDEE(RESOURCE_ID);
+
+---------------
+-- Delegates --
+---------------
+
+create table DELEGATES (
+ DELEGATOR varchar(255) not null,
+ DELEGATE varchar(255) not null,
+ READ_WRITE integer not null, -- 1 = ReadWrite, 0 = ReadOnly
+
+ primary key (DELEGATOR, READ_WRITE, DELEGATE)
+);
+create index DELEGATE_TO_DELEGATOR on
+ DELEGATES(DELEGATE, READ_WRITE, DELEGATOR);
+
+create table DELEGATE_GROUPS (
+ DELEGATOR varchar(255) not null,
+ GROUP_ID integer not null references GROUPS on delete cascade,
+ READ_WRITE integer not null, -- 1 = ReadWrite, 0 = ReadOnly
+ IS_EXTERNAL integer not null, -- 1 = ReadWrite, 0 = ReadOnly
+
+ primary key (DELEGATOR, READ_WRITE, GROUP_ID)
+);
+create index DELEGATE_GROUPS_GROUP_ID on
+ DELEGATE_GROUPS(GROUP_ID);
+
+create table EXTERNAL_DELEGATE_GROUPS (
+ DELEGATOR varchar(255) primary key not null,
+ GROUP_UID_READ varchar(255),
+ GROUP_UID_WRITE varchar(255)
+);
+
+--------------------------
+-- Object Splitter Work --
+--------------------------
+
+create table CALENDAR_OBJECT_SPLITTER_WORK (
+ WORK_ID integer primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+ JOB_ID integer references JOB not null,
+ RESOURCE_ID integer not null references CALENDAR_OBJECT on delete cascade
+);
+
+create index CALENDAR_OBJECT_SPLITTER_WORK_RESOURCE_ID on
+ CALENDAR_OBJECT_SPLITTER_WORK(RESOURCE_ID);
+create index CALENDAR_OBJECT_SPLITTER_WORK_JOB_ID on
+ CALENDAR_OBJECT_SPLITTER_WORK(JOB_ID);
+
+---------------------------
+-- Revision Cleanup Work --
+---------------------------
+
+create table FIND_MIN_VALID_REVISION_WORK (
+ WORK_ID integer primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+ JOB_ID integer references JOB not null
+);
+
+create index FIND_MIN_VALID_REVISION_WORK_JOB_ID on
+ FIND_MIN_VALID_REVISION_WORK(JOB_ID);
+
+create table REVISION_CLEANUP_WORK (
+ WORK_ID integer primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+ JOB_ID integer references JOB not null
+);
+
+create index REVISION_CLEANUP_WORK_JOB_ID on
+ REVISION_CLEANUP_WORK(JOB_ID);
+
+------------------------
+-- Inbox Cleanup Work --
+------------------------
+
+create table INBOX_CLEANUP_WORK (
+ WORK_ID integer primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+ JOB_ID integer references JOB not null
+);
+
+create index INBOX_CLEANUP_WORK_JOB_ID on
+ INBOX_CLEANUP_WORK(JOB_ID);
+
+create table CLEANUP_ONE_INBOX_WORK (
+ WORK_ID integer primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+ JOB_ID integer references JOB not null,
+ HOME_ID integer not null unique references CALENDAR_HOME on delete cascade
+);
+
+create index CLEANUP_ONE_INBOX_WORK_JOB_ID on
+ CLEANUP_ONE_INBOX_WORK(JOB_ID);
+
+---------------------------
+-- Schedule Refresh Work --
+---------------------------
+
+create table SCHEDULE_REFRESH_WORK (
+ WORK_ID integer primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+ JOB_ID integer references JOB not null,
+ ICALENDAR_UID varchar(255) not null,
+ HOME_RESOURCE_ID integer not null references CALENDAR_HOME on delete cascade,
+ RESOURCE_ID integer not null references CALENDAR_OBJECT on delete cascade,
+ ATTENDEE_COUNT integer
+);
+
+create index SCHEDULE_REFRESH_WORK_HOME_RESOURCE_ID on
+ SCHEDULE_REFRESH_WORK(HOME_RESOURCE_ID);
+create index SCHEDULE_REFRESH_WORK_RESOURCE_ID on
+ SCHEDULE_REFRESH_WORK(RESOURCE_ID);
+create index SCHEDULE_REFRESH_WORK_JOB_ID on
+ SCHEDULE_REFRESH_WORK(JOB_ID);
+
+create table SCHEDULE_REFRESH_ATTENDEES (
+ RESOURCE_ID integer not null references CALENDAR_OBJECT on delete cascade,
+ ATTENDEE varchar(255) not null,
+
+ primary key (RESOURCE_ID, ATTENDEE)
+);
+
+create index SCHEDULE_REFRESH_ATTENDEES_RESOURCE_ID_ATTENDEE on
+ SCHEDULE_REFRESH_ATTENDEES(RESOURCE_ID, ATTENDEE);
+
+------------------------------
+-- Schedule Auto Reply Work --
+------------------------------
+
+create table SCHEDULE_AUTO_REPLY_WORK (
+ WORK_ID integer primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+ JOB_ID integer references JOB not null,
+ ICALENDAR_UID varchar(255) not null,
+ HOME_RESOURCE_ID integer not null references CALENDAR_HOME on delete cascade,
+ RESOURCE_ID integer not null references CALENDAR_OBJECT on delete cascade,
+ PARTSTAT varchar(255) not null
+);
+
+create index SCHEDULE_AUTO_REPLY_WORK_HOME_RESOURCE_ID on
+ SCHEDULE_AUTO_REPLY_WORK(HOME_RESOURCE_ID);
+create index SCHEDULE_AUTO_REPLY_WORK_RESOURCE_ID on
+ SCHEDULE_AUTO_REPLY_WORK(RESOURCE_ID);
+create index SCHEDULE_AUTO_REPLY_WORK_JOB_ID on
+ SCHEDULE_AUTO_REPLY_WORK(JOB_ID);
+
+-----------------------------
+-- Schedule Organizer Work --
+-----------------------------
+
+create table SCHEDULE_ORGANIZER_WORK (
+ WORK_ID integer primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+ JOB_ID integer references JOB not null,
+ ICALENDAR_UID varchar(255) not null,
+ SCHEDULE_ACTION integer not null, -- Enum SCHEDULE_ACTION
+ HOME_RESOURCE_ID integer not null references CALENDAR_HOME on delete cascade,
+ RESOURCE_ID integer, -- this references a possibly non-existent CALENDR_OBJECT
+ ICALENDAR_TEXT_OLD text,
+ ICALENDAR_TEXT_NEW text,
+ ATTENDEE_COUNT integer,
+ SMART_MERGE boolean
+);
+
+create index SCHEDULE_ORGANIZER_WORK_HOME_RESOURCE_ID on
+ SCHEDULE_ORGANIZER_WORK(HOME_RESOURCE_ID);
+create index SCHEDULE_ORGANIZER_WORK_RESOURCE_ID on
+ SCHEDULE_ORGANIZER_WORK(RESOURCE_ID);
+create index SCHEDULE_ORGANIZER_WORK_JOB_ID on
+ SCHEDULE_ORGANIZER_WORK(JOB_ID);
+
+-- Enumeration of schedule actions
+
+create table SCHEDULE_ACTION (
+ ID integer primary key,
+ DESCRIPTION varchar(16) not null unique
+);
+
+insert into SCHEDULE_ACTION values (0, 'create');
+insert into SCHEDULE_ACTION values (1, 'modify');
+insert into SCHEDULE_ACTION values (2, 'modify-cancelled');
+insert into SCHEDULE_ACTION values (3, 'remove');
+
+-------------------------
+-- Schedule Reply Work --
+-------------------------
+
+create table SCHEDULE_REPLY_WORK (
+ WORK_ID integer primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+ JOB_ID integer references JOB not null,
+ ICALENDAR_UID varchar(255) not null,
+ HOME_RESOURCE_ID integer not null references CALENDAR_HOME on delete cascade,
+ RESOURCE_ID integer not null references CALENDAR_OBJECT on delete cascade,
+ CHANGED_RIDS text
+);
+
+create index SCHEDULE_REPLY_WORK_HOME_RESOURCE_ID on
+ SCHEDULE_REPLY_WORK(HOME_RESOURCE_ID);
+create index SCHEDULE_REPLY_WORK_RESOURCE_ID on
+ SCHEDULE_REPLY_WORK(RESOURCE_ID);
+create index SCHEDULE_REPLY_WORK_JOB_ID on
+ SCHEDULE_REPLY_WORK(JOB_ID);
+
+--------------------------------
+-- Schedule Reply Cancel Work --
+--------------------------------
+
+create table SCHEDULE_REPLY_CANCEL_WORK (
+ WORK_ID integer primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+ JOB_ID integer references JOB not null,
+ ICALENDAR_UID varchar(255) not null,
+ HOME_RESOURCE_ID integer not null references CALENDAR_HOME on delete cascade,
+ ICALENDAR_TEXT text not null
+);
+
+create index SCHEDULE_REPLY_CANCEL_WORK_HOME_RESOURCE_ID on
+ SCHEDULE_REPLY_CANCEL_WORK(HOME_RESOURCE_ID);
+create index SCHEDULE_REPLY_CANCEL_WORK_JOB_ID on
+ SCHEDULE_REPLY_CANCEL_WORK(JOB_ID);
+
+----------------------------------
+-- Principal Purge Polling Work --
+----------------------------------
+
+create table PRINCIPAL_PURGE_POLLING_WORK (
+ WORK_ID integer primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+ JOB_ID integer references JOB not null
+);
+
+create index PRINCIPAL_PURGE_POLLING_WORK_JOB_ID on
+ PRINCIPAL_PURGE_POLLING_WORK(JOB_ID);
+
+--------------------------------
+-- Principal Purge Check Work --
+--------------------------------
+
+create table PRINCIPAL_PURGE_CHECK_WORK (
+ WORK_ID integer primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+ JOB_ID integer references JOB not null,
+ UID varchar(255) not null
+);
+
+create index PRINCIPAL_PURGE_CHECK_WORK_JOB_ID on
+ PRINCIPAL_PURGE_CHECK_WORK(JOB_ID);
+
+--------------------------
+-- Principal Purge Work --
+--------------------------
+
+create table PRINCIPAL_PURGE_WORK (
+ WORK_ID integer primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+ JOB_ID integer references JOB not null,
+ UID varchar(255) not null
+);
+
+create index PRINCIPAL_PURGE_WORK_JOB_ID on
+ PRINCIPAL_PURGE_WORK(JOB_ID);
+
+
+--------------------------------
+-- Principal Home Remove Work --
+--------------------------------
+
+create table PRINCIPAL_PURGE_HOME_WORK (
+ WORK_ID integer primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+ JOB_ID integer references JOB not null,
+ HOME_RESOURCE_ID integer not null references CALENDAR_HOME on delete cascade
+);
+
+create index PRINCIPAL_PURGE_HOME_WORK_JOB_ID on
+ PRINCIPAL_PURGE_HOME_WORK(JOB_ID);
+create index PRINCIPAL_PURGE_HOME_HOME_RESOURCE_ID on
+ PRINCIPAL_PURGE_HOME_WORK(HOME_RESOURCE_ID);
+
+
+--------------------
+-- Schema Version --
+--------------------
+
+create table CALENDARSERVER (
+ NAME varchar(255) primary key, -- implicit index
+ VALUE varchar(255)
+);
+
+insert into CALENDARSERVER values ('VERSION', '41');
+insert into CALENDARSERVER values ('CALENDAR-DATAVERSION', '6');
+insert into CALENDARSERVER values ('ADDRESSBOOK-DATAVERSION', '2');
+insert into CALENDARSERVER values ('NOTIFICATION-DATAVERSION', '1');
+insert into CALENDARSERVER values ('MIN-VALID-REVISION', '1');
</ins></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_41_to_42sql"></a>
<div class="addfile"><h4>Added: CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_41_to_42.sql (0 => 13473)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_41_to_42.sql         (rev 0)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_41_to_42.sql        2014-05-14 20:10:58 UTC (rev 13473)
</span><span class="lines">@@ -0,0 +1,33 @@
</span><ins>+----
+-- Copyright (c) 2012-2014 Apple Inc. All rights reserved.
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+----
+
+---------------------------------------------------
+-- Upgrade database schema from VERSION 41 to 42 --
+---------------------------------------------------
+
+-----------------
+-- Job Changes --
+-----------------
+
+alter table JOB
+ modify ("NOT_BEFORE" timestamp not null)
+ add ("FAILED" integer default 0);
+
+alter table JOB
+ rename column NOT_AFTER to ASSIGNED;
+
+-- update the version
+update CALENDARSERVER set VALUE = '42' where NAME = 'VERSION';
</ins></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaupgradespostgresdialectupgrade_from_41_to_42sql"></a>
<div class="addfile"><h4>Added: CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_41_to_42.sql (0 => 13473)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_41_to_42.sql         (rev 0)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_41_to_42.sql        2014-05-14 20:10:58 UTC (rev 13473)
</span><span class="lines">@@ -0,0 +1,34 @@
</span><ins>+----
+-- Copyright (c) 2012-2014 Apple Inc. All rights reserved.
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+----
+
+---------------------------------------------------
+-- Upgrade database schema from VERSION 41 to 42 --
+---------------------------------------------------
+
+-----------------
+-- Job Changes --
+-----------------
+
+alter table JOB
+ alter column NOT_BEFORE drop default,
+ alter column NOT_BEFORE set not null,
+ add column FAILED integer default 0;
+
+alter table JOB
+ rename column NOT_AFTER to ASSIGNED;
+
+-- update the version
+update CALENDARSERVER set VALUE = '42' where NAME = 'VERSION';
</ins></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoretesttest_sqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/test/test_sql.py (13472 => 13473)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/test/test_sql.py        2014-05-14 19:50:12 UTC (rev 13472)
+++ CalendarServer/trunk/txdav/common/datastore/test/test_sql.py        2014-05-14 20:10:58 UTC (rev 13473)
</span><span class="lines">@@ -268,6 +268,7 @@
</span><span class="cx"> """
</span><span class="cx"> txn = self.transactionUnderTest()
</span><span class="cx"> cs = schema.CALENDARSERVER
</span><ins>+ yield Select([cs.VALUE], From=cs).on(txn)
</ins><span class="cx"> waitAMoment = Deferred()
</span><span class="cx"> @inlineCallbacks
</span><span class="cx"> def later(subtxn):
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoretestutilpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/test/util.py (13472 => 13473)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/test/util.py        2014-05-14 19:50:12 UTC (rev 13472)
+++ CalendarServer/trunk/txdav/common/datastore/test/util.py        2014-05-14 20:10:58 UTC (rev 13473)
</span><span class="lines">@@ -36,6 +36,7 @@
</span><span class="cx"> from twext.python.filepath import CachingFilePath as FilePath
</span><span class="cx"> from twext.enterprise.adbapi2 import ConnectionPool
</span><span class="cx"> from twext.enterprise.ienterprise import AlreadyFinishedError
</span><ins>+from twext.enterprise.jobqueue import PeerConnectionPool, JobItem
</ins><span class="cx"> from twext.who.directory import DirectoryRecord
</span><span class="cx">
</span><span class="cx"> from twisted.application.service import Service
</span><span class="lines">@@ -100,7 +101,6 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>-
</del><span class="cx"> class SQLStoreBuilder(object):
</span><span class="cx"> """
</span><span class="cx"> Test-fixture-builder which can construct a PostgresStore.
</span><span class="lines">@@ -109,6 +109,7 @@
</span><span class="cx"> self.sharedService = None
</span><span class="cx"> self.currentTestID = None
</span><span class="cx"> self.sharedDBPath = "_test_sql_db" + str(os.getpid()) + ("-2" if secondary else "")
</span><ins>+ self.ampPort = config.WorkQueue.ampPort + (1 if secondary else 0)
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> def createService(self, serviceFactory):
</span><span class="lines">@@ -155,7 +156,7 @@
</span><span class="cx"> return cds
</span><span class="cx">
</span><span class="cx">
</span><del>- def buildStore(self, testCase, notifierFactory, directoryService=None, homes=None):
</del><ins>+ def buildStore(self, testCase, notifierFactory, directoryService=None, homes=None, enableJobProcessing=True):
</ins><span class="cx"> """
</span><span class="cx"> Do the necessary work to build a store for a particular test case.
</span><span class="cx">
</span><span class="lines">@@ -169,7 +170,7 @@
</span><span class="cx"> ready = Deferred()
</span><span class="cx"> def getReady(connectionFactory, storageService):
</span><span class="cx"> self.makeAndCleanStore(
</span><del>- testCase, notifierFactory, directoryService, attachmentRoot
</del><ins>+ testCase, notifierFactory, directoryService, attachmentRoot, enableJobProcessing
</ins><span class="cx"> ).chainDeferred(ready)
</span><span class="cx"> return Service()
</span><span class="cx"> self.sharedService = self.createService(getReady)
</span><span class="lines">@@ -183,7 +184,7 @@
</span><span class="cx"> result = ready
</span><span class="cx"> else:
</span><span class="cx"> result = self.makeAndCleanStore(
</span><del>- testCase, notifierFactory, directoryService, attachmentRoot
</del><ins>+ testCase, notifierFactory, directoryService, attachmentRoot, enableJobProcessing
</ins><span class="cx"> )
</span><span class="cx"> def cleanUp():
</span><span class="cx"> def stopit():
</span><span class="lines">@@ -194,7 +195,7 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><del>- def makeAndCleanStore(self, testCase, notifierFactory, directoryService, attachmentRoot):
</del><ins>+ def makeAndCleanStore(self, testCase, notifierFactory, directoryService, attachmentRoot, enableJobProcessing=True):
</ins><span class="cx"> """
</span><span class="cx"> Create a L{CommonDataStore} specific to the given L{TestCase}.
</span><span class="cx">
</span><span class="lines">@@ -211,7 +212,7 @@
</span><span class="cx"> attachmentRoot.createDirectory()
</span><span class="cx">
</span><span class="cx"> currentTestID = testCase.id()
</span><del>- cp = ConnectionPool(self.sharedService.produceConnection, maxConnections=5)
</del><ins>+ cp = ConnectionPool(self.sharedService.produceConnection, maxConnections=4)
</ins><span class="cx"> quota = deriveQuota(testCase)
</span><span class="cx"> store = CommonDataStore(
</span><span class="cx"> cp.connection,
</span><span class="lines">@@ -223,20 +224,39 @@
</span><span class="cx"> )
</span><span class="cx"> store.label = currentTestID
</span><span class="cx"> cp.startService()
</span><ins>+
+ @inlineCallbacks
</ins><span class="cx"> def stopIt():
</span><ins>+ txn = store.newTransaction()
+ jobs = yield JobItem.all(txn)
+ yield txn.commit()
+ if len(jobs):
+ print("Jobs left in job queue {}".format(testCase))
+
+ if enableJobProcessing:
+ yield pool.stopService()
+
</ins><span class="cx"> # active transactions should have been shut down.
</span><span class="cx"> wasBusy = len(cp._busy)
</span><span class="cx"> busyText = repr(cp._busy)
</span><del>- stop = cp.stopService()
- def checkWasBusy(ignored):
</del><ins>+ result = yield cp.stopService()
+ if deriveValue(testCase, _SPECIAL_TXN_CLEAN, lambda tc: False):
</ins><span class="cx"> if wasBusy:
</span><span class="cx"> testCase.fail("Outstanding Transactions: " + busyText)
</span><del>- return ignored
- if deriveValue(testCase, _SPECIAL_TXN_CLEAN, lambda tc: False):
- stop.addBoth(checkWasBusy)
- return stop
</del><ins>+ returnValue(result)
+ returnValue(result)
+
</ins><span class="cx"> testCase.addCleanup(stopIt)
</span><span class="cx"> yield self.cleanStore(testCase, store)
</span><ins>+
+ # Start the job queue after store is up and cleaned
+ if enableJobProcessing:
+ pool = PeerConnectionPool(
+ reactor, store.newTransaction, None
+ )
+ store.queuer = store.queuer.transferProposalCallbacks(pool)
+ pool.startService()
+
</ins><span class="cx"> returnValue(store)
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -597,7 +617,6 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>-
</del><span class="cx"> def buildTestDirectory(
</span><span class="cx"> store, dataRoot, accounts=None, resources=None, augments=None, proxies=None,
</span><span class="cx"> serversDB=None
</span><span class="lines">@@ -772,7 +791,6 @@
</span><span class="cx"> self.config = config
</span><span class="cx">
</span><span class="cx">
</span><del>-
</del><span class="cx"> def buildStore(self, storeBuilder=theStoreBuilder):
</span><span class="cx"> """
</span><span class="cx"> Builds and returns a store
</span><span class="lines">@@ -783,8 +801,6 @@
</span><span class="cx"> return storeBuilder.buildStore(self, self.notifierFactory, None)
</span><span class="cx">
</span><span class="cx">
</span><del>-
-
</del><span class="cx"> def transactionUnderTest(self, txn=None):
</span><span class="cx"> """
</span><span class="cx"> Create a transaction from C{storeUnderTest} and save it as
</span><span class="lines">@@ -840,7 +856,6 @@
</span><span class="cx"> return result
</span><span class="cx">
</span><span class="cx">
</span><del>-
</del><span class="cx"> def storeUnderTest(self):
</span><span class="cx"> """
</span><span class="cx"> Create and return the L{CalendarStore} for testing.
</span><span class="lines">@@ -924,6 +939,7 @@
</span><span class="cx"> updatedRecord = DirectoryRecord(self.directory, fields)
</span><span class="cx"> yield self.directory.updateRecords((updatedRecord,), create=True)
</span><span class="cx">
</span><ins>+
</ins><span class="cx"> @inlineCallbacks
</span><span class="cx"> def removeRecord(self, uid):
</span><span class="cx"> yield self.directory.removeRecords([uid])
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoreupgradesqlotherstesttest_attachment_migrationpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/upgrade/sql/others/test/test_attachment_migration.py (13472 => 13473)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/upgrade/sql/others/test/test_attachment_migration.py        2014-05-14 19:50:12 UTC (rev 13472)
+++ CalendarServer/trunk/txdav/common/datastore/upgrade/sql/others/test/test_attachment_migration.py        2014-05-14 20:10:58 UTC (rev 13473)
</span><span class="lines">@@ -17,6 +17,7 @@
</span><span class="cx"> from twext.enterprise.dal.syntax import Delete, Insert, Select, Count
</span><span class="cx">
</span><span class="cx"> from twisted.internet.defer import inlineCallbacks, succeed, returnValue
</span><ins>+from twisted.trial.unittest import TestCase
</ins><span class="cx">
</span><span class="cx"> from twistedcaldav.config import config
</span><span class="cx">
</span><span class="lines">@@ -42,6 +43,13 @@
</span><span class="cx"> """
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><ins>+ def setUp(self):
+ # We need to skip the immediate base class since we are creating our own
+ # store in each test
+ yield TestCase.setUp(self)
+
+
+ @inlineCallbacks
</ins><span class="cx"> def _initStore(self, enableManagedAttachments=True):
</span><span class="cx"> """
</span><span class="cx"> Build a store with certain bits cleaned out.
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoreupgradesqltesttest_upgradepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/upgrade/sql/test/test_upgrade.py (13472 => 13473)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/upgrade/sql/test/test_upgrade.py        2014-05-14 19:50:12 UTC (rev 13472)
+++ CalendarServer/trunk/txdav/common/datastore/upgrade/sql/test/test_upgrade.py        2014-05-14 20:10:58 UTC (rev 13473)
</span><span class="lines">@@ -145,7 +145,7 @@
</span><span class="cx"> """
</span><span class="cx">
</span><span class="cx"> store = yield theStoreBuilder.buildStore(
</span><del>- self, {"push": StubNotifierFactory()}
</del><ins>+ self, {"push": StubNotifierFactory()}, enableJobProcessing=False
</ins><span class="cx"> )
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><span class="lines">@@ -203,6 +203,16 @@
</span><span class="cx"> new_schema = yield _loadSchemaFromDatabase()
</span><span class="cx"> currentSchema = schemaFromPath(test_upgrader.schemaLocation.child("current.sql"))
</span><span class="cx"> mismatched = currentSchema.compare(new_schema)
</span><ins>+ # These are special case exceptions
+ for i in (
+ "Table: CALENDAR_HOME, column name DATAVERSION default mismatch",
+ "Table: ADDRESSBOOK_HOME, column name DATAVERSION default mismatch",
+ "Table: PUSH_NOTIFICATION_WORK, column name PUSH_PRIORITY default mismatch",
+ ):
+ try:
+ mismatched.remove(i)
+ except ValueError:
+ pass
</ins><span class="cx"> self.assertEqual(len(mismatched), 0, "Schema mismatch:\n" + "\n".join(mismatched))
</span><span class="cx">
</span><span class="cx"> yield _unloadOldSchema()
</span><span class="lines">@@ -239,7 +249,7 @@
</span><span class="cx"> """
</span><span class="cx">
</span><span class="cx"> store = yield theStoreBuilder.buildStore(
</span><del>- self, {"push": StubNotifierFactory()}
</del><ins>+ self, {"push": StubNotifierFactory()}, enableJobProcessing=False
</ins><span class="cx"> )
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><span class="lines">@@ -297,7 +307,7 @@
</span><span class="cx"> for child in test_upgrader.schemaLocation.child("old").child(POSTGRES_DIALECT).globChildren("*.sql"):
</span><span class="cx"> def f(self, lchild=child):
</span><span class="cx"> return self._dbSchemaUpgrades(lchild)
</span><del>- setattr(SchemaUpgradeTests, "test_dbSchemaUpgrades_%s" % (child.basename().split(".", 1)[0],), f)
</del><ins>+ setattr(SchemaUpgradeTests, "test_dbSchemaUpgrades_%s" % (child.basename().split(".", 1)[0],), f)
</ins><span class="cx">
</span><span class="cx"> # Bind test methods for each addressbook data version
</span><span class="cx"> versions = set()
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoreworktesttest_inbox_cleanuppy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/work/test/test_inbox_cleanup.py (13472 => 13473)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/work/test/test_inbox_cleanup.py        2014-05-14 19:50:12 UTC (rev 13472)
+++ CalendarServer/trunk/txdav/common/datastore/work/test/test_inbox_cleanup.py        2014-05-14 20:10:58 UTC (rev 13473)
</span><span class="lines">@@ -15,17 +15,18 @@
</span><span class="cx"> ##
</span><span class="cx">
</span><span class="cx">
</span><ins>+from txdav.common.datastore.sql_tables import schema
</ins><span class="cx"> from txdav.common.datastore.work.inbox_cleanup import InboxCleanupWork, CleanupOneInboxWork
</span><span class="cx"> from txdav.common.datastore.test.util import CommonCommonTests, populateCalendarsFrom
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> from twext.enterprise.dal.syntax import Select, Update, Parameter
</span><del>-from twext.enterprise.jobqueue import WorkItem
</del><ins>+from twext.enterprise.jobqueue import WorkItem, JobItem
</ins><span class="cx"> from twext.python.clsprop import classproperty
</span><ins>+from twisted.internet import reactor
</ins><span class="cx"> from twisted.internet.defer import inlineCallbacks
</span><span class="cx"> from twisted.trial.unittest import TestCase
</span><span class="cx"> from twistedcaldav.config import config
</span><del>-from txdav.common.datastore.sql_tables import schema
</del><span class="cx"> import datetime
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -143,9 +144,9 @@
</span><span class="cx"> self.patch(CleanupOneInboxWork, "_schedule", FakeCleanupOneInboxWork._schedule)
</span><span class="cx">
</span><span class="cx"> # do cleanup
</span><del>- wp = yield self.transactionUnderTest().enqueue(InboxCleanupWork, notBefore=datetime.datetime.utcnow())
</del><ins>+ yield self.transactionUnderTest().enqueue(InboxCleanupWork, notBefore=datetime.datetime.utcnow())
</ins><span class="cx"> yield self.commit()
</span><del>- yield wp.whenExecuted()
</del><ins>+ yield JobItem.waitEmpty(self.storeUnderTest().newTransaction, reactor, 60)
</ins><span class="cx">
</span><span class="cx"> ch = schema.CALENDAR_HOME
</span><span class="cx"> workRows = yield Select(
</span><span class="lines">@@ -171,9 +172,9 @@
</span><span class="cx"> yield item.remove()
</span><span class="cx">
</span><span class="cx"> # do cleanup
</span><del>- wp = yield self.transactionUnderTest().enqueue(CleanupOneInboxWork, homeID=inbox.ownerHome()._resourceID, notBefore=datetime.datetime.utcnow())
</del><ins>+ yield self.transactionUnderTest().enqueue(CleanupOneInboxWork, homeID=inbox.ownerHome()._resourceID, notBefore=datetime.datetime.utcnow())
</ins><span class="cx"> yield self.commit()
</span><del>- yield wp.whenExecuted()
</del><ins>+ yield JobItem.waitEmpty(self.storeUnderTest().newTransaction, reactor, 60)
</ins><span class="cx">
</span><span class="cx"> # check that orphans are deleted
</span><span class="cx"> inbox = yield self.calendarUnderTest(home="user01", name="inbox")
</span><span class="lines">@@ -200,9 +201,9 @@
</span><span class="cx"> co.CALENDAR_RESOURCE_ID == inbox._resourceID)).on(self.transactionUnderTest(), itemsToPredate=itemsToPredate)
</span><span class="cx">
</span><span class="cx"> # do cleanup
</span><del>- wp = yield self.transactionUnderTest().enqueue(CleanupOneInboxWork, homeID=inbox.ownerHome()._resourceID, notBefore=datetime.datetime.utcnow())
</del><ins>+ yield self.transactionUnderTest().enqueue(CleanupOneInboxWork, homeID=inbox.ownerHome()._resourceID, notBefore=datetime.datetime.utcnow())
</ins><span class="cx"> yield self.commit()
</span><del>- yield wp.whenExecuted()
</del><ins>+ yield JobItem.waitEmpty(self.storeUnderTest().newTransaction, reactor, 60)
</ins><span class="cx">
</span><span class="cx"> # check that old items are deleted
</span><span class="cx"> inbox = yield self.calendarUnderTest(home="user01", name="inbox")
</span><span class="lines">@@ -225,9 +226,9 @@
</span><span class="cx"> Where=tr.CALENDAR_OBJECT_RESOURCE_ID == cal3Event._resourceID).on(
</span><span class="cx"> self.transactionUnderTest())
</span><span class="cx"> # do cleanup
</span><del>- wp = yield self.transactionUnderTest().enqueue(CleanupOneInboxWork, homeID=calendar.ownerHome()._resourceID, notBefore=datetime.datetime.utcnow())
</del><ins>+ yield self.transactionUnderTest().enqueue(CleanupOneInboxWork, homeID=calendar.ownerHome()._resourceID, notBefore=datetime.datetime.utcnow())
</ins><span class="cx"> yield self.commit()
</span><del>- yield wp.whenExecuted()
</del><ins>+ yield JobItem.waitEmpty(self.storeUnderTest().newTransaction, reactor, 60)
</ins><span class="cx">
</span><span class="cx"> # check that old items are deleted
</span><span class="cx"> inbox = yield self.calendarUnderTest(home="user01", name="inbox")
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoreworktesttest_revision_cleanuppy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/work/test/test_revision_cleanup.py (13472 => 13473)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/work/test/test_revision_cleanup.py        2014-05-14 19:50:12 UTC (rev 13472)
+++ CalendarServer/trunk/txdav/common/datastore/work/test/test_revision_cleanup.py        2014-05-14 20:10:58 UTC (rev 13473)
</span><span class="lines">@@ -17,8 +17,9 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> from twext.enterprise.dal.syntax import Select
</span><del>-from twext.enterprise.jobqueue import WorkItem
</del><ins>+from twext.enterprise.jobqueue import WorkItem, JobItem
</ins><span class="cx"> from twext.python.clsprop import classproperty
</span><ins>+from twisted.internet import reactor
</ins><span class="cx"> from twisted.internet.defer import inlineCallbacks, returnValue
</span><span class="cx"> from twisted.trial.unittest import TestCase
</span><span class="cx"> from twistedcaldav.config import config
</span><span class="lines">@@ -265,18 +266,18 @@
</span><span class="cx"> self.assertNotEqual(len(revisionRows), 0)
</span><span class="cx">
</span><span class="cx"> # do FindMinValidRevisionWork
</span><del>- wp = yield self.transactionUnderTest().enqueue(FindMinValidRevisionWork, notBefore=datetime.datetime.utcnow())
</del><ins>+ yield self.transactionUnderTest().enqueue(FindMinValidRevisionWork, notBefore=datetime.datetime.utcnow())
</ins><span class="cx"> yield self.commit()
</span><del>- yield wp.whenExecuted()
</del><ins>+ yield JobItem.waitEmpty(self.storeUnderTest().newTransaction, reactor, 60)
</ins><span class="cx">
</span><span class="cx"> # Get the minimum valid revision and check it
</span><span class="cx"> minValidRevision = yield self.transactionUnderTest().calendarserverValue("MIN-VALID-REVISION")
</span><span class="cx"> self.assertEqual(int(minValidRevision), max([row[0] for row in revisionRows]))
</span><span class="cx">
</span><span class="cx"> # do RevisionCleanupWork
</span><del>- wp = yield self.transactionUnderTest().enqueue(RevisionCleanupWork, notBefore=datetime.datetime.utcnow())
</del><ins>+ yield self.transactionUnderTest().enqueue(RevisionCleanupWork, notBefore=datetime.datetime.utcnow())
</ins><span class="cx"> yield self.commit()
</span><del>- yield wp.whenExecuted()
</del><ins>+ yield JobItem.waitEmpty(self.storeUnderTest().newTransaction, reactor, 60)
</ins><span class="cx">
</span><span class="cx"> # Get group1 object revision
</span><span class="cx"> rev = schema.CALENDAR_OBJECT_REVISIONS
</span><span class="lines">@@ -313,18 +314,18 @@
</span><span class="cx"> self.assertNotEqual(len(revisionRows), 0)
</span><span class="cx">
</span><span class="cx"> # do FindMinValidRevisionWork
</span><del>- wp = yield self.transactionUnderTest().enqueue(FindMinValidRevisionWork, notBefore=datetime.datetime.utcnow())
</del><ins>+ yield self.transactionUnderTest().enqueue(FindMinValidRevisionWork, notBefore=datetime.datetime.utcnow())
</ins><span class="cx"> yield self.commit()
</span><del>- yield wp.whenExecuted()
</del><ins>+ yield JobItem.waitEmpty(self.storeUnderTest().newTransaction, reactor, 60)
</ins><span class="cx">
</span><span class="cx"> # Get the minimum valid revision and check it
</span><span class="cx"> minValidRevision = yield self.transactionUnderTest().calendarserverValue("MIN-VALID-REVISION")
</span><span class="cx"> self.assertEqual(int(minValidRevision), max([row[0] for row in revisionRows]))
</span><span class="cx">
</span><span class="cx"> # do RevisionCleanupWork
</span><del>- wp = yield self.transactionUnderTest().enqueue(RevisionCleanupWork, notBefore=datetime.datetime.utcnow())
</del><ins>+ yield self.transactionUnderTest().enqueue(RevisionCleanupWork, notBefore=datetime.datetime.utcnow())
</ins><span class="cx"> yield self.commit()
</span><del>- yield wp.whenExecuted()
</del><ins>+ yield JobItem.waitEmpty(self.storeUnderTest().newTransaction, reactor, 60)
</ins><span class="cx">
</span><span class="cx"> # Get group1 object revision
</span><span class="cx"> rev = schema.NOTIFICATION_OBJECT_REVISIONS
</span><span class="lines">@@ -365,18 +366,18 @@
</span><span class="cx"> self.assertNotEqual(len(revisionRows), 0)
</span><span class="cx">
</span><span class="cx"> # do FindMinValidRevisionWork
</span><del>- wp = yield self.transactionUnderTest().enqueue(FindMinValidRevisionWork, notBefore=datetime.datetime.utcnow())
</del><ins>+ yield self.transactionUnderTest().enqueue(FindMinValidRevisionWork, notBefore=datetime.datetime.utcnow())
</ins><span class="cx"> yield self.commit()
</span><del>- yield wp.whenExecuted()
</del><ins>+ yield JobItem.waitEmpty(self.storeUnderTest().newTransaction, reactor, 60)
</ins><span class="cx">
</span><span class="cx"> # Get the minimum valid revision and check it
</span><span class="cx"> minValidRevision = yield self.transactionUnderTest().calendarserverValue("MIN-VALID-REVISION")
</span><span class="cx"> self.assertEqual(int(minValidRevision), max([row[0] for row in revisionRows]))
</span><span class="cx">
</span><span class="cx"> # do RevisionCleanupWork
</span><del>- wp = yield self.transactionUnderTest().enqueue(RevisionCleanupWork, notBefore=datetime.datetime.utcnow())
</del><ins>+ yield self.transactionUnderTest().enqueue(RevisionCleanupWork, notBefore=datetime.datetime.utcnow())
</ins><span class="cx"> yield self.commit()
</span><del>- yield wp.whenExecuted()
</del><ins>+ yield JobItem.waitEmpty(self.storeUnderTest().newTransaction, reactor, 60)
</ins><span class="cx">
</span><span class="cx"> # Get group1 object revision
</span><span class="cx"> rev = schema.ADDRESSBOOK_OBJECT_REVISIONS
</span><span class="lines">@@ -438,18 +439,18 @@
</span><span class="cx"> self.assertEqual(len(group2Rows), 4) # 2 members x 2 revisions each
</span><span class="cx">
</span><span class="cx"> # do FindMinValidRevisionWork
</span><del>- wp = yield self.transactionUnderTest().enqueue(FindMinValidRevisionWork, notBefore=datetime.datetime.utcnow())
</del><ins>+ yield self.transactionUnderTest().enqueue(FindMinValidRevisionWork, notBefore=datetime.datetime.utcnow())
</ins><span class="cx"> yield self.commit()
</span><del>- yield wp.whenExecuted()
</del><ins>+ yield JobItem.waitEmpty(self.storeUnderTest().newTransaction, reactor, 60)
</ins><span class="cx">
</span><span class="cx"> # Get the minimum valid revision and check it
</span><span class="cx"> minValidRevision = yield self.transactionUnderTest().calendarserverValue("MIN-VALID-REVISION")
</span><span class="cx"> self.assertEqual(int(minValidRevision), max([row[3] for row in group1Rows + group2Rows]))
</span><span class="cx">
</span><span class="cx"> # do RevisionCleanupWork
</span><del>- wp = yield self.transactionUnderTest().enqueue(RevisionCleanupWork, notBefore=datetime.datetime.utcnow())
</del><ins>+ yield self.transactionUnderTest().enqueue(RevisionCleanupWork, notBefore=datetime.datetime.utcnow())
</ins><span class="cx"> yield self.commit()
</span><del>- yield wp.whenExecuted()
</del><ins>+ yield JobItem.waitEmpty(self.storeUnderTest().newTransaction, reactor, 60)
</ins><span class="cx">
</span><span class="cx"> group1Rows = yield Select(
</span><span class="cx"> [aboMembers.GROUP_ID,
</span></span></pre></div>
<a id="CalendarServertrunktxdavdpstesttest_clientpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/dps/test/test_client.py (13472 => 13473)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/dps/test/test_client.py        2014-05-14 19:50:12 UTC (rev 13472)
+++ CalendarServer/trunk/txdav/dps/test/test_client.py        2014-05-14 20:10:58 UTC (rev 13473)
</span><span class="lines">@@ -63,7 +63,6 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>-
</del><span class="cx"> class DPSClientSingleDirectoryTest(unittest.TestCase):
</span><span class="cx"> """
</span><span class="cx"> Tests the client against a single directory service (as opposed to the
</span><span class="lines">@@ -301,8 +300,6 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>-
-
</del><span class="cx"> class DPSClientAugmentedAggregateDirectoryTest(StoreTestCase):
</span><span class="cx"> """
</span><span class="cx"> Similar to the above tests, but in the context of the directory structure
</span></span></pre></div>
<a id="CalendarServertrunktxdavwhogroupspy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/who/groups.py (13472 => 13473)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/who/groups.py        2014-05-14 19:50:12 UTC (rev 13472)
+++ CalendarServer/trunk/txdav/who/groups.py        2014-05-14 20:10:58 UTC (rev 13473)
</span><span class="lines">@@ -21,7 +21,7 @@
</span><span class="cx">
</span><span class="cx"> from twext.enterprise.dal.record import fromTable
</span><span class="cx"> from twext.enterprise.dal.syntax import Delete, Select
</span><del>-from twext.enterprise.jobqueue import WorkItem, PeerConnectionPool
</del><ins>+from twext.enterprise.jobqueue import WorkItem
</ins><span class="cx"> from twext.python.log import Logger
</span><span class="cx"> from twisted.internet.defer import inlineCallbacks, returnValue
</span><span class="cx"> from twistedcaldav.config import config
</span><span class="lines">@@ -109,11 +109,9 @@
</span><span class="cx">
</span><span class="cx"> def schedulePolledGroupCachingUpdate(store):
</span><span class="cx"> """
</span><del>- Schedules a group caching update work item in "the past" so
- PeerConnectionPool's overdue-item logic picks it up quickly.
</del><ins>+ Schedules a group caching update work item to run immediately.
</ins><span class="cx"> """
</span><del>- seconds = -PeerConnectionPool.queueProcessTimeout
- return scheduleNextGroupCachingUpdate(store, seconds)
</del><ins>+ return scheduleNextGroupCachingUpdate(store, 0)
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -164,7 +162,7 @@
</span><span class="cx"> group = property(
</span><span class="cx"> lambda self: "{0}, {1}".format(self.groupID, self.resourceID)
</span><span class="cx"> )
</span><del>-
</del><ins>+
</ins><span class="cx"> @classmethod
</span><span class="cx"> @inlineCallbacks
</span><span class="cx"> def _schedule(cls, txn, eventID, groupID, seconds):
</span><span class="lines">@@ -435,9 +433,9 @@
</span><span class="cx"> wps = []
</span><span class="cx"> for [eventID] in rows:
</span><span class="cx"> wp = yield GroupAttendeeReconciliationWork._schedule(
</span><del>- txn,
- eventID=eventID,
- groupID=groupID,
</del><ins>+ txn,
+ eventID=eventID,
+ groupID=groupID,
</ins><span class="cx"> seconds=float(config.GroupAttendees.ReconciliationDelaySeconds)
</span><span class="cx"> )
</span><span class="cx"> wps.append(wp)
</span></span></pre></div>
<a id="CalendarServertrunktxdavwhotesttest_group_attendeespy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/who/test/test_group_attendees.py (13472 => 13473)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/who/test/test_group_attendees.py        2014-05-14 19:50:12 UTC (rev 13472)
+++ CalendarServer/trunk/txdav/who/test/test_group_attendees.py        2014-05-14 20:10:58 UTC (rev 13473)
</span><span class="lines">@@ -20,8 +20,10 @@
</span><span class="cx">
</span><span class="cx"> import os
</span><span class="cx">
</span><ins>+from twext.enterprise.jobqueue import JobItem
</ins><span class="cx"> from twext.python.filepath import CachingFilePath as FilePath
</span><span class="cx"> from twext.who.directory import DirectoryService
</span><ins>+from twisted.internet import reactor
</ins><span class="cx"> from twisted.internet.defer import inlineCallbacks, returnValue
</span><span class="cx"> from twisted.trial import unittest
</span><span class="cx"> from twistedcaldav.config import config
</span><span class="lines">@@ -503,7 +505,7 @@
</span><span class="cx"> wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), "20000000-0000-0000-0000-000000000001")
</span><span class="cx"> yield self.commit()
</span><span class="cx"> self.assertEqual(len(wps), 1)
</span><del>- yield wps[0].whenExecuted()
</del><ins>+ yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
</ins><span class="cx">
</span><span class="cx"> cobj = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-000000000002")
</span><span class="cx"> vcalendar = yield cobj.component()
</span><span class="lines">@@ -516,7 +518,7 @@
</span><span class="cx"> wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), "20000000-0000-0000-0000-000000000001")
</span><span class="cx"> yield self.commit()
</span><span class="cx"> self.assertEqual(len(wps), 1)
</span><del>- yield wps[0].whenExecuted()
</del><ins>+ yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
</ins><span class="cx">
</span><span class="cx"> cobj = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-000000000002")
</span><span class="cx"> vcalendar = yield cobj.component()
</span><span class="lines">@@ -638,8 +640,7 @@
</span><span class="cx"> wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), "20000000-0000-0000-0000-000000000001")
</span><span class="cx"> yield self.commit()
</span><span class="cx"> self.assertEqual(len(wps), len(userRange))
</span><del>- for wp in wps:
- yield wp.whenExecuted()
</del><ins>+ yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
</ins><span class="cx">
</span><span class="cx"> for i in userRange:
</span><span class="cx"> cobj = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-00000000000{0}".format(i))
</span><span class="lines">@@ -653,8 +654,7 @@
</span><span class="cx"> wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), "20000000-0000-0000-0000-000000000001")
</span><span class="cx"> yield self.commit()
</span><span class="cx"> self.assertEqual(len(wps), len(userRange))
</span><del>- for wp in wps:
- yield wp.whenExecuted()
</del><ins>+ yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
</ins><span class="cx">
</span><span class="cx"> for i in userRange:
</span><span class="cx"> cobj = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-00000000000{0}".format(i))
</span><span class="lines">@@ -760,7 +760,7 @@
</span><span class="cx"> wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), "20000000-0000-0000-0000-000000000001")
</span><span class="cx"> yield self.commit()
</span><span class="cx"> self.assertEqual(len(wps), 1)
</span><del>- yield wps[0].whenExecuted()
</del><ins>+ yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
</ins><span class="cx">
</span><span class="cx"> cobj = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-000000000002")
</span><span class="cx"> vcalendar = yield cobj.component()
</span><span class="lines">@@ -779,6 +779,9 @@
</span><span class="cx"> self.assertEqual(normalize_iCalStr(vcalendar), normalize_iCalStr(data_get_2))
</span><span class="cx">
</span><span class="cx"> wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), "20000000-0000-0000-0000-000000000001")
</span><ins>+ if len(wps): # This is needed because the test currently fails and does actually create job items we have to wait for
+ yield self.commit()
+ yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
</ins><span class="cx"> self.assertEqual(len(wps), 0)
</span><span class="cx">
</span><span class="cx"> test_groupChangeOldEvent.todo = "Doesn't work yet"
</span><span class="lines">@@ -916,7 +919,7 @@
</span><span class="cx"> wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), "20000000-0000-0000-0000-000000000002")
</span><span class="cx"> yield self.commit()
</span><span class="cx"> self.assertEqual(len(wps), 1)
</span><del>- yield wps[0].whenExecuted()
</del><ins>+ yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
</ins><span class="cx">
</span><span class="cx"> cobj = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-000000000001")
</span><span class="cx"> vcalendar = yield cobj.component()
</span><span class="lines">@@ -928,7 +931,7 @@
</span><span class="cx"> wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), "20000000-0000-0000-0000-000000000002")
</span><span class="cx"> yield self.commit()
</span><span class="cx"> self.assertEqual(len(wps), 1)
</span><del>- yield wps[0].whenExecuted()
</del><ins>+ yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
</ins><span class="cx">
</span><span class="cx"> cobj = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-000000000001")
</span><span class="cx"> vcalendar = yield cobj.component()
</span><span class="lines">@@ -947,7 +950,7 @@
</span><span class="cx"> wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), "20000000-0000-0000-0000-000000000002")
</span><span class="cx"> self.assertEqual(len(wps), 1)
</span><span class="cx"> yield self.commit()
</span><del>- yield wps[0].whenExecuted()
</del><ins>+ yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
</ins><span class="cx">
</span><span class="cx"> cobj = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-000000000001")
</span><span class="cx"> vcalendar = yield cobj.component()
</span><span class="lines">@@ -1072,11 +1075,11 @@
</span><span class="cx"> wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), "20000000-0000-0000-0000-000000000002")
</span><span class="cx"> yield self.commit()
</span><span class="cx"> self.assertEqual(len(wps), 1)
</span><del>- yield wps[0].whenExecuted()
</del><ins>+ yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
</ins><span class="cx"> wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), "20000000-0000-0000-0000-000000000003")
</span><span class="cx"> yield self.commit()
</span><span class="cx"> self.assertEqual(len(wps), 1)
</span><del>- yield wps[0].whenExecuted()
</del><ins>+ yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
</ins><span class="cx">
</span><span class="cx"> cobj = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="10000000-0000-0000-0000-000000000001")
</span><span class="cx"> vcalendar = yield cobj.component()
</span></span></pre>
</div>
</div>
</body>
</html>