This is an automated email from the ASF dual-hosted git repository. east pushed a commit to branch update_mult_dir_avoid_full_disk in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
commit ed5f472af33f240bab7a0e1824bf483f1fa673ed Author: mdf369 <[email protected]> AuthorDate: Tue Jun 4 16:06:56 2019 +0800 update --- .../iotdb/db/conf/directories/Directories.java | 2 ++ .../db/engine/filenode/FileNodeProcessor.java | 19 ++++-------- .../exception/DiskSpaceInsufficientException.java | 4 +-- .../test/java/org/apache/iotdb/db/test/Test1.java | 36 ++++++++++++++++++++++ .../test/java/org/apache/iotdb/db/test/Test2.java | 36 ++++++++++++++++++++++ 5 files changed, 82 insertions(+), 15 deletions(-) diff --git a/iotdb/src/main/java/org/apache/iotdb/db/conf/directories/Directories.java b/iotdb/src/main/java/org/apache/iotdb/db/conf/directories/Directories.java index d792c37..db6e99a 100644 --- a/iotdb/src/main/java/org/apache/iotdb/db/conf/directories/Directories.java +++ b/iotdb/src/main/java/org/apache/iotdb/db/conf/directories/Directories.java @@ -41,6 +41,8 @@ public class Directories { private DirectoryStrategy strategy; private Directories() { + System.out.println("Init Directories."); + tsfileFolders = new ArrayList<>( Arrays.asList(IoTDBDescriptor.getInstance().getConfig().getBufferWriteDirs())); initFolders(); diff --git a/iotdb/src/main/java/org/apache/iotdb/db/engine/filenode/FileNodeProcessor.java b/iotdb/src/main/java/org/apache/iotdb/db/engine/filenode/FileNodeProcessor.java index 701aefb..786d4f3 100644 --- a/iotdb/src/main/java/org/apache/iotdb/db/engine/filenode/FileNodeProcessor.java +++ b/iotdb/src/main/java/org/apache/iotdb/db/engine/filenode/FileNodeProcessor.java @@ -445,7 +445,7 @@ public class FileNodeProcessor extends Processor implements IStatistic { /** * execute filenode recovery. */ - public void fileNodeRecovery() throws FileNodeProcessorException { + public void fileNodeRecovery() throws FileNodeProcessorException, DiskSpaceInsufficientException { // restore bufferwrite if (!newFileNodes.isEmpty() && !newFileNodes.get(newFileNodes.size() - 1).isClosed()) { // @@ -521,19 +521,14 @@ public class FileNodeProcessor extends Processor implements IStatistic { * get buffer write processor by processor name and insert time. */ public BufferWriteProcessor getBufferWriteProcessor(String processorName, long insertTime) - throws FileNodeProcessorException { + throws FileNodeProcessorException, DiskSpaceInsufficientException { if (bufferWriteProcessor == null) { Map<String, Action> params = new HashMap<>(); params.put(FileNodeConstants.BUFFERWRITE_FLUSH_ACTION, bufferwriteFlushAction); params.put(FileNodeConstants.BUFFERWRITE_CLOSE_ACTION, bufferwriteCloseAction); params .put(FileNodeConstants.FILENODE_PROCESSOR_FLUSH_ACTION, flushFileNodeProcessorAction); - String baseDir = null; - try { - baseDir = directories.getNextFolderForTsfile(); - } catch (DiskSpaceInsufficientException e) { - throw new FileNodeProcessorException(e); - } + String baseDir = directories.getNextFolderForTsfile(); LOGGER.info("Allocate folder {} for the new bufferwrite processor.", baseDir); // construct processor or restore try { @@ -1049,7 +1044,7 @@ public class FileNodeProcessor extends Processor implements IStatistic { /** * Merge this storage group, merge the tsfile data with overflow data. */ - public void merge() throws FileNodeProcessorException { + public void merge() throws FileNodeProcessorException, DiskSpaceInsufficientException { // close bufferwrite and overflow, prepare for merge LOGGER.info("The filenode processor {} begins to merge.", getProcessorName()); prepareForMerge(); @@ -1473,7 +1468,7 @@ public class FileNodeProcessor extends Processor implements IStatistic { } private String queryAndWriteDataForMerge(TsFileResource backupIntervalFile) - throws IOException, FileNodeProcessorException, PathErrorException { + throws IOException, FileNodeProcessorException, PathErrorException, DiskSpaceInsufficientException { Map<String, Long> startTimeMap = new HashMap<>(); Map<String, Long> endTimeMap = new HashMap<>(); @@ -1538,8 +1533,6 @@ public class FileNodeProcessor extends Processor implements IStatistic { mergeFileWriter.endChunkGroup(footer, 0); } } - } catch (DiskSpaceInsufficientException e) { - throw new FileNodeProcessorException(e); } finally { FileReaderManager.getInstance().decreaseFileReaderReference(backupIntervalFile.getFilePath(), true); @@ -2063,7 +2056,7 @@ public class FileNodeProcessor extends Processor implements IStatistic { getProcessorName(), ofInstant(Instant.ofEpochMilli(mergeStartTime), zoneId), ofInstant(Instant.ofEpochMilli(mergeEndTime), zoneId), intervalTime); - } catch (FileNodeProcessorException e) { + } catch (FileNodeProcessorException | DiskSpaceInsufficientException e) { LOGGER.error("The filenode processor {} encountered an error when merging.", getProcessorName(), e); throw new ErrorDebugException(e); diff --git a/iotdb/src/main/java/org/apache/iotdb/db/exception/DiskSpaceInsufficientException.java b/iotdb/src/main/java/org/apache/iotdb/db/exception/DiskSpaceInsufficientException.java index 1649fa1..5b71f4c 100644 --- a/iotdb/src/main/java/org/apache/iotdb/db/exception/DiskSpaceInsufficientException.java +++ b/iotdb/src/main/java/org/apache/iotdb/db/exception/DiskSpaceInsufficientException.java @@ -20,7 +20,7 @@ package org.apache.iotdb.db.exception; import java.util.List; -public class DiskSpaceInsufficientException extends Exception { +public class DiskSpaceInsufficientException extends FileNodeManagerException { private static final long serialVersionUID = 9001643829368311032L; @@ -29,6 +29,6 @@ public class DiskSpaceInsufficientException extends Exception { } public DiskSpaceInsufficientException(List<String> folders) { - this(String.format("Can't get next folder from %s, because they are all full.", folders)); + super(String.format("Can't get next folder from %s, because they are all full.", folders)); } } diff --git a/iotdb/src/test/java/org/apache/iotdb/db/test/Test1.java b/iotdb/src/test/java/org/apache/iotdb/db/test/Test1.java new file mode 100644 index 0000000..f283600 --- /dev/null +++ b/iotdb/src/test/java/org/apache/iotdb/db/test/Test1.java @@ -0,0 +1,36 @@ +package org.apache.iotdb.db.test; + +import org.apache.iotdb.db.conf.directories.Directories; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class Test1 { + + private Directories directories = Directories.getInstance(); + + @Before + public void setup() { + System.out.println("Test1.setup"); + } + + @After + public void teardown() { + System.out.println("Test1.teardown"); + } + + @Test + public void method1() { + System.out.println("Test1.method1"); + } + + @Test + public void method2() { + System.out.println("Test1.method2"); + } + + @Test + public void method3() { + System.out.println("Test1.method3"); + } +} diff --git a/iotdb/src/test/java/org/apache/iotdb/db/test/Test2.java b/iotdb/src/test/java/org/apache/iotdb/db/test/Test2.java new file mode 100644 index 0000000..4955f34 --- /dev/null +++ b/iotdb/src/test/java/org/apache/iotdb/db/test/Test2.java @@ -0,0 +1,36 @@ +package org.apache.iotdb.db.test; + +import org.apache.iotdb.db.conf.directories.Directories; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class Test2 { + +// private Directories directories = Directories.getInstance(); + + @Before + public void setup() { + System.out.println("Test2.setup"); + } + + @After + public void teardown() { + System.out.println("Test2.teardown"); + } + + @Test + public void method1() { + System.out.println("Test2.method1"); + } + + @Test + public void method2() { + System.out.println("Test2.method2"); + } + + @Test + public void method3() { + System.out.println("Test2.method3"); + } +}
