Queue getMasterServiceCurrentQueue()

in src/main/java/org/opensearch/performanceanalyzer/collectors/MasterServiceEventMetrics.java [237:264]


    Queue<Runnable> getMasterServiceCurrentQueue() throws Exception {
        if (masterServiceCurrentQueue == null) {
            if (OpenSearchResources.INSTANCE.getClusterService() != null) {
                MasterService masterService =
                        OpenSearchResources.INSTANCE.getClusterService().getMasterService();

                if (masterService != null) {
                    if (prioritizedOpenSearchThreadPoolExecutor == null) {
                        prioritizedOpenSearchThreadPoolExecutor =
                                (PrioritizedOpenSearchThreadPoolExecutor)
                                        getMasterServiceTPExecutorField().get(masterService);
                    }

                    if (prioritizedOpenSearchThreadPoolExecutor != null) {
                        masterServiceCurrentQueue =
                                (Queue<Runnable>)
                                        getPrioritizedTPExecutorCurrentField()
                                                .get(prioritizedOpenSearchThreadPoolExecutor);
                    } else {
                        PerformanceAnalyzerApp.WRITER_METRICS_AGGREGATOR.updateStat(
                                WriterMetrics.MASTER_NODE_NOT_UP, "", 1);
                    }
                }
            }
        }

        return masterServiceCurrentQueue;
    }