From 05a7364c6cfcb89eb38e94cfcfb085ef51f892e1 Mon Sep 17 00:00:00 2001 From: Bhavana Ramaram Date: Fri, 6 Oct 2023 15:58:26 -0700 Subject: [PATCH] fix format violations Signed-off-by: Bhavana Ramaram --- .../opensearch/ml/model/MLModelManager.java | 118 +++++++++--------- 1 file changed, 60 insertions(+), 58 deletions(-) diff --git a/plugin/src/main/java/org/opensearch/ml/model/MLModelManager.java b/plugin/src/main/java/org/opensearch/ml/model/MLModelManager.java index 0f8ba2ff4d..79c3f625df 100644 --- a/plugin/src/main/java/org/opensearch/ml/model/MLModelManager.java +++ b/plugin/src/main/java/org/opensearch/ml/model/MLModelManager.java @@ -5,10 +5,62 @@ package org.opensearch.ml.model; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.io.Files; -import lombok.extern.log4j.Log4j2; +import static org.opensearch.common.xcontent.XContentType.JSON; +import static org.opensearch.core.xcontent.ToXContent.EMPTY_PARAMS; +import static org.opensearch.core.xcontent.XContentParserUtils.ensureExpectedToken; +import static org.opensearch.ml.common.CommonValue.ML_CONNECTOR_INDEX; +import static org.opensearch.ml.common.CommonValue.ML_MODEL_GROUP_INDEX; +import static org.opensearch.ml.common.CommonValue.ML_MODEL_INDEX; +import static org.opensearch.ml.common.CommonValue.NOT_FOUND; +import static org.opensearch.ml.common.CommonValue.UNDEPLOYED; +import static org.opensearch.ml.common.MLModel.ALGORITHM_FIELD; +import static org.opensearch.ml.common.MLTask.ERROR_FIELD; +import static org.opensearch.ml.common.MLTask.MODEL_ID_FIELD; +import static org.opensearch.ml.common.MLTask.STATE_FIELD; +import static org.opensearch.ml.common.MLTaskState.COMPLETED; +import static org.opensearch.ml.common.MLTaskState.FAILED; +import static org.opensearch.ml.engine.ModelHelper.CHUNK_FILES; +import static org.opensearch.ml.engine.ModelHelper.CHUNK_SIZE; +import static org.opensearch.ml.engine.ModelHelper.MODEL_FILE_HASH; +import static org.opensearch.ml.engine.ModelHelper.MODEL_SIZE_IN_BYTES; +import static org.opensearch.ml.engine.algorithms.remote.RemoteModel.CLIENT; +import static org.opensearch.ml.engine.algorithms.remote.RemoteModel.CLUSTER_SERVICE; +import static org.opensearch.ml.engine.algorithms.remote.RemoteModel.SCRIPT_SERVICE; +import static org.opensearch.ml.engine.algorithms.remote.RemoteModel.XCONTENT_REGISTRY; +import static org.opensearch.ml.engine.algorithms.text_embedding.TextEmbeddingDenseModel.ML_ENGINE; +import static org.opensearch.ml.engine.algorithms.text_embedding.TextEmbeddingDenseModel.MODEL_HELPER; +import static org.opensearch.ml.engine.algorithms.text_embedding.TextEmbeddingDenseModel.MODEL_ZIP_FILE; +import static org.opensearch.ml.engine.utils.FileUtils.calculateFileHash; +import static org.opensearch.ml.engine.utils.FileUtils.deleteFileQuietly; +import static org.opensearch.ml.plugin.MachineLearningPlugin.DEPLOY_THREAD_POOL; +import static org.opensearch.ml.plugin.MachineLearningPlugin.REGISTER_THREAD_POOL; +import static org.opensearch.ml.settings.MLCommonsSettings.ML_COMMONS_MAX_DEPLOY_MODEL_TASKS_PER_NODE; +import static org.opensearch.ml.settings.MLCommonsSettings.ML_COMMONS_MAX_MODELS_PER_NODE; +import static org.opensearch.ml.settings.MLCommonsSettings.ML_COMMONS_MAX_REGISTER_MODEL_TASKS_PER_NODE; +import static org.opensearch.ml.stats.ActionName.REGISTER; +import static org.opensearch.ml.stats.MLActionLevelStat.ML_ACTION_REQUEST_COUNT; +import static org.opensearch.ml.utils.MLExceptionUtils.logException; +import static org.opensearch.ml.utils.MLNodeUtils.checkOpenCircuitBreaker; +import static org.opensearch.ml.utils.MLNodeUtils.createXContentParserFromRegistry; + +import java.io.File; +import java.nio.file.Path; +import java.security.PrivilegedActionException; +import java.time.Instant; +import java.util.Arrays; +import java.util.Base64; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.concurrent.ConcurrentLinkedDeque; +import java.util.concurrent.Semaphore; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.Supplier; + import org.apache.logging.log4j.util.Strings; import org.opensearch.OpenSearchStatusException; import org.opensearch.action.delete.DeleteRequest; @@ -71,61 +123,11 @@ import org.opensearch.search.fetch.subphase.FetchSourceContext; import org.opensearch.threadpool.ThreadPool; -import java.io.File; -import java.nio.file.Path; -import java.security.PrivilegedActionException; -import java.time.Instant; -import java.util.Arrays; -import java.util.Base64; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.concurrent.ConcurrentLinkedDeque; -import java.util.concurrent.Semaphore; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.function.Supplier; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.io.Files; -import static org.opensearch.common.xcontent.XContentType.JSON; -import static org.opensearch.core.xcontent.ToXContent.EMPTY_PARAMS; -import static org.opensearch.core.xcontent.XContentParserUtils.ensureExpectedToken; -import static org.opensearch.ml.common.CommonValue.ML_CONNECTOR_INDEX; -import static org.opensearch.ml.common.CommonValue.ML_MODEL_GROUP_INDEX; -import static org.opensearch.ml.common.CommonValue.ML_MODEL_INDEX; -import static org.opensearch.ml.common.CommonValue.NOT_FOUND; -import static org.opensearch.ml.common.CommonValue.UNDEPLOYED; -import static org.opensearch.ml.common.MLModel.ALGORITHM_FIELD; -import static org.opensearch.ml.common.MLTask.ERROR_FIELD; -import static org.opensearch.ml.common.MLTask.MODEL_ID_FIELD; -import static org.opensearch.ml.common.MLTask.STATE_FIELD; -import static org.opensearch.ml.common.MLTaskState.COMPLETED; -import static org.opensearch.ml.common.MLTaskState.FAILED; -import static org.opensearch.ml.engine.ModelHelper.CHUNK_FILES; -import static org.opensearch.ml.engine.ModelHelper.CHUNK_SIZE; -import static org.opensearch.ml.engine.ModelHelper.MODEL_FILE_HASH; -import static org.opensearch.ml.engine.ModelHelper.MODEL_SIZE_IN_BYTES; -import static org.opensearch.ml.engine.algorithms.remote.RemoteModel.CLIENT; -import static org.opensearch.ml.engine.algorithms.remote.RemoteModel.CLUSTER_SERVICE; -import static org.opensearch.ml.engine.algorithms.remote.RemoteModel.SCRIPT_SERVICE; -import static org.opensearch.ml.engine.algorithms.remote.RemoteModel.XCONTENT_REGISTRY; -import static org.opensearch.ml.engine.algorithms.text_embedding.TextEmbeddingDenseModel.ML_ENGINE; -import static org.opensearch.ml.engine.algorithms.text_embedding.TextEmbeddingDenseModel.MODEL_HELPER; -import static org.opensearch.ml.engine.algorithms.text_embedding.TextEmbeddingDenseModel.MODEL_ZIP_FILE; -import static org.opensearch.ml.engine.utils.FileUtils.calculateFileHash; -import static org.opensearch.ml.engine.utils.FileUtils.deleteFileQuietly; -import static org.opensearch.ml.plugin.MachineLearningPlugin.DEPLOY_THREAD_POOL; -import static org.opensearch.ml.plugin.MachineLearningPlugin.REGISTER_THREAD_POOL; -import static org.opensearch.ml.settings.MLCommonsSettings.ML_COMMONS_MAX_DEPLOY_MODEL_TASKS_PER_NODE; -import static org.opensearch.ml.settings.MLCommonsSettings.ML_COMMONS_MAX_MODELS_PER_NODE; -import static org.opensearch.ml.settings.MLCommonsSettings.ML_COMMONS_MAX_REGISTER_MODEL_TASKS_PER_NODE; -import static org.opensearch.ml.stats.ActionName.REGISTER; -import static org.opensearch.ml.stats.MLActionLevelStat.ML_ACTION_REQUEST_COUNT; -import static org.opensearch.ml.utils.MLExceptionUtils.logException; -import static org.opensearch.ml.utils.MLNodeUtils.checkOpenCircuitBreaker; -import static org.opensearch.ml.utils.MLNodeUtils.createXContentParserFromRegistry; +import lombok.extern.log4j.Log4j2; /** * Manager class for ML models. It contains ML model related operations like register, deploy model etc.