You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by xu...@apache.org on 2020/12/09 04:55:38 UTC
[iotdb] branch virtual_partition_2 updated: clean code
This is an automated email from the ASF dual-hosted git repository.
xuekaifeng pushed a commit to branch virtual_partition_2
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/virtual_partition_2 by this push:
new aa6d629 clean code
aa6d629 is described below
commit aa6d629ae95e65981bc4a891477ed112a569ace1
Author: 151250176 <15...@smail.nju.edu.cn>
AuthorDate: Wed Dec 9 12:55:20 2020 +0800
clean code
---
.../org/apache/iotdb/db/engine/StorageEngine.java | 10 +--
.../virtualSg/VirtualPartitionerReader.java | 86 -------------------
.../virtualSg/VirtualPartitionerWriter.java | 96 ----------------------
3 files changed, 1 insertion(+), 191 deletions(-)
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/StorageEngine.java b/server/src/main/java/org/apache/iotdb/db/engine/StorageEngine.java
index a492962..15e8efa 100644
--- a/server/src/main/java/org/apache/iotdb/db/engine/StorageEngine.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/StorageEngine.java
@@ -53,8 +53,6 @@ import org.apache.iotdb.db.engine.storagegroup.StorageGroupProcessor;
import org.apache.iotdb.db.engine.storagegroup.StorageGroupProcessor.TimePartitionFilter;
import org.apache.iotdb.db.engine.storagegroup.TsFileProcessor;
import org.apache.iotdb.db.engine.storagegroup.TsFileResource;
-import org.apache.iotdb.db.engine.storagegroup.virtualSg.HashVirtualPartitioner;
-import org.apache.iotdb.db.engine.storagegroup.virtualSg.VirtualPartitioner;
import org.apache.iotdb.db.engine.storagegroup.virtualSg.VirtualStorageGroupManager;
import org.apache.iotdb.db.exception.BatchInsertionException;
import org.apache.iotdb.db.exception.LoadFileException;
@@ -107,7 +105,7 @@ public class StorageEngine implements IService {
@ServerConfigConsistent
private static boolean enablePartition =
IoTDBDescriptor.getInstance().getConfig().isEnablePartition();
- private final VirtualPartitioner partitioner;
+
private final Logger logger;
/**
* a folder (system/storage_groups/ by default) that persist system info. Each Storage Processor
@@ -148,12 +146,6 @@ public class StorageEngine implements IService {
// recover upgrade process
UpgradeUtils.recoverUpgrade();
- if (config.isEnableVirtualPartition()) {
- partitioner = HashVirtualPartitioner.getInstance();
- } else {
- partitioner = null;
- }
-
recover();
}
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/virtualSg/VirtualPartitionerReader.java b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/virtualSg/VirtualPartitionerReader.java
deleted file mode 100644
index 251694a..0000000
--- a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/virtualSg/VirtualPartitionerReader.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * 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.storagegroup.virtualSg;
-
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import org.apache.iotdb.db.conf.IoTDBConfig;
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.engine.fileSystem.SystemFileFactory;
-import org.apache.iotdb.db.utils.FilePathUtils;
-import org.apache.iotdb.tsfile.utils.Pair;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class VirtualPartitionerReader {
-
- private static final Logger logger = LoggerFactory.getLogger(VirtualPartitionerReader.class);
- private static final String MAPPING_SEPARATOR = ",";
- private static final String LOG_FILE_NAME = "VirtualSGMapping.log";
- private static final IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
-
- private BufferedReader reader;
-
- VirtualPartitionerReader() {
- String systemDir = FilePathUtils.regularizePath(config.getSystemDir()) + "storage_groups";
- File logFile = SystemFileFactory.INSTANCE.getFile(systemDir + File.separator + LOG_FILE_NAME);
- // no log file, create it
- if (!logFile.exists()){
- try {
- logFile.createNewFile();
- } catch (IOException e) {
- logger.error("can not create virtual storage group mapping file because: ", e);
- }
- }
-
- try {
- reader = new BufferedReader(new FileReader(logFile));
- } catch (FileNotFoundException e) {
- logger.error("can not create virtual storage group mapping because: ", e);
- }
- }
-
- /**
- * read the mapping between virtual storage group id and device id
- * @return mapping line
- */
- public Pair<String, String> readMapping() {
- String line = null;
- try {
- line = reader.readLine();
- } catch (IOException e) {
- logger.error("can not read virtual storage group mapping because: ", e);
- }
- if(line == null){
- return null;
- }
-
- String[] part = line.split(MAPPING_SEPARATOR);
-
- return new Pair<>(part[0], part[1]);
- }
-
- public void close() throws IOException {
- reader.close();
- }
-}
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/virtualSg/VirtualPartitionerWriter.java b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/virtualSg/VirtualPartitionerWriter.java
deleted file mode 100644
index ed8f6b0..0000000
--- a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/virtualSg/VirtualPartitionerWriter.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * 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.storagegroup.virtualSg;
-
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.channels.FileChannel;
-import org.apache.iotdb.db.conf.IoTDBConfig;
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.engine.fileSystem.SystemFileFactory;
-import org.apache.iotdb.db.utils.FilePathUtils;
-import org.apache.iotdb.db.utils.TestOnly;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class VirtualPartitionerWriter {
-
- private static final Logger logger = LoggerFactory.getLogger(VirtualPartitionerWriter.class);
- private static final String MAPPING_SEPARATOR = ",";
- private static final String LINE_SEPARATOR = System.lineSeparator();
- private static final String LOG_FILE_NAME = "VirtualSGMapping.log";
- private static final IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
-
- private File logFile;
- private FileOutputStream fileOutputStream;
- private FileChannel channel;
-
- VirtualPartitionerWriter() {
- String systemDir = FilePathUtils.regularizePath(config.getSystemDir()) + "storage_groups";
- logFile = SystemFileFactory.INSTANCE.getFile(systemDir + File.separator + LOG_FILE_NAME);
-
- try {
- fileOutputStream = new FileOutputStream(logFile, true);
- channel = fileOutputStream.getChannel();
- } catch (FileNotFoundException e) {
- logger.error("can not create virtual storage group mapping because: ", e);
- }
- }
-
- /**
- * write the mapping between virtual storage group id and device id
- *
- * @param storageGroupId virtual storage group id
- * @param deviceId device id
- */
- public void writeMapping(String storageGroupId, String deviceId) {
- String line = storageGroupId
- + MAPPING_SEPARATOR
- + deviceId
- + LINE_SEPARATOR;
-
- try {
- channel.write(ByteBuffer.wrap(line.getBytes()));
- channel.force(false);
- } catch (IOException e) {
- logger.error("can not write virtual storage group mapping because: ", e);
- }
- }
-
- public void close() {
- try {
- channel.force(true);
- channel.close();
- fileOutputStream.close();
- } catch (IOException e) {
- logger.error("can not close virtual storage group mapping file because: ", e);
-
- }
- }
-
- @TestOnly
- public void clear() {
- close();
- logFile.delete();
- }
-}