Class AbstractCommandExecutor
java.lang.Object
com.linecorp.centraldogma.server.command.AbstractCommandExecutor
- All Implemented Interfaces:
CommandExecutor
- Direct Known Subclasses:
StandaloneCommandExecutor
Helps to implement a concrete
CommandExecutor
.-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractCommandExecutor
(Consumer<CommandExecutor> onTakeLeadership, Consumer<CommandExecutor> onReleaseLeadership, Consumer<CommandExecutor> onTakeZoneLeadership, Consumer<CommandExecutor> onReleaseZoneLeadership) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract <T> CompletableFuture
<T> protected abstract void
doStart
(Runnable onTakeLeadership, Runnable onReleaseLeadership, Runnable onTakeZoneLeadership, Runnable onReleaseZoneLeadership) protected abstract void
final <T> CompletableFuture
<T> Executes the specifiedCommand
.final boolean
Returnstrue
if the executor is started.protected final boolean
final boolean
Returnstrue
if the executor can accept theCommand
s making a change to the replica.final void
setWritable
(boolean writable) Makes the executor read/write mode or read-only mode.final CompletableFuture
<Void> start()
Starts the executor.Returns the status manager of this executor.final CompletableFuture
<Void> stop()
Stops the executor.toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.linecorp.centraldogma.server.command.CommandExecutor
replicaId, setWriteQuota
-
Constructor Details
-
AbstractCommandExecutor
protected AbstractCommandExecutor(@Nullable Consumer<CommandExecutor> onTakeLeadership, @Nullable Consumer<CommandExecutor> onReleaseLeadership, @Nullable Consumer<CommandExecutor> onTakeZoneLeadership, @Nullable Consumer<CommandExecutor> onReleaseZoneLeadership) Creates a new instance.- Parameters:
onTakeLeadership
- the callback to be invoked after the replica has taken the leadershiponReleaseLeadership
- the callback to be invoked before the replica releases the leadershiponTakeZoneLeadership
- the callback to be invoked after the replica has taken the zone leadershiponReleaseZoneLeadership
- the callback to be invoked before the replica releases the zone leadership
-
-
Method Details
-
isStarted
public final boolean isStarted()Description copied from interface:CommandExecutor
Returnstrue
if the executor is started.- Specified by:
isStarted
in interfaceCommandExecutor
-
isStopping
protected final boolean isStopping() -
start
Description copied from interface:CommandExecutor
Starts the executor.- Specified by:
start
in interfaceCommandExecutor
-
doStart
protected abstract void doStart(@Nullable Runnable onTakeLeadership, @Nullable Runnable onReleaseLeadership, @Nullable Runnable onTakeZoneLeadership, @Nullable Runnable onReleaseZoneLeadership) throws Exception - Throws:
Exception
-
stop
Description copied from interface:CommandExecutor
Stops the executor.- Specified by:
stop
in interfaceCommandExecutor
-
doStop
protected abstract void doStop(@Nullable Runnable onReleaseLeadership, @Nullable Runnable onReleaseZoneLeadership) throws Exception - Throws:
Exception
-
isWritable
public final boolean isWritable()Description copied from interface:CommandExecutor
Returnstrue
if the executor can accept theCommand
s making a change to the replica.false
would be returned if the replica is running as a read-only mode.- Specified by:
isWritable
in interfaceCommandExecutor
-
setWritable
public final void setWritable(boolean writable) Description copied from interface:CommandExecutor
Makes the executor read/write mode or read-only mode.- Specified by:
setWritable
in interfaceCommandExecutor
- Parameters:
writable
-true
to make the executor read/write mode, orfalse
to make it read-only mode
-
execute
Description copied from interface:CommandExecutor
Executes the specifiedCommand
.- Specified by:
execute
in interfaceCommandExecutor
- Type Parameters:
T
- the type of the result to be returned- Parameters:
command
- the command which is supposed to be executed
-
doExecute
- Throws:
Exception
-
statusManager
Description copied from interface:CommandExecutor
Returns the status manager of this executor.- Specified by:
statusManager
in interfaceCommandExecutor
-
toString
-