public class KetchSystem extends Object
This class provides useful defaults for testing and small proof of concepts. Full scale installations are expected to subclass and override methods to provide consistent configuration across all managed repositories.
Servers should configure their own ScheduledExecutorService
.
Constructor and Description |
---|
KetchSystem()
Create a default system with a thread pool of 1 thread per CPU.
|
KetchSystem(ScheduledExecutorService executor,
MonotonicClock clock,
String txnNamespace)
Create a Ketch system with the provided executor service.
|
Modifier and Type | Method and Description |
---|---|
KetchLeader |
createLeader(Repository repo)
Construct the KetchLeader instance of a repository.
|
protected List<KetchReplica> |
createReplicas(KetchLeader leader,
Repository repo)
Get the collection of replicas for a repository.
|
static ScheduledExecutorService |
defaultExecutor() |
MonotonicClock |
getClock() |
ScheduledExecutorService |
getExecutor() |
Duration |
getMaxWaitForMonotonicClock() |
String |
getTxnAccepted() |
String |
getTxnCommitted() |
String |
getTxnNamespace()
Get the namespace used for the RefTree graph and transaction management.
|
String |
getTxnStage() |
PersonIdent |
newCommitter(ProposedTimestamp time) |
String |
newLeaderTag()
Construct a random tag to identify a candidate during leader election.
|
boolean |
requireMonotonicLeaderElections() |
public KetchSystem()
public KetchSystem(ScheduledExecutorService executor, MonotonicClock clock, String txnNamespace)
executor
- thread pool to run background operations.clock
- clock to create timestamps.txnNamespace
- reference namespace for the RefTree graph and associated
transaction state. Must begin with "refs/"
and end
with '/'
, for example "refs/txn/"
.public static ScheduledExecutorService defaultExecutor()
public ScheduledExecutorService getExecutor()
public MonotonicClock getClock()
public Duration getMaxWaitForMonotonicClock()
getClock()
's
ProposedTimestamp
used in commits proposed to the RefTree
graph (getTxnAccepted()
). Defaults to 5 seconds.public boolean requireMonotonicLeaderElections()
MonotonicClock
.public String getTxnNamespace()
"refs/txn/"
.public String getTxnAccepted()
public String getTxnCommitted()
public String getTxnStage()
"refs/txn/stage/"
.public PersonIdent newCommitter(ProposedTimestamp time)
time
- timestamp for the committer.@Nullable public String newLeaderTag()
Multiple processes trying to elect themselves leaders at exactly the same
time (rounded to seconds) using the same
newCommitter(ProposedTimestamp)
identity strings, for the same
term, may generate the same ObjectId for the election commit and falsely
assume they have both won.
Candidates add this tag to their election ballot commit to disambiguate
the election. The tag only needs to be unique for a given triplet of
newCommitter(ProposedTimestamp)
, system time (rounded to
seconds), and term. If every replica in the system uses a unique
newCommitter
(such as including the host name after the
"@"
in the email address) the tag could be the empty string.
The default implementation generates a few bytes of random data.
newCommitter()
is
sufficiently unique to identify the leader.public KetchLeader createLeader(Repository repo) throws URISyntaxException
repo
- local repository stored by the leader.URISyntaxException
- a follower configuration contains an unsupported URI.protected List<KetchReplica> createReplicas(KetchLeader leader, Repository repo) throws URISyntaxException
The collection of replicas must include the local repository.
leader
- the leader driving these replicas.repo
- repository to get the replicas of.URISyntaxException
- a configured URI is invalid.Copyright © 2017 Eclipse JGit Project. All rights reserved.