You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by hx...@apache.org on 2019/01/22 13:15:26 UTC
[incubator-iotdb] branch fix_OpenFileNumUtilTest_failure updated:
add more output for debuging..
This is an automated email from the ASF dual-hosted git repository.
hxd pushed a commit to branch fix_OpenFileNumUtilTest_failure
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
The following commit(s) were added to refs/heads/fix_OpenFileNumUtilTest_failure by this push:
new 3b8a9c3 add more output for debuging..
3b8a9c3 is described below
commit 3b8a9c3ca36535c8daac2e5728f3376050685b83
Author: xiangdong huang <sa...@gmail.com>
AuthorDate: Tue Jan 22 21:15:13 2019 +0800
add more output for debuging..
---
.../org/apache/iotdb/db/utils/OpenFileNumUtil.java | 27 +++++++-------
.../apache/iotdb/db/utils/OpenFileNumUtilTest.java | 24 ++++++-------
iotdb/src/test/resources/logback.xml | 42 ++++++++++++++++++++++
3 files changed, 66 insertions(+), 27 deletions(-)
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/utils/OpenFileNumUtil.java b/iotdb/src/main/java/org/apache/iotdb/db/utils/OpenFileNumUtil.java
index 4187854..cfce9ce 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/utils/OpenFileNumUtil.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/utils/OpenFileNumUtil.java
@@ -32,7 +32,7 @@ import org.slf4j.LoggerFactory;
// Notice : statistics in this class may not be accurate because of limited user authority.
public class OpenFileNumUtil {
-
+ private static final Logger log = LoggerFactory.getLogger(OpenFileNumUtil.class);
private static final int PID_ERROR_CODE = -1;
private static final int UNSUPPORTED_OS_ERROR_CODE = -2;
private static final int UNKNOWN_STATISTICS_ERROR_CODE = -3;
@@ -42,7 +42,7 @@ public class OpenFileNumUtil {
private static final String SEARCH_PID_LINUX = "ps -aux | grep -i %s | grep -v grep";
private static final String SEARCH_PID_MAC = "ps aux | grep -i %s | grep -v grep";
private static final String SEARCH_OPEN_DATA_FILE_BY_PID = "lsof -p %d";
- private static Logger log = LoggerFactory.getLogger(OpenFileNumUtil.class);
+
private static IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
private static Directories directories = Directories.getInstance();
private final String[] cmds = {"/bin/bash", "-c", ""};
@@ -160,9 +160,9 @@ public class OpenFileNumUtil {
BufferedReader in = new BufferedReader(new InputStreamReader(pro.getInputStream()));
String line;
int oldValue;
- System.out.println("Output result of " + command);
+ log.debug("Output result of {}:", command);
while ((line = in.readLine()) != null) {
- System.out.println(line);
+ log.debug(line);
String[] temp = line.split("\\s+");
if (line.contains("" + pid) && temp.length > 8) {
oldValue = resultMap.get(OpenFileNumStatistics.TOTAL_OPEN_FILE_NUM);
@@ -183,9 +183,10 @@ public class OpenFileNumUtil {
}
}
}
+ log.debug("Output finished.");
in.close();
pro.destroy();
- } catch (IOException e) {
+ } catch (Exception e) {
log.error("Cannot get open file number of IoTDB process because of {}", e.getMessage());
}
return resultMap;
@@ -232,14 +233,14 @@ public class OpenFileNumUtil {
}
public enum OpenFileNumStatistics {
- TOTAL_OPEN_FILE_NUM(null), DATA_OPEN_FILE_NUM(
- Collections.singletonList(config.dataDir)), DELTA_OPEN_FILE_NUM(
- directories.getAllTsFileFolders()), OVERFLOW_OPEN_FILE_NUM(
- Collections.singletonList(config.overflowDataDir)), WAL_OPEN_FILE_NUM(
- Collections.singletonList(config.walFolder)), METADATA_OPEN_FILE_NUM(
- Collections.singletonList(config.metadataDir)), DIGEST_OPEN_FILE_NUM(
- Collections.singletonList(config.fileNodeDir)), SOCKET_OPEN_FILE_NUM(
- null);
+ TOTAL_OPEN_FILE_NUM(null),
+ DATA_OPEN_FILE_NUM(Collections.singletonList(config.dataDir)),
+ DELTA_OPEN_FILE_NUM(directories.getAllTsFileFolders()),
+ OVERFLOW_OPEN_FILE_NUM(Collections.singletonList(config.overflowDataDir)),
+ WAL_OPEN_FILE_NUM(Collections.singletonList(config.walFolder)),
+ METADATA_OPEN_FILE_NUM(Collections.singletonList(config.metadataDir)),
+ DIGEST_OPEN_FILE_NUM(Collections.singletonList(config.fileNodeDir)),
+ SOCKET_OPEN_FILE_NUM(null);
// path is a list of directory corresponding to the OpenFileNumStatistics enum element,
// e.g. data/data/ for DATA_OPEN_FILE_NUM
diff --git a/iotdb/src/test/java/org/apache/iotdb/db/utils/OpenFileNumUtilTest.java b/iotdb/src/test/java/org/apache/iotdb/db/utils/OpenFileNumUtilTest.java
index ac0da51..49ae3eb 100644
--- a/iotdb/src/test/java/org/apache/iotdb/db/utils/OpenFileNumUtilTest.java
+++ b/iotdb/src/test/java/org/apache/iotdb/db/utils/OpenFileNumUtilTest.java
@@ -65,14 +65,13 @@ public class OpenFileNumUtilTest {
openFileNumUtil.setPid(testProcessID);
String dataFilePath = OpenFileNumUtil.OpenFileNumStatistics.DATA_OPEN_FILE_NUM.getPath().get(0);
String userDir = System.getProperty("user.dir");
- currDir = userDir + File.separator + testProcessID + File.separator + dataFilePath;
+ currDir = userDir + File.separator + testProcessID;
+ testDataDirRoot = new File(currDir);
+ currDir = currDir + File.separator + dataFilePath;
File testDataDir = new File(currDir);
- testDataDirRoot = new File(userDir + File.separator + testProcessID);
- if (!testDataDir.exists()) {
- if (!testDataDir.isDirectory()) {
- if (!testDataDir.mkdirs()) {
- LOGGER.error("Create test file dir {} failed.", testDataDir.getPath());
- }
+ if(!testDataDir.isDirectory()){
+ if (!testDataDir.mkdirs()) {
+ LOGGER.error("Create test file dir {} failed.", testDataDir.getPath());
}
}
testFileName = TEST_FILE_PREFIX + testProcessID;
@@ -133,7 +132,7 @@ public class OpenFileNumUtilTest {
public void testDataOpenFileNumWhenCreateFileWriter() {
if (os.startsWith(MAC_OS_NAME) || os.startsWith(LINUX_OS_NAME)) {
for (int i = 0; i < testFileNum; i++) {
- fileList.add(new File(currDir + testFileName + i));
+ fileList.add(new File(currDir + File.separator + testFileName + i));
}
totalOpenFileNumBefore = openFileNumUtil
.get(OpenFileNumUtil.OpenFileNumStatistics.DATA_OPEN_FILE_NUM);
@@ -147,7 +146,9 @@ public class OpenFileNumUtilTest {
} else {
try {
boolean flag = file.createNewFile();
- if (!flag) {
+ if(flag) {
+ fileWriterList.add(new FileWriter(file));
+ }else{
LOGGER.error(
"create test file {} failed when execute testTotalOpenFileNumWhenCreateFileWriter().",
file.getPath());
@@ -155,11 +156,6 @@ public class OpenFileNumUtilTest {
} catch (IOException e) {
LOGGER.error(e.getMessage());
}
- try {
- fileWriterList.add(new FileWriter(file));
- } catch (IOException e) {
- LOGGER.error(e.getMessage());
- }
}
}
totalOpenFileNumAfter = openFileNumUtil
diff --git a/iotdb/src/test/resources/logback.xml b/iotdb/src/test/resources/logback.xml
new file mode 100644
index 0000000..c946fa2
--- /dev/null
+++ b/iotdb/src/test/resources/logback.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<configuration debug="false">
+ <property name="LOG_PATH" value="logs"/>
+ <!-- prevent logback from outputting its own status at the start of every log -->
+ <statusListener class="ch.qos.logback.core.status.NopStatusListener"/>
+ <appender class="ch.qos.logback.core.ConsoleAppender" name="stdout">
+ <Target>System.out</Target>
+ <encoder>
+ <pattern>%-5p [%d] [%thread] %C:%L - %m %n</pattern>
+ <charset>utf-8</charset>
+ </encoder>
+ <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+ <level>DEBUG</level>
+ </filter>
+ </appender>
+ <!--<logger name="org.apache.iotdb.tsfile.write.chunk.ChunkWriterImpl level="debug" />-->
+ <logger name="org.apache.iotdb.db.utils.OpenFileNumUtil" level="debug" />
+ <logger name="org.apache.iotdb.db.utils.OpenFileNumUtilTest" level="debug" />
+ <root level="INFO">
+ <appender-ref ref="stdout"/>
+ </root>
+</configuration>