public class MockQuorumFixture extends Object
QuorumClient
s running in the same JVM.
This fixture dumps the events into queues drained by a per-watcher thread.
This approximates the zookeeper behavior and ensures that each watcher sees
the events in a total order. Zookeeper promises that all watchers proceed at
the same rate. We enforce that with a globalSynchronousLock
. Once
all watchers have drained the event, the next event is made available to the
watchers.
The fixture only generates events for actual state changes. This also mimics the behavior of zookeeper.
Modifier and Type | Class and Description |
---|---|
static class |
MockQuorumFixture.MockQuorum<S extends Remote,C extends QuorumMember<S>>
Mock
Quorum implementation with increased visibility of some
methods so we can pump state changes into the MockQuorumFixture2 . |
Modifier and Type | Field and Description |
---|---|
protected static org.apache.log4j.Logger |
log |
Constructor and Description |
---|
MockQuorumFixture() |
Modifier and Type | Method and Description |
---|---|
void |
addWatcher(MockQuorumFixture.MockQuorum.MockQuorumWatcher watcher) |
void |
awaitDeque()
Deprecated.
The semantics of the
QuorumActor have been modified
to require it to block until the requested change has been
observed by the QuorumWatcher and made visible in the
local model of the quorum state maintained by the
AbstractQuorum .
If you need more control over the visibility of state changes
use |
ExecutorService |
getExecutor()
An
ExecutorService which can be used by the unit tests. |
QuorumMember<?> |
getMember(UUID serviceId)
Resolve a known
QuorumMember for the fixture. |
protected static int |
getPort(int suggestedPort)
Return an open port on current machine.
|
Object |
getService(UUID serviceId)
Resolve the service by its
UUID for any service running against
this fixture. |
void |
removeWatcher(MockQuorumFixture.MockQuorum.MockQuorumWatcher watcher) |
void |
start()
Start fixture.
|
void |
terminate()
Terminate fixture.
|
String |
toString() |
public ExecutorService getExecutor()
ExecutorService
which can be used by the unit tests.QuorumMember.getExecutor()
public QuorumMember<?> getMember(UUID serviceId)
QuorumMember
for the fixture.serviceId
- The UUID
for the QuorumMember
's service.QuorumMember
-or- null
if there is none
known for that serviceId.public Object getService(UUID serviceId)
UUID
for any service running against
this fixture.serviceId
- The UUID
for the service.QuorumException
- if there is no known QuorumMember
for that serviceId.public void start()
public void terminate()
public void awaitDeque() throws InterruptedException
QuorumActor
have been modified
to require it to block until the requested change has been
observed by the QuorumWatcher
and made visible in the
local model of the quorum state maintained by the
AbstractQuorum
.
If you need more control over the visibility of state changes
use #assertCondition(Runnable)
.
actor.memberAdd(); actor.pipelineAdd();can throw an
QuorumException
since the actor's local quorum state
in all likelihood will not have been updated before we attempt to add the
actor to the pipeline in the distributed quorum state.
However, the following sequence will succeed.
actor.memberAdd(); fixture.awaitDeque(); actor.pipelineAdd();
InterruptedException
protected static int getPort(int suggestedPort) throws IOException
IOException
public void removeWatcher(MockQuorumFixture.MockQuorum.MockQuorumWatcher watcher)
public void addWatcher(MockQuorumFixture.MockQuorum.MockQuorumWatcher watcher)
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.