DataNode: Added new state so that we don't automatically start (#17952)

* added new states

* fix error message

* adding new state to test

* removed doubled line

* start if insecure has been chosen

* adding jump

* always start if everything's confgured

* fixing test
This commit is contained in:
Jan Heise
2024-01-29 12:59:37 +01:00
committed by GitHub
parent 795f008e00
commit ac4caca1b4
13 changed files with 107 additions and 30 deletions

View File

@@ -17,6 +17,7 @@
package org.graylog.datanode.process;
public enum ProcessEvent {
PROCESS_PREPARED,
PROCESS_STARTED,
HEALTH_CHECK_OK,
HEALTH_CHECK_FAILED,

View File

@@ -23,6 +23,10 @@ public enum ProcessState {
* Fresh created process, not started yet
*/
WAITING_FOR_CONFIGURATION(DataNodeStatus.UNCONFIGURED),
/**
* All configuration files have been written
*/
PREPARED(DataNodeStatus.PREPARED),
/**
* The process is running on the underlying OS and has a process ID. It's not responding to the REST API yet
*/

View File

@@ -38,6 +38,12 @@ public class ProcessStateMachine {
// Freshly created process, it hasn't started yet and doesn't have any pid.
config.configure(ProcessState.WAITING_FOR_CONFIGURATION)
.permit(ProcessEvent.PROCESS_PREPARED, ProcessState.PREPARED)
// jump to started only allowed to facilitate startup with insecure config
.permit(ProcessEvent.PROCESS_STARTED, ProcessState.STARTING)
.ignore(ProcessEvent.HEALTH_CHECK_FAILED);
config.configure(ProcessState.PREPARED)
.permit(ProcessEvent.PROCESS_STARTED, ProcessState.STARTING)
.permit(ProcessEvent.PROCESS_TERMINATED, ProcessState.TERMINATED)
.permit(ProcessEvent.PROCESS_STOPPED, ProcessState.TERMINATED)