package org.elasticsoftware.elasticactors.kubernetes.cluster.statemachine.impl;

import io.fabric8.kubernetes.api.model.apps.StatefulSet;
import org.elasticsoftware.elasticactors.kubernetes.cluster.TaskScheduler;
import org.elasticsoftware.elasticactors.kubernetes.cluster.statemachine.AbstractKubernetesStateMachine;

import java.util.concurrent.ExecutorService;

import static java.util.concurrent.Executors.newSingleThreadExecutor;

public class SingleThreadKubernetesStateMachine extends AbstractKubernetesStateMachine {

    private final ExecutorService executorService = newSingleThreadExecutor();

    public SingleThreadKubernetesStateMachine(TaskScheduler taskScheduler) {
        super(taskScheduler);
    }

    @Override
    public void handleStateUpdate(StatefulSet resource) {
        logger.info("Received state update. Submitting processing task to the Single Thread Executor Service");
        executorService.submit(() -> processStateUpdate(resource));
    }
}

@@ -595,16 +595,77 @@
 xecutor(
+r -%3E new Thread(r, %22KUBERNETES_CLUSTERSERVICE_STATE_MACHINE%22)
 );%0A%0A    

Add thread name to the state machine