You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2019/06/29 12:46:23 UTC
[incubator-iotdb] branch feature_async_close_tsfile updated: add
MBean for TVListAllocator and reject set storage group when there are not
enough memtables
This is an automated email from the ASF dual-hosted git repository.
qiaojialin pushed a commit to branch feature_async_close_tsfile
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
The following commit(s) were added to refs/heads/feature_async_close_tsfile by this push:
new 1845b95 add MBean for TVListAllocator and reject set storage group when there are not enough memtables
1845b95 is described below
commit 1845b95c018c99abce24db2576a74687a780838a
Author: qiaojialin <64...@qq.com>
AuthorDate: Sat Jun 29 20:45:54 2019 +0800
add MBean for TVListAllocator and reject set storage group when there are not enough memtables
---
.../org/apache/iotdb/db/metadata/MManager.java | 7 +++-
.../java/org/apache/iotdb/db/service/IoTDB.java | 3 +-
.../org/apache/iotdb/db/service/ServiceType.java | 3 +-
.../db/utils/datastructure/TVListAllocator.java | 42 +++++++++++++++++++++-
.../utils/datastructure/TVListAllocatorMBean.java | 7 ++++
5 files changed, 58 insertions(+), 4 deletions(-)
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/metadata/MManager.java b/iotdb/src/main/java/org/apache/iotdb/db/metadata/MManager.java
index 0680025..0d827fa 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/metadata/MManager.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/metadata/MManager.java
@@ -359,11 +359,16 @@ public class MManager {
* function for setting storage level of the given path to mTree.
*/
public void setStorageLevelToMTree(String path) throws PathErrorException, IOException {
-
lock.writeLock().lock();
try {
checkAndGetDataTypeCache.clear();
mNodeCache.clear();
+ // if (current storage groups + the new storage group + the statistic storage group) * 2 > total memtable number
+ if ((seriesNumberInStorageGroups.size() + 2) * 2 > IoTDBDescriptor.getInstance().getConfig()
+ .getMemtableNumber()) {
+ throw new PathErrorException(
+ "too many storage groups, please increase the number of memtable");
+ }
mgraph.setStorageLevel(path);
seriesNumberInStorageGroups.put(path, 0);
if (writeToLog) {
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/service/IoTDB.java b/iotdb/src/main/java/org/apache/iotdb/db/service/IoTDB.java
index 57639bc..9f58fe4 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/service/IoTDB.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/service/IoTDB.java
@@ -27,8 +27,8 @@ import org.apache.iotdb.db.exception.FileNodeManagerException;
import org.apache.iotdb.db.exception.StartupException;
import org.apache.iotdb.db.exception.builder.ExceptionBuilder;
import org.apache.iotdb.db.monitor.StatMonitor;
-import org.apache.iotdb.db.query.control.FileReaderManager;
import org.apache.iotdb.db.sync.receiver.SyncServerManager;
+import org.apache.iotdb.db.utils.datastructure.TVListAllocator;
import org.apache.iotdb.db.writelog.manager.MultiFileLogNodeManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -96,6 +96,7 @@ public class IoTDB implements IoTDBMBean {
registerManager.register(StatMonitor.getInstance());
registerManager.register(BasicMemController.getInstance());
registerManager.register(SyncServerManager.getInstance());
+ registerManager.register(TVListAllocator.getInstance());
JMXService.registerMBean(getInstance(), mbeanName);
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/service/ServiceType.java b/iotdb/src/main/java/org/apache/iotdb/db/service/ServiceType.java
index 4b396f2..3b01020 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/service/ServiceType.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/service/ServiceType.java
@@ -30,7 +30,8 @@ public enum ServiceType {
JVM_MEM_CONTROL_SERVICE("Memory Controller", ""),
AUTHORIZATION_SERVICE("Authorization ServerService", ""),
FILE_READER_MANAGER_SERVICE("File reader manager ServerService", ""),
- SYNC_SERVICE("SYNC ServerService", "");
+ SYNC_SERVICE("SYNC ServerService", ""),
+ TVLIST_ALLOCATOR_SERVICE("TVList Allocator", "");
private String name;
private String jmxName;
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/utils/datastructure/TVListAllocator.java b/iotdb/src/main/java/org/apache/iotdb/db/utils/datastructure/TVListAllocator.java
index b1aeea5..f048c4c 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/utils/datastructure/TVListAllocator.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/utils/datastructure/TVListAllocator.java
@@ -23,11 +23,19 @@ import java.util.ArrayDeque;
import java.util.EnumMap;
import java.util.Map;
import java.util.Queue;
+import org.apache.iotdb.db.conf.IoTDBConstant;
+import org.apache.iotdb.db.exception.StartupException;
+import org.apache.iotdb.db.service.IService;
+import org.apache.iotdb.db.service.JMXService;
+import org.apache.iotdb.db.service.ServiceType;
import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-public class TVListAllocator {
+public class TVListAllocator implements TVListAllocatorMBean, IService {
private Map<TSDataType, Queue<TVList>> tvListCache = new EnumMap<>(TSDataType.class);
+ private String mbeanName = String
+ .format("%s:%s=%s", IoTDBConstant.IOTDB_PACKAGE, IoTDBConstant.JMX_TYPE,
+ getID().getJmxName());
private static final TVListAllocator INSTANCE = new TVListAllocator();
@@ -63,4 +71,36 @@ public class TVListAllocator {
tvListCache.get(TSDataType.INT64).add(list);
}
}
+
+ @Override
+ public int getNumberOfTVLists() {
+ int number = 0;
+ for (Queue<TVList> queue : tvListCache.values()) {
+ number += queue.size();
+ }
+ return number;
+ }
+
+ @Override
+ public void start() throws StartupException {
+ try {
+ JMXService.registerMBean(INSTANCE, mbeanName);
+ } catch (Exception e) {
+ String errorMessage = String
+ .format("Failed to start %s because of %s", this.getID().getName(),
+ e.getMessage());
+ throw new StartupException(errorMessage, e);
+ }
+ }
+
+ @Override
+ public void stop() {
+ JMXService.deregisterMBean(mbeanName);
+ tvListCache.clear();
+ }
+
+ @Override
+ public ServiceType getID() {
+ return ServiceType.TVLIST_ALLOCATOR_SERVICE;
+ }
}
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/utils/datastructure/TVListAllocatorMBean.java b/iotdb/src/main/java/org/apache/iotdb/db/utils/datastructure/TVListAllocatorMBean.java
new file mode 100644
index 0000000..289c213
--- /dev/null
+++ b/iotdb/src/main/java/org/apache/iotdb/db/utils/datastructure/TVListAllocatorMBean.java
@@ -0,0 +1,7 @@
+package org.apache.iotdb.db.utils.datastructure;
+
+public interface TVListAllocatorMBean {
+
+ int getNumberOfTVLists();
+
+}