Class CaldavOutboundWork
Shared by the synchronisation, whose bursts and sweep write and verify an account's copies, and by the propagation, which writes the copies of the members of a space invited to a meeting (EXO-91031). One thread and one place for the claims of both, so that two of them never write the same account's copies at once: the claim is what keeps a sweep, a burst and a space invitation from each reading "no copy yet" and writing the same meeting twice. A bean of its own because the synchronisation already depends on the propagation, and the propagation cannot depend back on it.
Two kinds of claim, because the writers do not all run on this thread. The
sweep runs on its own job's thread, beside this one, and a burst is queued
here: both claim the account's outward work (claim(long),
claimForQueue(long)). A space invitation's task claims a member's account
for one write (claimMemberWrite(long)), and runs here too. The sweep
honours both kinds. A burst honours only the first: a member's write is made
by a task on this thread, so a burst queued while it is held runs once that
task has ended, never alongside the write.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanclaim(long userIdentityId) Claims an account's outward work for a caller that runs beside this thread: the sweep.booleanclaimForQueue(long userIdentityId) Claims an account's outward work for a task about to be handed to this thread: a burst.booleanclaimMemberWrite(long userIdentityId) Claims a member's account for one write of a space invitation's task, which runs on this thread (EXO-91031).voidHands a task to the thread.voidrelease(long userIdentityId) Gives back an account's outward work claimed byclaim(long)orclaimForQueue(long).voidreleaseMemberWrite(long userIdentityId) Gives back a member's account claimed byclaimMemberWrite(long).voidstop()Stops accepting outward work when the platform is going down.
-
Constructor Details
-
CaldavOutboundWork
public CaldavOutboundWork()
-
-
Method Details
-
claim
public boolean claim(long userIdentityId) Claims an account's outward work for a caller that runs beside this thread: the sweep.Refused while anybody holds the account, a space invitation's write to it included: the sweep would write alongside it.
- Parameters:
userIdentityId- the account's user- Returns:
- true when the caller now holds it; false when somebody else does
-
claimForQueue
public boolean claimForQueue(long userIdentityId) Claims an account's outward work for a task about to be handed to this thread: a burst.Refused while a burst is already queued or running for the account, or a sweep is doing its outward work. Not refused by a space invitation's write to it: that write is made by a task on this thread, so the task queued now runs once it has ended. Turned away there, a burst asked for by a connection or a Synchronise now would lose its owed rewrites and removals, its seeding and its verification until the sweep finds the account due, for a write it could never have run alongside.
- Parameters:
userIdentityId- the account's user- Returns:
- true when the caller now holds it; false when another burst or a sweep does
-
release
public void release(long userIdentityId) Gives back an account's outward work claimed byclaim(long)orclaimForQueue(long).- Parameters:
userIdentityId- the account's user
-
claimMemberWrite
public boolean claimMemberWrite(long userIdentityId) Claims a member's account for one write of a space invitation's task, which runs on this thread (EXO-91031).Refused while a burst is queued or running for the account, a sweep is doing its outward work, or another such write holds it.
- Parameters:
userIdentityId- the member- Returns:
- true when the caller now holds the account for the write; false when somebody else holds it
-
releaseMemberWrite
public void releaseMemberWrite(long userIdentityId) Gives back a member's account claimed byclaimMemberWrite(long).- Parameters:
userIdentityId- the member
-
execute
Hands a task to the thread.- Parameters:
task- the work- Throws:
RejectedExecutionException- when the queue is full or the platform is going down
-
stop
@PreDestroy public void stop()Stops accepting outward work when the platform is going down.shutdownand notshutdownNow: a copy half written is a copy the verification pass has to reconcile later, so the task in flight is let finish rather than interrupted. The tasks already queued keep running until the JVM exits, the thread being a daemon; those it does not reach are dropped, and the sweep writes their copies after the next start, for the meetings within its window (seedDays).
-