@Override
    public void stop() throws Exception {
        if (fetcher != null) {
            fetcher.stop();
        }
        // TODO: change job state which is in running state.
        LOGGER.info("stopping agent manager");
        taskManager.stop();
        heartbeatManager.stop();
        agentConfMonitor.shutdown();
    }
It should guarantee thread-safe, and can be invoked many times.

@throws Exception exceptions
inlong-agent/agent-core/src/main/java/org/apache/inlong/agent/core/AgentManager.java