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()
Get default executor, one thread per available processor.
|
MonotonicClock |
getClock()
Get clock to obtain timestamps from.
|
ScheduledExecutorService |
getExecutor()
Get executor to perform background operations.
|
Duration |
getMaxWaitForMonotonicClock()
Get how long the leader will wait for the
getClock() 's
ProposedTimestamp used in commits proposed to the RefTree graph
(getTxnAccepted() ) |
String |
getTxnAccepted()
Get name of the accepted RefTree graph.
|
String |
getTxnCommitted()
Get name of the committed RefTree graph.
|
String |
getTxnNamespace()
Get the namespace used for the RefTree graph and transaction management.
|
String |
getTxnStage()
Get prefix for staged objects, e.g.
|
PersonIdent |
newCommitter(ProposedTimestamp time)
Create new committer
PersonIdent for ketch system |
String |
newLeaderTag()
Construct a random tag to identify a candidate during leader election.
|
boolean |
requireMonotonicLeaderElections()
Whether elections should require monotonically increasing commit
timestamps
|
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()
)getClock()
's
ProposedTimestamp
used in commits proposed to the RefTree
graph (getTxnAccepted()
). Defaults to 5 seconds.public boolean requireMonotonicLeaderElections()
true
if elections should require monotonically increasing
commit timestamps. This requires a very good
MonotonicClock
.public String getTxnNamespace()
"refs/txn/"
.public String getTxnAccepted()
public String getTxnCommitted()
public String getTxnStage()
"refs/txn/stage/"
."refs/txn/stage/"
.public PersonIdent newCommitter(ProposedTimestamp time)
PersonIdent
for ketch systemtime
- 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 © 2018 Eclipse JGit Project. All rights reserved.