From 2069fb21055a0623e79301e44a6960eca1f0faec Mon Sep 17 00:00:00 2001 From: Jackie Han Date: Thu, 21 Sep 2023 10:56:23 -0700 Subject: [PATCH] correct checkstyle errors Signed-off-by: Jackie Han --- .../flowframework/constant/CommonName.java | 3 +++ .../flowframework/constant/CommonValue.java | 3 +++ .../exception/FlowFrameworkException.java | 3 +++ .../indices/FlowFrameworkIndex.java | 3 +++ .../indices/FlowFrameworkIndicesHandler.java | 23 +++++++++++++++++-- 5 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/opensearch/flowframework/constant/CommonName.java b/src/main/java/org/opensearch/flowframework/constant/CommonName.java index ee4ed9642..701fa6d8a 100644 --- a/src/main/java/org/opensearch/flowframework/constant/CommonName.java +++ b/src/main/java/org/opensearch/flowframework/constant/CommonName.java @@ -8,6 +8,9 @@ */ package org.opensearch.flowframework.constant; +/** + * Representation of common names that used across the project + */ public class CommonName { public static final String GLOBAL_CONTEXT_INDEX_NAME = ".opensearch-flow-framework-global-context"; diff --git a/src/main/java/org/opensearch/flowframework/constant/CommonValue.java b/src/main/java/org/opensearch/flowframework/constant/CommonValue.java index a2d427836..c166833f9 100644 --- a/src/main/java/org/opensearch/flowframework/constant/CommonValue.java +++ b/src/main/java/org/opensearch/flowframework/constant/CommonValue.java @@ -8,6 +8,9 @@ */ package org.opensearch.flowframework.constant; +/** + * Representation of common values that are used across project + */ public class CommonValue { public static Integer NO_SCHEMA_VERSION = 0; diff --git a/src/main/java/org/opensearch/flowframework/exception/FlowFrameworkException.java b/src/main/java/org/opensearch/flowframework/exception/FlowFrameworkException.java index d976b107f..899bbffc9 100644 --- a/src/main/java/org/opensearch/flowframework/exception/FlowFrameworkException.java +++ b/src/main/java/org/opensearch/flowframework/exception/FlowFrameworkException.java @@ -8,6 +8,9 @@ */ package org.opensearch.flowframework.exception; +/** + * Representation of Flow Framework Exceptions + */ public class FlowFrameworkException extends RuntimeException { /** * Constructor with error message. diff --git a/src/main/java/org/opensearch/flowframework/indices/FlowFrameworkIndex.java b/src/main/java/org/opensearch/flowframework/indices/FlowFrameworkIndex.java index b18ab7b57..8dd9e1f30 100644 --- a/src/main/java/org/opensearch/flowframework/indices/FlowFrameworkIndex.java +++ b/src/main/java/org/opensearch/flowframework/indices/FlowFrameworkIndex.java @@ -12,6 +12,9 @@ import static org.opensearch.flowframework.constant.CommonValue.GLOBAL_CONTEXT_INDEX_MAPPING; import static org.opensearch.flowframework.constant.CommonValue.GLOBAL_CONTEXT_INDEX_SCHEMA_VERSION; +/** + * An enumeration of Flow Framework indices + */ public enum FlowFrameworkIndex { GLOBAL_CONTEXT(GLOBAL_CONTEXT_INDEX_NAME, GLOBAL_CONTEXT_INDEX_MAPPING, GLOBAL_CONTEXT_INDEX_SCHEMA_VERSION); diff --git a/src/main/java/org/opensearch/flowframework/indices/FlowFrameworkIndicesHandler.java b/src/main/java/org/opensearch/flowframework/indices/FlowFrameworkIndicesHandler.java index 55911c40c..ca64700d7 100644 --- a/src/main/java/org/opensearch/flowframework/indices/FlowFrameworkIndicesHandler.java +++ b/src/main/java/org/opensearch/flowframework/indices/FlowFrameworkIndicesHandler.java @@ -26,8 +26,13 @@ import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; -import static org.opensearch.flowframework.constant.CommonValue.*; +import static org.opensearch.flowframework.constant.CommonValue.META; +import static org.opensearch.flowframework.constant.CommonValue.NO_SCHEMA_VERSION; +import static org.opensearch.flowframework.constant.CommonValue.SCHEMA_VERSION_FIELD; +/** + * Flow Framework Indices Handler + */ public class FlowFrameworkIndicesHandler { private static final Logger logger = LogManager.getLogger(FlowFrameworkIndicesHandler.class); @@ -37,6 +42,11 @@ public class FlowFrameworkIndicesHandler { private ClusterService clusterService; private Client client; + /** + * Handler constructor + * @param clusterService cluster service + * @param client client + */ public FlowFrameworkIndicesHandler(ClusterService clusterService, Client client) { this.clusterService = clusterService; this.client = client; @@ -48,10 +58,19 @@ public FlowFrameworkIndicesHandler(ClusterService clusterService, Client client) } } + /** + * Initiate global context index if it's absent + * @param listener action listner + */ public void initGlobalContextIndexIfAbsent(ActionListener listener) { initFlowFrameworkIndexIfAbsent(FlowFrameworkIndex.GLOBAL_CONTEXT, listener); } + /** + * General method for initiate flow framework indices or update index mapping if it's needed + * @param index flow framework index + * @param listener action listener + */ public void initFlowFrameworkIndexIfAbsent(FlowFrameworkIndex index, ActionListener listener) { String indexName = index.getIndexName(); String mapping = index.getMapping(); @@ -135,7 +154,7 @@ public void initFlowFrameworkIndexIfAbsent(FlowFrameworkIndex index, ActionListe * @param newVersion new index mapping version * @param listener action listener, if update index is needed, will pass true to its onResponse method */ - public void shouldUpdateIndex(String indexName, Integer newVersion, ActionListener listener) { + private void shouldUpdateIndex(String indexName, Integer newVersion, ActionListener listener) { IndexMetadata indexMetaData = clusterService.state().getMetadata().indices().get(indexName); if (indexMetaData == null) { listener.onResponse(Boolean.FALSE);