From 2110130abdb3c96682db72989740cacd81a6e736 Mon Sep 17 00:00:00 2001 From: David Roberts Date: Fri, 8 Dec 2023 19:53:22 +0000 Subject: [PATCH] Different fixes --- .../core/ml/job/process/autodetect/state/ModelSizeStats.java | 1 - .../ml/job/process/autodetect/AutodetectProcessManager.java | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/state/ModelSizeStats.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/state/ModelSizeStats.java index 297f7c1a65b22..3812c012e2a3d 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/state/ModelSizeStats.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/state/ModelSizeStats.java @@ -533,7 +533,6 @@ public static class Builder { public Builder(String jobId) { this.jobId = jobId; memoryStatus = MemoryStatus.OK; - assignmentMemoryBasis = AssignmentMemoryBasis.MODEL_MEMORY_LIMIT; categorizationStatus = CategorizationStatus.OK; logTime = new Date(); } diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManager.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManager.java index f685afc788adc..658db2997485d 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManager.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManager.java @@ -1071,7 +1071,8 @@ public ByteSizeValue getOpenProcessMemoryUsage() { for (ProcessContext processContext : processByAllocation.values()) { if (processContext.getState() == ProcessContext.ProcessStateName.RUNNING) { ModelSizeStats modelSizeStats = processContext.getAutodetectCommunicator().getModelSizeStats(); - memoryUsedBytes += switch (modelSizeStats.getAssignmentMemoryBasis()) { + ModelSizeStats.AssignmentMemoryBasis basis = modelSizeStats.getAssignmentMemoryBasis(); + memoryUsedBytes += switch (basis != null ? basis : ModelSizeStats.AssignmentMemoryBasis.MODEL_MEMORY_LIMIT) { case MODEL_MEMORY_LIMIT -> modelSizeStats.getModelBytesMemoryLimit(); case CURRENT_MODEL_BYTES -> modelSizeStats.getModelBytes(); case PEAK_MODEL_BYTES -> Optional.ofNullable(modelSizeStats.getPeakModelBytes()).orElse(modelSizeStats.getModelBytes());