public class SlaveUpdatePuller extends org.neo4j.kernel.lifecycle.LifecycleAdapter implements Runnable, UpdatePuller
Updates are pulled and applied using a single and dedicated thread, created in here. No other threads are allowed to
pull and apply transactions on a slave. Calling one of the pullUpdates
TransactionObligationFulfiller.fulfill(long) will poke that single thread,
so
that it gets going, if not already doing so, with its usual task of pulling updates and the caller which poked
the update thread will constantly poll to see if the transactions it is obliged to await have been applied.
Here comes a diagram of how the classes making up this functionality hangs together:
-------- 1 -------------------->(master)
/ |
| /
| v--------------------- 2 --------
(slave)
| ^ \
| | -------- 3 -----
| \ \
| \ v
| ---- 8 -----------(response unpacker)
| | ^
9 | |
(continue) 4 7
| |
v |
(obligation fulfiller)
| ^
| |
5 6
| |
v |
(update puller)
In the above picture:
transaction obligation telling the slave
which transaction it must have applied before continuingobligation fulfiller...update puller, a separate thread, to have that transaction
committed and applied. The calling thread will gently wait for that to happen.update puller will pull updates until it reaches that desired transaction id,
and might actually continue passed that point if master has more transactions. The obligation fulfiller,
constantly polling for last applied transaction
will notice when the obligation has been fulfilled.fulfill the
obligation
All communication, except actually pulling updates, work this way between slave and master. The only difference
in the pullUpdates case is that instead of receiving and fulfilling a transaction obligation,
transaction data is received and applied to store directly, in batches.
UpdatePullerUpdatePuller.Condition| Modifier and Type | Field and Description |
|---|---|
static String |
UPDATE_PULLER_THREAD_PREFIX |
NONE| Modifier and Type | Method and Description |
|---|---|
void |
init() |
boolean |
isActive() |
void |
pullUpdates()
Pull all available updates.
|
void |
pullUpdates(UpdatePuller.Condition condition,
boolean strictlyAssertActive)
Pull updates and waits for the supplied condition to be
fulfilled as part of the update pulling happening.
|
void |
run() |
void |
shutdown() |
String |
toString() |
boolean |
tryPullUpdates()
Try to pull all updates
|
public static String UPDATE_PULLER_THREAD_PREFIX
public void init()
throws Throwable
init in interface org.neo4j.kernel.lifecycle.Lifecycleinit in class org.neo4j.kernel.lifecycle.LifecycleAdapterThrowablepublic void shutdown()
throws Throwable
shutdown in interface org.neo4j.kernel.lifecycle.Lifecycleshutdown in class org.neo4j.kernel.lifecycle.LifecycleAdapterThrowablepublic void pullUpdates()
throws InterruptedException
UpdatePullerpullUpdates in interface UpdatePullerInterruptedException - in case if interrupted while waiting for updatespublic boolean tryPullUpdates()
throws InterruptedException
UpdatePullertryPullUpdates in interface UpdatePullerInterruptedException - in case if interrupted while waiting for updatespublic void pullUpdates(UpdatePuller.Condition condition, boolean strictlyAssertActive) throws InterruptedException
UpdatePullerpullUpdates in interface UpdatePullercondition - UpdatePuller.Condition to wait for.strictlyAssertActive - if true then observing an inactive update puller
will throw an IllegalStateException,InterruptedException - if we were interrupted while awaiting the condition.public boolean isActive()
Copyright © 2002–2015 The Neo4j Graph Database Project. All rights reserved.