This is an automated email from the ASF dual-hosted git repository.
spricoder pushed a commit to branch feature/memory_auto
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/feature/memory_auto by this
push:
new bccae9dce0f Add test log
bccae9dce0f is described below
commit bccae9dce0f89be8bf4e08828e0522c0134d3ae3
Author: spricoder <[email protected]>
AuthorDate: Sat Feb 22 14:36:09 2025 +0800
Add test log
---
.../apache/iotdb/commons/memory/MemoryManager.java | 19 -------------------
.../iotdb/commons/memory/MemoryRuntimeAgent.java | 21 +++++++++++++++++++++
2 files changed, 21 insertions(+), 19 deletions(-)
diff --git
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/memory/MemoryManager.java
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/memory/MemoryManager.java
index e4d9786a260..7b7587a76c2 100644
---
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/memory/MemoryManager.java
+++
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/memory/MemoryManager.java
@@ -19,8 +19,6 @@
package org.apache.iotdb.commons.memory;
-import org.apache.iotdb.commons.conf.CommonConfig;
-import org.apache.iotdb.commons.conf.CommonDescriptor;
import org.apache.iotdb.commons.utils.TestOnly;
import org.slf4j.Logger;
@@ -32,9 +30,6 @@ import java.util.function.LongUnaryOperator;
public class MemoryManager {
private static final Logger LOGGER =
LoggerFactory.getLogger(MemoryManager.class);
- private static final CommonConfig CONFIG =
CommonDescriptor.getInstance().getConfig();
- private static final boolean ENABLE_MEMORY_TRANSFER =
CONFIG.isEnableMemoryTransfer();
- private static final long MEMORY_CHECK_INTERVAL_IN_S =
CONFIG.getMemoryCheckIntervalInS();
/** The max retry times for memory allocation */
private static final int MEMORY_ALLOCATE_MAX_RETRIES = 3;
@@ -503,20 +498,6 @@ public class MemoryManager {
private static final MemoryManager GLOBAL =
new MemoryManager("GlobalMemoryManager", null,
Runtime.getRuntime().totalMemory());
- static {
- LOGGER.info(
- "{} Enable automatic memory transfer with an interval of {} s",
- ENABLE_MEMORY_TRANSFER,
- MEMORY_CHECK_INTERVAL_IN_S);
- if (ENABLE_MEMORY_TRANSFER) {
- MemoryRuntimeAgent.getInstance()
- .registerPeriodicalJob(
- "GlobalMemoryManager#updateAllocate()",
- MemoryManagerHolder.GLOBAL::updateAllocate,
- MEMORY_CHECK_INTERVAL_IN_S);
- }
- }
-
private MemoryManagerHolder() {}
}
diff --git
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/memory/MemoryRuntimeAgent.java
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/memory/MemoryRuntimeAgent.java
index e8611339759..a6ec5f343aa 100644
---
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/memory/MemoryRuntimeAgent.java
+++
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/memory/MemoryRuntimeAgent.java
@@ -21,13 +21,22 @@ package org.apache.iotdb.commons.memory;
import org.apache.iotdb.commons.concurrent.IoTDBThreadPoolFactory;
import org.apache.iotdb.commons.concurrent.ThreadName;
+import org.apache.iotdb.commons.conf.CommonConfig;
+import org.apache.iotdb.commons.conf.CommonDescriptor;
import org.apache.iotdb.commons.exception.StartupException;
import org.apache.iotdb.commons.service.IService;
import org.apache.iotdb.commons.service.ServiceType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.util.concurrent.atomic.AtomicBoolean;
public class MemoryRuntimeAgent implements IService {
+ private static final Logger LOGGER =
LoggerFactory.getLogger(MemoryRuntimeAgent.class);
+ private static final CommonConfig CONFIG =
CommonDescriptor.getInstance().getConfig();
+ private static final boolean ENABLE_MEMORY_TRANSFER =
CONFIG.isEnableMemoryTransfer();
+ private static final long MEMORY_CHECK_INTERVAL_IN_S =
CONFIG.getMemoryCheckIntervalInS();
private final AtomicBoolean isShutdown = new AtomicBoolean(false);
private static final MemoryPeriodicalJobExecutor memoryPeriodicalJobExecutor
=
@@ -40,6 +49,18 @@ public class MemoryRuntimeAgent implements IService {
public void start() throws StartupException {
memoryPeriodicalJobExecutor.start();
+ LOGGER.info(
+ "{} Enable automatic memory transfer with an interval of {} s",
+ ENABLE_MEMORY_TRANSFER,
+ MEMORY_CHECK_INTERVAL_IN_S);
+ if (ENABLE_MEMORY_TRANSFER) {
+ MemoryRuntimeAgent.getInstance()
+ .registerPeriodicalJob(
+ "GlobalMemoryManager#updateAllocate()",
+ MemoryManager.global()::updateAllocate,
+ MEMORY_CHECK_INTERVAL_IN_S);
+ }
+
isShutdown.set(false);
}