You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ji...@apache.org on 2019/04/13 12:47:37 UTC

[incubator-iotdb] 01/01: add DisabledMemController

This is an automated email from the ASF dual-hosted git repository.

jiangtian pushed a commit to branch add_disabled_mem_control
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git

commit e4c192ce1b6acbc116f3d7f5c65d270dcff651b0
Author: 江天 <jt...@163.com>
AuthorDate: Sat Apr 13 20:46:21 2019 +0800

    add DisabledMemController
---
 iotdb/iotdb/conf/iotdb-engine.properties           |  1 +
 .../db/engine/memcontrol/BasicMemController.java   |  6 ++-
 .../engine/memcontrol/DisabledMemController.java   | 56 ++++++++++++++++++++++
 3 files changed, 61 insertions(+), 2 deletions(-)

diff --git a/iotdb/iotdb/conf/iotdb-engine.properties b/iotdb/iotdb/conf/iotdb-engine.properties
index 5c7046f..c91cec7 100644
--- a/iotdb/iotdb/conf/iotdb-engine.properties
+++ b/iotdb/iotdb/conf/iotdb-engine.properties
@@ -146,6 +146,7 @@ mem_monitor_interval=1000
 # Decide how to control memory used by inserting data.
 # 0 is RecordMemController, which count the size of every record (tuple).
 # 1 is JVMMemController, which use JVM heap memory as threshold.
+# 2 is DisabledMemController, which does not control memory usage.
 mem_controller_type=0
 
 # When a bufferwrite's metadata size (in byte) exceed this, the bufferwrite is forced closed.
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/engine/memcontrol/BasicMemController.java b/iotdb/src/main/java/org/apache/iotdb/db/engine/memcontrol/BasicMemController.java
index fe6753a..87e04de 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/engine/memcontrol/BasicMemController.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/engine/memcontrol/BasicMemController.java
@@ -52,8 +52,10 @@ public abstract class BasicMemController implements IService {
       case JVM:
         return JVMMemController.getInstance();
       case RECORD:
-      default:
         return RecordMemController.getInstance();
+      case DISABLED:
+      default:
+        return DisabledMemController.getInstance();
     }
   }
 
@@ -155,7 +157,7 @@ public abstract class BasicMemController implements IService {
   public abstract void reportFree(Object user, long freeSize);
 
   public enum ControllerType {
-    RECORD, JVM
+    RECORD, JVM, DISABLED
   }
 
   public enum UsageLevel {
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/engine/memcontrol/DisabledMemController.java b/iotdb/src/main/java/org/apache/iotdb/db/engine/memcontrol/DisabledMemController.java
new file mode 100644
index 0000000..05b2284
--- /dev/null
+++ b/iotdb/src/main/java/org/apache/iotdb/db/engine/memcontrol/DisabledMemController.java
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iotdb.db.engine.memcontrol;
+
+import org.apache.iotdb.db.conf.IoTDBConfig;
+
+/**
+ * DisabledMemController is used when the overhead of memory control is too high.
+ */
+public class DisabledMemController extends BasicMemController {
+
+  DisabledMemController(IoTDBConfig config) {
+    super(config);
+  }
+
+  @Override
+  public long getTotalUsage() {
+    return 0;
+  }
+
+  @Override
+  public UsageLevel getCurrLevel() {
+    return UsageLevel.SAFE;
+  }
+
+  @Override
+  public void clear() {
+
+  }
+
+  @Override
+  public UsageLevel reportUse(Object user, long usage) {
+    return UsageLevel.SAFE;
+  }
+
+  @Override
+  public void reportFree(Object user, long freeSize) {
+
+  }
+}