public void execute()

in functions/CDDKVSJava/src/main/java/com/amazonaws/greengrass/cddkvs/handlers/StartupHandler.java [54:84]


    public void execute(ImmutableGreengrassStartEvent immutableGreengrassStartEvent) {
        dispatcher.publishMessageEvent(topics.getOutputTopic(), "KVS streamer started [" + System.nanoTime() + "] [" + uuid + "]");

        Timer timer = new Timer(true);
        timer.scheduleAtFixedRate(new TimerTask() {
            private long previousSeconds = Long.MIN_VALUE;

            @Override
            public void run() {
                dispatcher.publishMessageEvent(topics.getOutputTopic(), "KVS streamer still running [" + System.nanoTime() + "] [" + uuid + "]");

                if (pipe == null) {
                    dispatcher.publishMessageEvent(topics.getOutputTopic(), "No pipe yet [" + System.nanoTime() + "] [" + uuid + "]");
                    return;
                }

                long seconds = pipe.queryPosition(TimeUnit.SECONDS);

                if (seconds == previousSeconds) {
                    dispatcher.publishMessageEvent(topics.getOutputTopic(), "Pipe is stalled, restarting [" + seconds + "] [" + System.nanoTime() + "] [" + uuid + "]");
                    System.exit(1);
                }

                previousSeconds = seconds;
                dispatcher.publishMessageEvent(topics.getOutputTopic(), "Pipe state [" + pipe.getState().name() + "] [" + seconds + "] [" + System.nanoTime() + "] [" + uuid + "]");
            }
        }, START_DELAY_MS, PERIOD_MS);

        // Start the video pipeline in a separate thread so that we can return from this function as soon as possible
        new Thread(this::startVideoPipeline).start();
    }