From 1b8a75ce8f8817d4512345c3b70ff4338492b986 Mon Sep 17 00:00:00 2001 From: zane-neo Date: Wed, 15 Nov 2023 10:28:07 +0800 Subject: [PATCH] format code Signed-off-by: zane-neo --- .../autoredeploy/MLModelAutoReDeployer.java | 2 +- .../MLCommonsClusterManagerEventListener.java | 13 ++++++---- .../opensearch/ml/cluster/MLSyncUpCron.java | 24 +++++++++---------- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/plugin/src/main/java/org/opensearch/ml/autoredeploy/MLModelAutoReDeployer.java b/plugin/src/main/java/org/opensearch/ml/autoredeploy/MLModelAutoReDeployer.java index 01b4078984..ff774ac0be 100644 --- a/plugin/src/main/java/org/opensearch/ml/autoredeploy/MLModelAutoReDeployer.java +++ b/plugin/src/main/java/org/opensearch/ml/autoredeploy/MLModelAutoReDeployer.java @@ -18,7 +18,6 @@ import java.util.function.Consumer; import java.util.stream.Collectors; -import lombok.Setter; import org.opensearch.action.search.SearchAction; import org.opensearch.action.search.SearchRequestBuilder; import org.opensearch.action.search.SearchResponse; @@ -51,6 +50,7 @@ import lombok.Builder; import lombok.Data; +import lombok.Setter; import lombok.extern.log4j.Log4j2; @Log4j2 diff --git a/plugin/src/main/java/org/opensearch/ml/cluster/MLCommonsClusterManagerEventListener.java b/plugin/src/main/java/org/opensearch/ml/cluster/MLCommonsClusterManagerEventListener.java index a741571187..71ccfb9569 100644 --- a/plugin/src/main/java/org/opensearch/ml/cluster/MLCommonsClusterManagerEventListener.java +++ b/plugin/src/main/java/org/opensearch/ml/cluster/MLCommonsClusterManagerEventListener.java @@ -8,6 +8,8 @@ import static org.opensearch.ml.plugin.MachineLearningPlugin.GENERAL_THREAD_POOL; import static org.opensearch.ml.settings.MLCommonsSettings.ML_COMMONS_SYNC_UP_JOB_INTERVAL_IN_SECONDS; +import java.util.List; + import org.opensearch.client.Client; import org.opensearch.cluster.LocalNodeClusterManagerListener; import org.opensearch.cluster.service.ClusterService; @@ -23,8 +25,6 @@ import lombok.extern.log4j.Log4j2; -import java.util.List; - @Log4j2 public class MLCommonsClusterManagerEventListener implements LocalNodeClusterManagerListener { @@ -81,9 +81,12 @@ public void onClusterManager() { }); mlModelAutoReDeployer.setStartCronJobListener(listener); String localNodeId = clusterService.localNode().getId(); - threadPool.schedule(() -> mlModelAutoReDeployer.buildAutoReloadArrangement(List.of(localNodeId), localNodeId), - TimeValue.timeValueSeconds(jobInterval), - GENERAL_THREAD_POOL); + threadPool + .schedule( + () -> mlModelAutoReDeployer.buildAutoReloadArrangement(List.of(localNodeId), localNodeId), + TimeValue.timeValueSeconds(jobInterval), + GENERAL_THREAD_POOL + ); } private void startSyncModelRoutingCron() { diff --git a/plugin/src/main/java/org/opensearch/ml/cluster/MLSyncUpCron.java b/plugin/src/main/java/org/opensearch/ml/cluster/MLSyncUpCron.java index 801b7f0961..3a5ea83347 100644 --- a/plugin/src/main/java/org/opensearch/ml/cluster/MLSyncUpCron.java +++ b/plugin/src/main/java/org/opensearch/ml/cluster/MLSyncUpCron.java @@ -244,20 +244,20 @@ void refreshModelState(Map> modelWorkerNodes, Map planningWorkNodes = sourceAsMap.containsKey(MLModel.PLANNING_WORKER_NODES_FIELD) - ? (List) sourceAsMap.get(MLModel.PLANNING_WORKER_NODES_FIELD) - : new ArrayList<>(); + ? (List) sourceAsMap.get(MLModel.PLANNING_WORKER_NODES_FIELD) + : new ArrayList<>(); if (deployToAllNodes) { DiscoveryNode[] eligibleNodes = nodeHelper.getEligibleNodes(functionName); planningWorkerNodeCount = eligibleNodes.length; @@ -312,8 +312,8 @@ private MLModelState getNewModelState( if (currentWorkerNodeCount == 0 && state != MLModelState.DEPLOY_FAILED && !(state == MLModelState.DEPLOYING - && lastUpdateTime != null - && lastUpdateTime + DEPLOY_MODEL_TASK_GRACE_TIME_IN_MS > Instant.now().toEpochMilli())) { + && lastUpdateTime != null + && lastUpdateTime + DEPLOY_MODEL_TASK_GRACE_TIME_IN_MS > Instant.now().toEpochMilli())) { // If model not deployed to any node and no node is deploying the model, then set model state as DEPLOY_FAILED return MLModelState.DEPLOY_FAILED; }