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
ConstructorsModifierConstructorDescriptionprotectedAbstractCommandExecutor(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> Executes the specifiedCommand.protected abstract voiddoStart(Runnable onTakeLeadership, Runnable onReleaseLeadership, Runnable onTakeZoneLeadership, Runnable onReleaseZoneLeadership) Starts theCommandExecutor.protected abstract voidStops theCommandExecutor.final <T> CompletableFuture<T> Executes the specifiedCommand.final booleanReturnstrueif the executor is started.protected final booleanReturnstrueif theCommandExecutoris in the process of stopping.final booleanReturnstrueif the executor can accept theCommands making a change to the replica.final voidsetWritable(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, waitMethods inherited from interface com.linecorp.centraldogma.server.command.CommandExecutor
replicaId
-
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:CommandExecutorReturnstrueif the executor is started.- Specified by:
isStartedin interfaceCommandExecutor
-
isStopping
protected final boolean isStopping()Returnstrueif theCommandExecutoris in the process of stopping. -
start
Description copied from interface:CommandExecutorStarts the executor.- Specified by:
startin interfaceCommandExecutor
-
doStart
protected abstract void doStart(@Nullable Runnable onTakeLeadership, @Nullable Runnable onReleaseLeadership, @Nullable Runnable onTakeZoneLeadership, @Nullable Runnable onReleaseZoneLeadership) throws Exception Starts theCommandExecutor.- Throws:
Exception
-
stop
Description copied from interface:CommandExecutorStops the executor.- Specified by:
stopin interfaceCommandExecutor
-
doStop
protected abstract void doStop(@Nullable Runnable onReleaseLeadership, @Nullable Runnable onReleaseZoneLeadership) throws Exception Stops theCommandExecutor.- Throws:
Exception
-
isWritable
public final boolean isWritable()Description copied from interface:CommandExecutorReturnstrueif the executor can accept theCommands making a change to the replica.falsewould be returned if the replica is running as a read-only mode.- Specified by:
isWritablein interfaceCommandExecutor
-
setWritable
public final void setWritable(boolean writable) Description copied from interface:CommandExecutorMakes the executor read/write mode or read-only mode.- Specified by:
setWritablein interfaceCommandExecutor- Parameters:
writable-trueto make the executor read/write mode, orfalseto make it read-only mode
-
execute
Description copied from interface:CommandExecutorExecutes the specifiedCommand.- Specified by:
executein interfaceCommandExecutor- Type Parameters:
T- the type of the result to be returned- Parameters:
command- the command which is supposed to be executed
-
doExecute
Executes the specifiedCommand.- Throws:
Exception
-
statusManager
Description copied from interface:CommandExecutorReturns the status manager of this executor.- Specified by:
statusManagerin interfaceCommandExecutor
-
toString
-