Skip to content

Commit

Permalink
correct checkstyle errors
Browse files Browse the repository at this point in the history
Signed-off-by: Jackie Han <[email protected]>
  • Loading branch information
jackiehanyang committed Sep 21, 2023
1 parent 14b9a95 commit 2069fb2
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
*/
package org.opensearch.flowframework.exception;

/**
* Representation of Flow Framework Exceptions
*/
public class FlowFrameworkException extends RuntimeException {
/**
* Constructor with error message.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -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<Boolean> 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<Boolean> listener) {
String indexName = index.getIndexName();
String mapping = index.getMapping();
Expand Down Expand Up @@ -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<Boolean> listener) {
private void shouldUpdateIndex(String indexName, Integer newVersion, ActionListener<Boolean> listener) {
IndexMetadata indexMetaData = clusterService.state().getMetadata().indices().get(indexName);
if (indexMetaData == null) {
listener.onResponse(Boolean.FALSE);
Expand Down

0 comments on commit 2069fb2

Please sign in to comment.