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/03/06 09:25:01 UTC
[incubator-iotdb] branch master updated: Fix sonar bug (#82)
This is an automated email from the ASF dual-hosted git repository.
hxd pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new db41e49 Fix sonar bug (#82)
db41e49 is described below
commit db41e4932bb7b73ad6c720d13a9492b93de92c3e
Author: Jiang Tian <jt...@163.com>
AuthorDate: Wed Mar 6 03:24:54 2019 -0600
Fix sonar bug (#82)
* Refactor some files to reduce sonar bugs.
---
.../apache/iotdb/cli/client/AbstractClient.java | 15 +-
.../java/org/apache/iotdb/cli/tool/ExportCsv.java | 2 +-
.../iotdb/db/auth/authorizer/BasicAuthorizer.java | 15 +-
.../db/auth/authorizer/LocalFileAuthorizer.java | 4 +-
.../iotdb/db/auth/role/LocalFileRoleAccessor.java | 4 +-
.../iotdb/db/auth/user/BasicUserManager.java | 3 +-
.../iotdb/db/auth/user/LocalFileUserAccessor.java | 2 +-
.../org/apache/iotdb/db/concurrent/HashLock.java | 8 +-
.../java/org/apache/iotdb/db/conf/IoTDBConfig.java | 589 +++++++++++++++++----
.../org/apache/iotdb/db/conf/IoTDBDescriptor.java | 207 ++++----
.../iotdb/db/conf/directories/Directories.java | 4 +-
.../strategy/MinDirOccupiedSpaceFirstStrategy.java | 2 +-
.../MinFolderOccupiedSpaceFirstStrategy.java | 2 +-
.../engine/bufferwrite/BufferWriteProcessor.java | 49 +-
.../bufferwrite/RestorableTsFileIOWriter.java | 6 +-
.../engine/cache/RowGroupBlockMetaDataCache.java | 16 +
.../db/engine/filenode/FileNodeFlushFuture.java | 12 +-
.../iotdb/db/engine/filenode/FileNodeManager.java | 17 +-
.../db/engine/filenode/FileNodeProcessor.java | 8 +-
.../db/engine/memcontrol/BasicMemController.java | 9 +-
.../db/engine/memcontrol/FlushPartialPolicy.java | 2 +-
.../db/engine/memcontrol/MemMonitorThread.java | 4 +-
.../db/engine/modification/ModificationFile.java | 2 +-
.../io/LocalTextModificationAccessor.java | 3 +-
.../db/engine/overflow/io/OverflowProcessor.java | 19 +-
.../db/engine/overflow/io/OverflowResource.java | 11 +-
.../apache/iotdb/db/engine/pool/FlushManager.java | 11 +-
.../apache/iotdb/db/engine/pool/MergeManager.java | 10 +-
.../version/SimpleFileVersionController.java | 4 +-
.../iotdb/db/exception/ProcessorException.java | 4 +
.../db/exception/builder/ExceptionBuilder.java | 2 +-
.../org/apache/iotdb/db/metadata/MManager.java | 268 +++++-----
.../org/apache/iotdb/db/monitor/StatMonitor.java | 12 +-
.../db/postback/conf/PostBackSenderConfig.java | 4 +-
.../iotdb/db/postback/receiver/ServerManager.java | 10 +-
.../db/postback/receiver/ServerServiceImpl.java | 12 +-
.../iotdb/db/qp/executor/OverflowQPExecutor.java | 7 +-
.../iotdb/db/query/control/FileReaderManager.java | 2 +-
.../apache/iotdb/db/service/CloseMergeService.java | 12 +-
.../java/org/apache/iotdb/db/service/IoTDB.java | 9 +-
.../org/apache/iotdb/db/service/JDBCService.java | 10 +-
.../java/org/apache/iotdb/db/service/Monitor.java | 10 +-
.../org/apache/iotdb/db/service/TSServiceImpl.java | 3 +-
.../org/apache/iotdb/db/utils/LoadDataUtils.java | 4 +-
.../org/apache/iotdb/db/utils/OpenFileNumUtil.java | 10 +-
.../org/apache/iotdb/db/writelog/io/LogWriter.java | 2 +-
.../writelog/manager/MultiFileLogNodeManager.java | 14 +-
.../db/writelog/node/ExclusiveWriteLogNode.java | 6 +-
.../db/writelog/transfer/PhysicalPlanCodec.java | 6 +-
.../java/org/apache/iotdb/db/engine/PathUtils.java | 4 +-
.../memcontrol/BufferwriteFileSizeControlTest.java | 10 +-
.../memcontrol/BufferwriteMetaSizeControlTest.java | 10 +-
.../db/engine/memcontrol/IoTDBMemControlTest.java | 10 +-
.../memcontrol/OverflowFileSizeControlTest.java | 8 +-
.../memcontrol/OverflowMetaSizeControlTest.java | 8 +-
.../engine/modification/DeletionFileNodeTest.java | 2 +-
.../overflow/io/OverflowProcessorBenchmark.java | 4 +-
.../version/SysTimeVersionControllerTest.java | 5 +-
.../iotdb/db/metadata/MManagerAdvancedTest.java | 5 +-
.../org/apache/iotdb/db/monitor/MonitorTest.java | 6 +-
.../sender/IoTDBSingleClientPostBackTest.java | 2 +-
.../db/query/control/FileReaderManagerTest.java | 6 +-
.../apache/iotdb/db/utils/EnvironmentUtils.java | 20 +-
.../apache/iotdb/db/writelog/PerformanceTest.java | 22 +-
.../org/apache/iotdb/db/writelog/RecoverTest.java | 6 +-
.../iotdb/db/writelog/WriteLogNodeManagerTest.java | 14 +-
.../apache/iotdb/db/writelog/WriteLogNodeTest.java | 22 +-
67 files changed, 1024 insertions(+), 587 deletions(-)
diff --git a/iotdb-cli/src/main/java/org/apache/iotdb/cli/client/AbstractClient.java b/iotdb-cli/src/main/java/org/apache/iotdb/cli/client/AbstractClient.java
index 5f9d72f..e4c4137 100644
--- a/iotdb-cli/src/main/java/org/apache/iotdb/cli/client/AbstractClient.java
+++ b/iotdb-cli/src/main/java/org/apache/iotdb/cli/client/AbstractClient.java
@@ -684,7 +684,9 @@ public abstract class AbstractClient {
if (hasResultSet) {
ResultSet resultSet = statement.getResultSet();
output(resultSet, printToConsole, zoneId);
- closeResultSet(resultSet);
+ if (resultSet != null) {
+ resultSet.close();
+ }
}
} catch (Exception e) {
println("Msg: " + e.getMessage());
@@ -703,17 +705,6 @@ public abstract class AbstractClient {
println(String.format("It costs %.3fs", costTime / 1000.0));
}
- protected static void closeResultSet(ResultSet resultSet) {
- if (resultSet != null) {
- try {
- resultSet.close();
- } catch (SQLException e) {
- println("Cannot close resultSet because: " + e.getMessage());
- handleException(e);
- }
- }
- }
-
enum OperationResult {
STOP_OPER, CONTINUE_OPER, NO_OPER
}
diff --git a/iotdb-cli/src/main/java/org/apache/iotdb/cli/tool/ExportCsv.java b/iotdb-cli/src/main/java/org/apache/iotdb/cli/tool/ExportCsv.java
index cae4527..33c0283 100644
--- a/iotdb-cli/src/main/java/org/apache/iotdb/cli/tool/ExportCsv.java
+++ b/iotdb-cli/src/main/java/org/apache/iotdb/cli/tool/ExportCsv.java
@@ -246,7 +246,7 @@ public class ExportCsv extends AbstractCsvTool {
return;
}
} catch (IOException e) {
- LOGGER.error(e.getMessage());
+ LOGGER.error("Cannot create dump file {}", path, e);
return;
}
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/auth/authorizer/BasicAuthorizer.java b/iotdb/src/main/java/org/apache/iotdb/db/auth/authorizer/BasicAuthorizer.java
index f050696..07f1033 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/auth/authorizer/BasicAuthorizer.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/auth/authorizer/BasicAuthorizer.java
@@ -101,10 +101,11 @@ public abstract class BasicAuthorizer implements IAuthorizer, IService {
if (IoTDBConstant.ADMIN_NAME.equals(username)) {
throw new AuthException("Invalid operation, administrator must have all privileges");
}
+ String p = path;
if (!PrivilegeType.isPathRelevant(privilegeId)) {
- path = IoTDBConstant.PATH_ROOT;
+ p = IoTDBConstant.PATH_ROOT;
}
- return userManager.revokePrivilegeFromUser(username, path, privilegeId);
+ return userManager.revokePrivilegeFromUser(username, p, privilegeId);
}
@Override
@@ -136,19 +137,21 @@ public abstract class BasicAuthorizer implements IAuthorizer, IService {
@Override
public boolean grantPrivilegeToRole(String roleName, String path, int privilegeId)
throws AuthException {
+ String p = path;
if (!PrivilegeType.isPathRelevant(privilegeId)) {
- path = IoTDBConstant.PATH_ROOT;
+ p = IoTDBConstant.PATH_ROOT;
}
- return roleManager.grantPrivilegeToRole(roleName, path, privilegeId);
+ return roleManager.grantPrivilegeToRole(roleName, p, privilegeId);
}
@Override
public boolean revokePrivilegeFromRole(String roleName, String path, int privilegeId)
throws AuthException {
+ String p = path;
if (!PrivilegeType.isPathRelevant(privilegeId)) {
- path = IoTDBConstant.PATH_ROOT;
+ p = IoTDBConstant.PATH_ROOT;
}
- return roleManager.revokePrivilegeFromRole(roleName, path, privilegeId);
+ return roleManager.revokePrivilegeFromRole(roleName, p, privilegeId);
}
@Override
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/auth/authorizer/LocalFileAuthorizer.java b/iotdb/src/main/java/org/apache/iotdb/db/auth/authorizer/LocalFileAuthorizer.java
index f631bb7..e1afe1b 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/auth/authorizer/LocalFileAuthorizer.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/auth/authorizer/LocalFileAuthorizer.java
@@ -33,8 +33,8 @@ public class LocalFileAuthorizer extends BasicAuthorizer {
private static Logger logger = LoggerFactory.getLogger(LocalFileAuthorizer.class);
private LocalFileAuthorizer() throws AuthException {
- super(new LocalFileUserManager(config.dataDir + File.separator + "users" + File.separator),
- new LocalFileRoleManager(config.dataDir + File.separator + "roles" + File.separator));
+ super(new LocalFileUserManager(config.getDataDir() + File.separator + "users" + File.separator),
+ new LocalFileRoleManager(config.getDataDir() + File.separator + "roles" + File.separator));
}
/**
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/auth/role/LocalFileRoleAccessor.java b/iotdb/src/main/java/org/apache/iotdb/db/auth/role/LocalFileRoleAccessor.java
index 0cac736..b8f8f64 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/auth/role/LocalFileRoleAccessor.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/auth/role/LocalFileRoleAccessor.java
@@ -92,7 +92,7 @@ public class LocalFileRoleAccessor implements IRoleAccessor {
return role;
} catch (Exception e) {
- throw new IOException(e.getMessage());
+ throw new IOException(e);
}
}
@@ -115,7 +115,7 @@ public class LocalFileRoleAccessor implements IRoleAccessor {
}
outputStream.flush();
} catch (Exception e) {
- throw new IOException(e.getMessage());
+ throw new IOException(e);
}
}
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/auth/user/BasicUserManager.java b/iotdb/src/main/java/org/apache/iotdb/db/auth/user/BasicUserManager.java
index 8be5ee4..8e44df5 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/auth/user/BasicUserManager.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/auth/user/BasicUserManager.java
@@ -67,7 +67,7 @@ public abstract class BasicUserManager implements IUserManager {
try {
admin = getUser(IoTDBConstant.ADMIN_NAME);
} catch (AuthException e) {
- logger.warn("Cannot load admin because {}. Create a new one.", e.getMessage());
+ logger.warn("Cannot load admin, Creating a new one.", e);
admin = null;
}
@@ -196,6 +196,7 @@ public abstract class BasicUserManager implements IUserManager {
try {
AuthUtils.validatePassword(newPassword);
} catch (AuthException e) {
+ logger.debug("An illegal password detected ", e);
return false;
}
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/auth/user/LocalFileUserAccessor.java b/iotdb/src/main/java/org/apache/iotdb/db/auth/user/LocalFileUserAccessor.java
index 495577e..b3020ad 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/auth/user/LocalFileUserAccessor.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/auth/user/LocalFileUserAccessor.java
@@ -150,7 +150,7 @@ public class LocalFileUserAccessor implements IUserAccessor {
outputStream.flush();
} catch (Exception e) {
- throw new IOException(e.getMessage());
+ throw new IOException(e);
}
}
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/concurrent/HashLock.java b/iotdb/src/main/java/org/apache/iotdb/db/concurrent/HashLock.java
index 970bfc5..e725b54 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/concurrent/HashLock.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/concurrent/HashLock.java
@@ -72,13 +72,13 @@ public class HashLock {
for (int i = 0; i < lockSize; i++) {
try {
locks[i].readLock().unlock();
- } catch (Exception ignored) {
- // do nothing
+ } catch (Exception e) {
+ LOGGER.debug("Cannot unlock because, ", e);
}
try {
locks[i].writeLock().unlock();
- } catch (Exception ignored) {
- // do nothing
+ } catch (Exception e) {
+ LOGGER.debug("Cannot unlock because, ", e);
}
}
}
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java b/iotdb/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
index 96e2969..22f17ae 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
@@ -23,255 +23,258 @@ import java.time.ZoneId;
import java.util.ArrayList;
import java.util.List;
import org.apache.iotdb.db.metadata.MManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class IoTDBConfig {
+ private static final Logger LOGGER = LoggerFactory.getLogger(IoTDBConfig.class);
public static final String CONFIG_NAME = "iotdb-engine.properties";
- public static final String default_data_dir = "data";
- public static final String default_sys_dir = "system";
- public static final String default_tsfile_dir = "settled";
- public static final String mult_dir_strategy_prefix =
+ public static final String DEFAULT_DATA_DIR = "data";
+ public static final String DEFAULT_SYS_DIR = "system";
+ public static final String DEFAULT_TSFILE_DIR = "settled";
+ public static final String MULT_DIR_STRATEGY_PREFIX =
"org.apache.iotdb.db.conf.directories.strategy.";
- public static final String default_mult_dir_strategy = "MaxDiskUsableSpaceFirstStrategy";
+ public static final String DEFAULT_MULT_DIR_STRATEGY = "MaxDiskUsableSpaceFirstStrategy";
- public String rpcAddress = "0.0.0.0";
+ private String rpcAddress = "0.0.0.0";
/**
* Port which the JDBC server listens to.
*/
- public int rpcPort = 6667;
+ private int rpcPort = 6667;
/**
* Is the write ahead log enable.
*/
- public boolean enableWal = false;
+ private boolean enableWal = false;
/**
* When a certain amount of write ahead logs is reached, they will be flushed to the disk. It is
* possible to lose at most flush_wal_threshold operations.
*/
- public int flushWalThreshold = 10000;
+ private int flushWalThreshold = 10000;
/**
* The cycle when write ahead logs are periodically refreshed to disk(in milliseconds). It is
* possible to lose at most flush_wal_period_in_ms ms operations.
*/
- public long flushWalPeriodInMs = 10000;
+ private long flushWalPeriodInMs = 10000;
/**
* The cycle when write ahead log is periodically forced to be written to disk(in milliseconds) If
* set this parameter to 0 it means call outputStream.force(true) after every each write
*/
- public long forceWalPeriodInMs = 10;
+ private long forceWalPeriodInMs = 10;
/**
* Data directory.
*/
- public String dataDir = null;
+ private String dataDir = null;
/**
* System directory.
*/
- public String sysDir = null;
+ private String sysDir = null;
/**
* Wal directory.
*/
- public String walDir = null;
+ private String walDir = null;
/**
* Data directory of Overflow data.
*/
- public String overflowDataDir = "overflow";
+ private String overflowDataDir = "overflow";
/**
* Data directory of fileNode data.
*/
- public String fileNodeDir = "info";
+ private String fileNodeDir = "info";
/**
* Data directory of bufferWrite data.
* It can be setted as bufferWriteDirs = {"settled1", "settled2", "settled3"};
*/
- public String[] bufferWriteDirs = {"settled"};
+ private String[] bufferWriteDirs = {DEFAULT_TSFILE_DIR};
/**
* Strategy of multiple directories.
*/
- public String multDirStrategyClassName = null;
+ private String multDirStrategyClassName = null;
/**
* Data directory of metadata data.
*/
- public String metadataDir = "schema";
+ private String metadataDir = "schema";
/**
* Data directory of derby data.
*/
- public String derbyHome = "derby";
+ private String derbyHome = "derby";
/**
* Data directory of Write ahead log folder.
*/
- public String walFolder = "wal";
+ private String walFolder = "wal";
/**
* Data directory for index files (KV-match indexes).
*/
- public String indexFileDir = "index";
+ private String indexFileDir = "index";
/**
* Temporary directory for temporary files of read (External Sort). TODO: unused field
*/
- public String readTmpFileDir = "readTmp";
+ private String readTmpFileDir = "readTmp";
/**
* The maximum concurrent thread number for merging overflow. When the value <=0 or > CPU core
* number, use the CPU core number.
*/
- public int mergeConcurrentThreads = Runtime.getRuntime().availableProcessors();
+ private int mergeConcurrentThreads = Runtime.getRuntime().availableProcessors();
/**
* Maximum number of folders open at the same time.
*/
- public int maxOpenFolder = 100;
+ private int maxOpenFolder = 100;
/**
* The amount of data that is read every time when IoTDB merges data.
*/
- public int fetchSize = 10000;
+ private int fetchSize = 10000;
/**
* the maximum number of writing instances existing in same time.
*/
@Deprecated
- public int writeInstanceThreshold = 5;
+ private int writeInstanceThreshold = 5;
/**
* The period time of flushing data from memory to file. . The unit is second.
*/
- public long periodTimeForFlush = 3600;
+ private long periodTimeForFlush = 3600;
/**
* The period time for merge overflow data with tsfile data. The unit is second.
*/
- public long periodTimeForMerge = 7200;
+ private long periodTimeForMerge = 7200;
/**
* When set true, start timed flush and merge service. Else, stop timed flush and merge service.
* The default value is true. TODO: 'timed' better explains this than 'timing'.
*/
- public boolean enableTimingCloseAndMerge = true;
+ private boolean enableTimingCloseAndMerge = true;
/**
* How many threads can concurrently flush. When <= 0, use CPU core number.
*/
- public int concurrentFlushThread = Runtime.getRuntime().availableProcessors();
+ private int concurrentFlushThread = Runtime.getRuntime().availableProcessors();
- public ZoneId zoneID = ZoneId.systemDefault();
+ private ZoneId zoneID = ZoneId.systemDefault();
/**
* BufferWriteProcessor and OverflowProcessor will immediately flush if this threshold is
* reached.
*/
- public long memThresholdWarning = (long) (0.5 * Runtime.getRuntime().maxMemory());
+ private long memThresholdWarning = (long) (0.5 * Runtime.getRuntime().maxMemory());
/**
* No more insert is allowed if this threshold is reached.
*/
- public long memThresholdDangerous = (long) (0.6 * Runtime.getRuntime().maxMemory());
+ private long memThresholdDangerous = (long) (0.6 * Runtime.getRuntime().maxMemory());
/**
* MemMonitorThread will check every such interval(in ms). If memThresholdWarning is reached,
* MemMonitorThread will inform FileNodeManager to flush.
*/
- public long memMonitorInterval = 1000;
+ private long memMonitorInterval = 1000;
/**
* Decide how to control memory usage of inserting data. 0 is RecordMemController, which sums the
* size of each record (tuple). 1 is JVMMemController, which uses the JVM heap memory as the
* memory usage indicator.
*/
- public int memControllerType = 1;
+ private int memControllerType = 1;
/**
* When a bufferwrite's metadata size (in byte) exceed this, the bufferwrite is forced closed.
*/
- public long bufferwriteMetaSizeThreshold = 200 * 1024 * 1024L;
+ private long bufferwriteMetaSizeThreshold = 200 * 1024 * 1024L;
/**
* When a bufferwrite's file size (in byte) exceed this, the bufferwrite is forced closed.
*/
- public long bufferwriteFileSizeThreshold = 2 * 1024 * 1024 * 1024L;
+ private long bufferwriteFileSizeThreshold = 2 * 1024 * 1024 * 1024L;
/**
* When a overflow's metadata size (in byte) exceed this, the overflow is forced closed.
*/
- public long overflowMetaSizeThreshold = 20 * 1024 * 1024L;
+ private long overflowMetaSizeThreshold = 20 * 1024 * 1024L;
/**
* When a overflow's file size (in byte) exceed this, the overflow is forced closed.
*/
- public long overflowFileSizeThreshold = 200 * 1024 * 1024L;
+ private long overflowFileSizeThreshold = 200 * 1024 * 1024L;
/**
* If set false, MemMonitorThread and MemStatisticThread will not be created.
*/
- public boolean enableMemMonitor = false;
+ private boolean enableMemMonitor = false;
/**
* When set to true, small flushes will be triggered periodically even if the memory threshold is
* not exceeded.
*/
- public boolean enableSmallFlush = false;
+ private boolean enableSmallFlush = false;
/**
* The interval of small flush in ms.
*/
- public long smallFlushInterval = 60L * 1000;
+ private long smallFlushInterval = 60L * 1000;
/**
* The statMonitor writes statistics info into IoTDB every backLoopPeriodSec secs. The default
* value is 5s.
*/
- public int backLoopPeriodSec = 5;
+ private int backLoopPeriodSec = 5;
/**
* Set true to enable statistics monitor service, false to disable statistics service.
*/
- public boolean enableStatMonitor = false;
+ private boolean enableStatMonitor = false;
/**
* Set the time interval when StatMonitor performs delete detection. The default value is 600s.
*/
- public int statMonitorDetectFreqSec = 60 * 10;
+ private int statMonitorDetectFreqSec = 60 * 10;
/**
* Set the maximum time to keep monitor statistics information in IoTDB. The default value is
* 600s.
*/
- public int statMonitorRetainIntervalSec = 60 * 10;
+ private int statMonitorRetainIntervalSec = 60 * 10;
/**
* Threshold for external sort. When using multi-line merging sort, if the count of lines exceed
* {@code externalSortThreshold}, it will trigger external sort.
*/
- public int externalSortThreshold = 50;
+ private int externalSortThreshold = 50;
/**
* Cache size of {@code checkAndGetDataTypeCache} in {@link MManager}.
*/
- public int mManagerCacheSize = 400000;
+ private int mManagerCacheSize = 400000;
/**
* The maximum size of a single log in byte. If a log exceeds this size, it cannot be written to
* the WAL file and an exception is thrown.
*/
- public int maxLogEntrySize = 4 * 1024 * 1024;
+ private int maxLogEntrySize = 4 * 1024 * 1024;
/**
* Is this IoTDB instance a receiver of postback or not.
*/
- public boolean isPostbackEnable = true;
+ private boolean isPostbackEnable = true;
/**
* If this IoTDB instance is a receiver of postback, set the server port.
*/
- public int postbackServerPort = 5555;
+ private int postbackServerPort = 5555;
/*
* Set the language version when loading file including error information, default value is "EN"
*/
- public String languageVersion = "EN";
+ private String languageVersion = "EN";
/**
* Choose a postBack strategy of merging historical data: 1. It's more likely to update historical
* data, choose "true". 2. It's more likely not to update historical data or you don't know
* exactly, choose "false".
*/
- public boolean update_historical_data_possibility = false;
- public String ipWhiteList = "0.0.0.0/0";
+ private boolean update_historical_data_possibility = false;
+ private String ipWhiteList = "0.0.0.0/0";
/**
* Examining period of cache file reader : 100 seconds.
*/
- public long cacheFileReaderClearPeriod = 100000;
+ private long cacheFileReaderClearPeriod = 100000;
public IoTDBConfig() {
// empty constructor
@@ -282,7 +285,7 @@ public class IoTDBConfig {
}
public String getZoneIDString() {
- return zoneID.toString();
+ return getZoneID().toString();
}
public void updatePath() {
@@ -291,37 +294,37 @@ public class IoTDBConfig {
preUpdatePath();
// update the paths of subdirectories in the dataDir
- if (dataDir.length() > 0 && !dataDir.endsWith(File.separator)) {
- dataDir = dataDir + File.separatorChar;
+ if (getDataDir().length() > 0 && !getDataDir().endsWith(File.separator)) {
+ setDataDir(getDataDir() + File.separatorChar);
}
- overflowDataDir = dataDir + overflowDataDir;
+ setOverflowDataDir(getDataDir() + getOverflowDataDir());
- if (bufferWriteDirs == null || bufferWriteDirs.length == 0) {
- bufferWriteDirs = new String[]{default_tsfile_dir};
+ if (getBufferWriteDirs() == null || getBufferWriteDirs().length == 0) {
+ setBufferWriteDirs(new String[]{DEFAULT_TSFILE_DIR});
}
- for (int i = 0; i < bufferWriteDirs.length; i++) {
- if (new File(bufferWriteDirs[i]).isAbsolute()) {
+ for (int i = 0; i < getBufferWriteDirs().length; i++) {
+ if (new File(getBufferWriteDirs()[i]).isAbsolute()) {
continue;
}
- bufferWriteDirs[i] = dataDir + bufferWriteDirs[i];
+ getBufferWriteDirs()[i] = getDataDir() + getBufferWriteDirs()[i];
}
// update the paths of subdirectories in the sysDir
- if (sysDir.length() > 0 && !sysDir.endsWith(File.separator)) {
- sysDir = sysDir + File.separatorChar;
+ if (getSysDir().length() > 0 && !getSysDir().endsWith(File.separator)) {
+ setSysDir(getSysDir() + File.separatorChar);
}
- fileNodeDir = sysDir + fileNodeDir;
- metadataDir = sysDir + metadataDir;
+ setFileNodeDir(getSysDir() + getFileNodeDir());
+ setMetadataDir(getSysDir() + getMetadataDir());
// update the paths of subdirectories in the walDir
- if (walDir.length() > 0 && !walDir.endsWith(File.separator)) {
- walDir = walDir + File.separatorChar;
+ if (getWalDir().length() > 0 && !getWalDir().endsWith(File.separator)) {
+ setWalDir(getWalDir() + File.separatorChar);
}
- walFolder = walDir + walFolder;
+ setWalFolder(getWalDir() + getWalFolder());
- derbyHome = sysDir + derbyHome;
- indexFileDir = dataDir + indexFileDir;
+ setDerbyHome(getSysDir() + getDerbyHome());
+ setIndexFileDir(getDataDir() + getIndexFileDir());
}
/*
@@ -361,20 +364,20 @@ public class IoTDBConfig {
*/
private void preUpdatePath() {
- if (dataDir == null) {
- dataDir = default_data_dir + File.separatorChar + default_data_dir;
+ if (getDataDir() == null) {
+ setDataDir(DEFAULT_DATA_DIR + File.separatorChar + DEFAULT_DATA_DIR);
}
- if (sysDir == null) {
- sysDir = default_data_dir + File.separatorChar + default_sys_dir;
+ if (getSysDir() == null) {
+ setSysDir(DEFAULT_DATA_DIR + File.separatorChar + DEFAULT_SYS_DIR);
}
- if (walDir == null) {
- walDir = default_data_dir;
+ if (getWalDir() == null) {
+ setWalDir(DEFAULT_DATA_DIR);
}
List<String> dirs = new ArrayList<>();
- dirs.add(dataDir);
- dirs.add(sysDir);
- dirs.add(walDir);
+ dirs.add(getDataDir());
+ dirs.add(getSysDir());
+ dirs.add(getWalDir());
String homeDir = System.getProperty(IoTDBConstant.IOTDB_HOME, null);
for (int i = 0; i < 3; i++) {
String dir = dirs.get(i);
@@ -387,27 +390,429 @@ public class IoTDBConfig {
dirs.set(i, dir);
}
}
- dataDir = dirs.get(0);
- sysDir = dirs.get(1);
- walDir = dirs.get(2);
+ setDataDir(dirs.get(0));
+ setSysDir(dirs.get(1));
+ setWalDir(dirs.get(2));
}
private void confirmMultiDirStrategy() {
- if (multDirStrategyClassName == null) {
- multDirStrategyClassName = default_mult_dir_strategy;
+ if (getMultDirStrategyClassName() == null) {
+ setMultDirStrategyClassName(DEFAULT_MULT_DIR_STRATEGY);
}
- if (!multDirStrategyClassName.contains(".")) {
- multDirStrategyClassName = mult_dir_strategy_prefix + multDirStrategyClassName;
+ if (!getMultDirStrategyClassName().contains(".")) {
+ setMultDirStrategyClassName(MULT_DIR_STRATEGY_PREFIX + getMultDirStrategyClassName());
}
try {
- Class.forName(multDirStrategyClassName);
+ Class.forName(getMultDirStrategyClassName());
} catch (ClassNotFoundException e) {
- multDirStrategyClassName = mult_dir_strategy_prefix + default_mult_dir_strategy;
+ LOGGER.warn("Cannot find given directory strategy {}, using the default value",
+ getMultDirStrategyClassName(), e);
+ setMultDirStrategyClassName(MULT_DIR_STRATEGY_PREFIX + DEFAULT_MULT_DIR_STRATEGY);
}
}
public String[] getBufferWriteDirs() {
return bufferWriteDirs;
}
+
+ public String getRpcAddress() {
+ return rpcAddress;
+ }
+
+ public void setRpcAddress(String rpcAddress) {
+ this.rpcAddress = rpcAddress;
+ }
+
+ public int getRpcPort() {
+ return rpcPort;
+ }
+
+ public void setRpcPort(int rpcPort) {
+ this.rpcPort = rpcPort;
+ }
+
+ public boolean isEnableWal() {
+ return enableWal;
+ }
+
+ public void setEnableWal(boolean enableWal) {
+ this.enableWal = enableWal;
+ }
+
+ public int getFlushWalThreshold() {
+ return flushWalThreshold;
+ }
+
+ public void setFlushWalThreshold(int flushWalThreshold) {
+ this.flushWalThreshold = flushWalThreshold;
+ }
+
+ public long getFlushWalPeriodInMs() {
+ return flushWalPeriodInMs;
+ }
+
+ public void setFlushWalPeriodInMs(long flushWalPeriodInMs) {
+ this.flushWalPeriodInMs = flushWalPeriodInMs;
+ }
+
+ public long getForceWalPeriodInMs() {
+ return forceWalPeriodInMs;
+ }
+
+ public void setForceWalPeriodInMs(long forceWalPeriodInMs) {
+ this.forceWalPeriodInMs = forceWalPeriodInMs;
+ }
+
+ public String getDataDir() {
+ return dataDir;
+ }
+
+ public void setDataDir(String dataDir) {
+ this.dataDir = dataDir;
+ }
+
+ public String getSysDir() {
+ return sysDir;
+ }
+
+ public void setSysDir(String sysDir) {
+ this.sysDir = sysDir;
+ }
+
+ public String getWalDir() {
+ return walDir;
+ }
+
+ public void setWalDir(String walDir) {
+ this.walDir = walDir;
+ }
+
+ public String getOverflowDataDir() {
+ return overflowDataDir;
+ }
+
+ public void setOverflowDataDir(String overflowDataDir) {
+ this.overflowDataDir = overflowDataDir;
+ }
+
+ public String getFileNodeDir() {
+ return fileNodeDir;
+ }
+
+ public void setFileNodeDir(String fileNodeDir) {
+ this.fileNodeDir = fileNodeDir;
+ }
+
+ public void setBufferWriteDirs(String[] bufferWriteDirs) {
+ this.bufferWriteDirs = bufferWriteDirs;
+ }
+
+ public String getMultDirStrategyClassName() {
+ return multDirStrategyClassName;
+ }
+
+ public void setMultDirStrategyClassName(String multDirStrategyClassName) {
+ this.multDirStrategyClassName = multDirStrategyClassName;
+ }
+
+ public String getMetadataDir() {
+ return metadataDir;
+ }
+
+ public void setMetadataDir(String metadataDir) {
+ this.metadataDir = metadataDir;
+ }
+
+ public String getDerbyHome() {
+ return derbyHome;
+ }
+
+ public void setDerbyHome(String derbyHome) {
+ this.derbyHome = derbyHome;
+ }
+
+ public String getWalFolder() {
+ return walFolder;
+ }
+
+ public void setWalFolder(String walFolder) {
+ this.walFolder = walFolder;
+ }
+
+ public String getIndexFileDir() {
+ return indexFileDir;
+ }
+
+ public void setIndexFileDir(String indexFileDir) {
+ this.indexFileDir = indexFileDir;
+ }
+
+ public String getReadTmpFileDir() {
+ return readTmpFileDir;
+ }
+
+ public void setReadTmpFileDir(String readTmpFileDir) {
+ this.readTmpFileDir = readTmpFileDir;
+ }
+
+ public int getMergeConcurrentThreads() {
+ return mergeConcurrentThreads;
+ }
+
+ public void setMergeConcurrentThreads(int mergeConcurrentThreads) {
+ this.mergeConcurrentThreads = mergeConcurrentThreads;
+ }
+
+ public int getMaxOpenFolder() {
+ return maxOpenFolder;
+ }
+
+ public void setMaxOpenFolder(int maxOpenFolder) {
+ this.maxOpenFolder = maxOpenFolder;
+ }
+
+ public int getFetchSize() {
+ return fetchSize;
+ }
+
+ public void setFetchSize(int fetchSize) {
+ this.fetchSize = fetchSize;
+ }
+
+ public int getWriteInstanceThreshold() {
+ return writeInstanceThreshold;
+ }
+
+ public void setWriteInstanceThreshold(int writeInstanceThreshold) {
+ this.writeInstanceThreshold = writeInstanceThreshold;
+ }
+
+ public long getPeriodTimeForFlush() {
+ return periodTimeForFlush;
+ }
+
+ public void setPeriodTimeForFlush(long periodTimeForFlush) {
+ this.periodTimeForFlush = periodTimeForFlush;
+ }
+
+ public long getPeriodTimeForMerge() {
+ return periodTimeForMerge;
+ }
+
+ public void setPeriodTimeForMerge(long periodTimeForMerge) {
+ this.periodTimeForMerge = periodTimeForMerge;
+ }
+
+ public boolean isEnableTimingCloseAndMerge() {
+ return enableTimingCloseAndMerge;
+ }
+
+ public void setEnableTimingCloseAndMerge(boolean enableTimingCloseAndMerge) {
+ this.enableTimingCloseAndMerge = enableTimingCloseAndMerge;
+ }
+
+ public int getConcurrentFlushThread() {
+ return concurrentFlushThread;
+ }
+
+ public void setConcurrentFlushThread(int concurrentFlushThread) {
+ this.concurrentFlushThread = concurrentFlushThread;
+ }
+
+ public void setZoneID(ZoneId zoneID) {
+ this.zoneID = zoneID;
+ }
+
+ public long getMemThresholdWarning() {
+ return memThresholdWarning;
+ }
+
+ public void setMemThresholdWarning(long memThresholdWarning) {
+ this.memThresholdWarning = memThresholdWarning;
+ }
+
+ public long getMemThresholdDangerous() {
+ return memThresholdDangerous;
+ }
+
+ public void setMemThresholdDangerous(long memThresholdDangerous) {
+ this.memThresholdDangerous = memThresholdDangerous;
+ }
+
+ public long getMemMonitorInterval() {
+ return memMonitorInterval;
+ }
+
+ public void setMemMonitorInterval(long memMonitorInterval) {
+ this.memMonitorInterval = memMonitorInterval;
+ }
+
+ public int getMemControllerType() {
+ return memControllerType;
+ }
+
+ public void setMemControllerType(int memControllerType) {
+ this.memControllerType = memControllerType;
+ }
+
+ public long getBufferwriteMetaSizeThreshold() {
+ return bufferwriteMetaSizeThreshold;
+ }
+
+ public void setBufferwriteMetaSizeThreshold(long bufferwriteMetaSizeThreshold) {
+ this.bufferwriteMetaSizeThreshold = bufferwriteMetaSizeThreshold;
+ }
+
+ public long getBufferwriteFileSizeThreshold() {
+ return bufferwriteFileSizeThreshold;
+ }
+
+ public void setBufferwriteFileSizeThreshold(long bufferwriteFileSizeThreshold) {
+ this.bufferwriteFileSizeThreshold = bufferwriteFileSizeThreshold;
+ }
+
+ public long getOverflowMetaSizeThreshold() {
+ return overflowMetaSizeThreshold;
+ }
+
+ public void setOverflowMetaSizeThreshold(long overflowMetaSizeThreshold) {
+ this.overflowMetaSizeThreshold = overflowMetaSizeThreshold;
+ }
+
+ public long getOverflowFileSizeThreshold() {
+ return overflowFileSizeThreshold;
+ }
+
+ public void setOverflowFileSizeThreshold(long overflowFileSizeThreshold) {
+ this.overflowFileSizeThreshold = overflowFileSizeThreshold;
+ }
+
+ public boolean isEnableMemMonitor() {
+ return enableMemMonitor;
+ }
+
+ public void setEnableMemMonitor(boolean enableMemMonitor) {
+ this.enableMemMonitor = enableMemMonitor;
+ }
+
+ public boolean isEnableSmallFlush() {
+ return enableSmallFlush;
+ }
+
+ public void setEnableSmallFlush(boolean enableSmallFlush) {
+ this.enableSmallFlush = enableSmallFlush;
+ }
+
+ public long getSmallFlushInterval() {
+ return smallFlushInterval;
+ }
+
+ public void setSmallFlushInterval(long smallFlushInterval) {
+ this.smallFlushInterval = smallFlushInterval;
+ }
+
+ public int getBackLoopPeriodSec() {
+ return backLoopPeriodSec;
+ }
+
+ public void setBackLoopPeriodSec(int backLoopPeriodSec) {
+ this.backLoopPeriodSec = backLoopPeriodSec;
+ }
+
+ public boolean isEnableStatMonitor() {
+ return enableStatMonitor;
+ }
+
+ public void setEnableStatMonitor(boolean enableStatMonitor) {
+ this.enableStatMonitor = enableStatMonitor;
+ }
+
+ public int getStatMonitorDetectFreqSec() {
+ return statMonitorDetectFreqSec;
+ }
+
+ public void setStatMonitorDetectFreqSec(int statMonitorDetectFreqSec) {
+ this.statMonitorDetectFreqSec = statMonitorDetectFreqSec;
+ }
+
+ public int getStatMonitorRetainIntervalSec() {
+ return statMonitorRetainIntervalSec;
+ }
+
+ public void setStatMonitorRetainIntervalSec(int statMonitorRetainIntervalSec) {
+ this.statMonitorRetainIntervalSec = statMonitorRetainIntervalSec;
+ }
+
+ public int getExternalSortThreshold() {
+ return externalSortThreshold;
+ }
+
+ public void setExternalSortThreshold(int externalSortThreshold) {
+ this.externalSortThreshold = externalSortThreshold;
+ }
+
+ public int getmManagerCacheSize() {
+ return mManagerCacheSize;
+ }
+
+ public void setmManagerCacheSize(int mManagerCacheSize) {
+ this.mManagerCacheSize = mManagerCacheSize;
+ }
+
+ public int getMaxLogEntrySize() {
+ return maxLogEntrySize;
+ }
+
+ public void setMaxLogEntrySize(int maxLogEntrySize) {
+ this.maxLogEntrySize = maxLogEntrySize;
+ }
+
+ public boolean isPostbackEnable() {
+ return isPostbackEnable;
+ }
+
+ public void setPostbackEnable(boolean postbackEnable) {
+ isPostbackEnable = postbackEnable;
+ }
+
+ public int getPostbackServerPort() {
+ return postbackServerPort;
+ }
+
+ public void setPostbackServerPort(int postbackServerPort) {
+ this.postbackServerPort = postbackServerPort;
+ }
+
+ public String getLanguageVersion() {
+ return languageVersion;
+ }
+
+ public void setLanguageVersion(String languageVersion) {
+ this.languageVersion = languageVersion;
+ }
+
+ public boolean isUpdate_historical_data_possibility() {
+ return update_historical_data_possibility;
+ }
+
+ public void setUpdate_historical_data_possibility(boolean update_historical_data_possibility) {
+ this.update_historical_data_possibility = update_historical_data_possibility;
+ }
+
+ public String getIpWhiteList() {
+ return ipWhiteList;
+ }
+
+ public void setIpWhiteList(String ipWhiteList) {
+ this.ipWhiteList = ipWhiteList;
+ }
+
+ public long getCacheFileReaderClearPeriod() {
+ return cacheFileReaderClearPeriod;
+ }
+
+ public void setCacheFileReaderClearPeriod(long cacheFileReaderClearPeriod) {
+ this.cacheFileReaderClearPeriod = cacheFileReaderClearPeriod;
+ }
}
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java b/iotdb/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
index 5cb2fab..4108a2f 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
@@ -38,7 +38,7 @@ public class IoTDBDescriptor {
loadProps();
}
- public static final IoTDBDescriptor getInstance() {
+ public static IoTDBDescriptor getInstance() {
return IoTDBDescriptorHolder.INSTANCE;
}
@@ -50,7 +50,7 @@ public class IoTDBDescriptor {
* load an property file and set TsfileDBConfig variables.
*/
private void loadProps() {
- InputStream inputStream = null;
+ InputStream inputStream;
String url = System.getProperty(IoTDBConstant.IOTDB_CONF, null);
if (url == null) {
url = System.getProperty(IoTDBConstant.IOTDB_HOME, null);
@@ -72,7 +72,7 @@ public class IoTDBDescriptor {
try {
inputStream = new FileInputStream(new File(url));
} catch (FileNotFoundException e) {
- LOGGER.warn("Fail to find config file {}", url);
+ LOGGER.warn("Fail to find config file {}", url, e);
// update all data seriesPath
conf.updatePath();
return;
@@ -82,179 +82,178 @@ public class IoTDBDescriptor {
Properties properties = new Properties();
try {
properties.load(inputStream);
- conf.enableStatMonitor = Boolean
+ conf.setEnableStatMonitor(Boolean
.parseBoolean(properties.getProperty("enable_stat_monitor",
- Boolean.toString(conf.enableStatMonitor)));
- conf.backLoopPeriodSec = Integer
+ Boolean.toString(conf.isEnableStatMonitor()))));
+ conf.setBackLoopPeriodSec(Integer
.parseInt(properties.getProperty("back_loop_period_sec",
- Integer.toString(conf.backLoopPeriodSec)));
+ Integer.toString(conf.getBackLoopPeriodSec()))));
int statMonitorDetectFreqSec = Integer.parseInt(
properties.getProperty("stat_monitor_detect_freq_sec",
- Integer.toString(conf.statMonitorDetectFreqSec)));
+ Integer.toString(conf.getStatMonitorDetectFreqSec())));
int statMonitorRetainIntervalSec = Integer.parseInt(
properties.getProperty("stat_monitor_retain_interval_sec",
- Integer.toString(conf.statMonitorRetainIntervalSec)));
+ Integer.toString(conf.getStatMonitorRetainIntervalSec())));
// the conf value must > default value, or may cause system unstable
- if (conf.statMonitorDetectFreqSec < statMonitorDetectFreqSec) {
- conf.statMonitorDetectFreqSec = statMonitorDetectFreqSec;
+ if (conf.getStatMonitorDetectFreqSec() < statMonitorDetectFreqSec) {
+ conf.setStatMonitorDetectFreqSec(statMonitorDetectFreqSec);
} else {
LOGGER.info("The stat_monitor_detect_freq_sec value is smaller than default,"
+ " use default value");
}
- if (conf.statMonitorRetainIntervalSec < statMonitorRetainIntervalSec) {
- conf.statMonitorRetainIntervalSec = statMonitorRetainIntervalSec;
+ if (conf.getStatMonitorRetainIntervalSec() < statMonitorRetainIntervalSec) {
+ conf.setStatMonitorRetainIntervalSec(statMonitorRetainIntervalSec);
} else {
LOGGER.info("The stat_monitor_retain_interval_sec value is smaller than default,"
+ " use default value");
}
- conf.rpcAddress = properties.getProperty("rpc_address", conf.rpcAddress);
+ conf.setRpcAddress(properties.getProperty("rpc_address", conf.getRpcAddress()));
- conf.rpcPort = Integer.parseInt(properties.getProperty("rpc_port",
- Integer.toString(conf.rpcPort)));
+ conf.setRpcPort(Integer.parseInt(properties.getProperty("rpc_port",
+ Integer.toString(conf.getRpcPort()))));
- conf.enableWal = Boolean.parseBoolean(properties.getProperty("enable_wal",
- Boolean.toString(conf.enableWal)));
+ conf.setEnableWal(Boolean.parseBoolean(properties.getProperty("enable_wal",
+ Boolean.toString(conf.isEnableWal()))));
- conf.flushWalThreshold = Integer
+ conf.setFlushWalThreshold(Integer
.parseInt(properties.getProperty("flush_wal_threshold",
- Integer.toString(conf.flushWalThreshold)));
- conf.flushWalPeriodInMs = Long
+ Integer.toString(conf.getFlushWalThreshold()))));
+ conf.setFlushWalPeriodInMs(Long
.parseLong(properties.getProperty("flush_wal_period_in_ms",
- Long.toString(conf.flushWalPeriodInMs)));
- conf.forceWalPeriodInMs = Long
+ Long.toString(conf.getFlushWalPeriodInMs()))));
+ conf.setForceWalPeriodInMs(Long
.parseLong(properties.getProperty("force_wal_period_in_ms",
- Long.toString(conf.forceWalPeriodInMs)));
+ Long.toString(conf.getForceWalPeriodInMs()))));
- conf.dataDir = properties.getProperty("data_dir", conf.dataDir);
- conf.bufferWriteDirs = properties.getProperty("tsfile_dir", conf.default_tsfile_dir)
- .split(",");
- conf.sysDir = properties.getProperty("sys_dir", conf.sysDir);
- conf.walDir = properties.getProperty("wal_dir", conf.walDir);
+ conf.setDataDir(properties.getProperty("data_dir", conf.getDataDir()));
+ conf.setBufferWriteDirs(properties.getProperty("tsfile_dir", conf.DEFAULT_TSFILE_DIR)
+ .split(","));
+ conf.setSysDir(properties.getProperty("sys_dir", conf.getSysDir()));
+ conf.setWalDir(properties.getProperty("wal_dir", conf.getWalDir()));
- conf.multDirStrategyClassName = properties.getProperty("mult_dir_strategy",
- conf.multDirStrategyClassName);
+ conf.setMultDirStrategyClassName(properties.getProperty("mult_dir_strategy",
+ conf.getMultDirStrategyClassName()));
- conf.maxOpenFolder = Integer.parseInt(properties.getProperty("max_opened_folder",
- Integer.toString(conf.maxOpenFolder)));
- conf.mergeConcurrentThreads = Integer
+ conf.setMaxOpenFolder(Integer.parseInt(properties.getProperty("max_opened_folder",
+ Integer.toString(conf.getMaxOpenFolder()))));
+ conf.setMergeConcurrentThreads(Integer
.parseInt(properties.getProperty("merge_concurrent_threads",
- Integer.toString(conf.mergeConcurrentThreads)));
- if (conf.mergeConcurrentThreads <= 0
- || conf.mergeConcurrentThreads > Runtime.getRuntime().availableProcessors()) {
- conf.mergeConcurrentThreads = Runtime.getRuntime().availableProcessors();
+ Integer.toString(conf.getMergeConcurrentThreads()))));
+ if (conf.getMergeConcurrentThreads() <= 0
+ || conf.getMergeConcurrentThreads() > Runtime.getRuntime().availableProcessors()) {
+ conf.setMergeConcurrentThreads(Runtime.getRuntime().availableProcessors());
}
- conf.fetchSize = Integer.parseInt(properties.getProperty("fetch_size",
- Integer.toString(conf.fetchSize)));
+ conf.setFetchSize(Integer.parseInt(properties.getProperty("fetch_size",
+ Integer.toString(conf.getFetchSize()))));
- conf.periodTimeForFlush = Long.parseLong(
+ conf.setPeriodTimeForFlush(Long.parseLong(
properties.getProperty("period_time_for_flush_in_second",
- Long.toString(conf.periodTimeForFlush)).trim());
- conf.periodTimeForMerge = Long.parseLong(
+ Long.toString(conf.getPeriodTimeForFlush())).trim()));
+ conf.setPeriodTimeForMerge(Long.parseLong(
properties.getProperty("period_time_for_merge_in_second",
- Long.toString(conf.periodTimeForMerge)).trim());
- conf.enableTimingCloseAndMerge = Boolean.parseBoolean(properties
+ Long.toString(conf.getPeriodTimeForMerge())).trim()));
+ conf.setEnableTimingCloseAndMerge(Boolean.parseBoolean(properties
.getProperty("enable_timing_close_and_Merge",
- Boolean.toString(conf.enableTimingCloseAndMerge)).trim());
+ Boolean.toString(conf.isEnableTimingCloseAndMerge())).trim()));
- conf.memThresholdWarning = (long) (Runtime.getRuntime().maxMemory() * Double.parseDouble(
+ conf.setMemThresholdWarning((long) (Runtime.getRuntime().maxMemory() * Double.parseDouble(
properties.getProperty("mem_threshold_warning",
- Long.toString(conf.memThresholdWarning)).trim()));
- conf.memThresholdDangerous = (long) (Runtime.getRuntime().maxMemory() * Double.parseDouble(
+ Long.toString(conf.getMemThresholdWarning())).trim())));
+ conf.setMemThresholdDangerous((long) (Runtime.getRuntime().maxMemory() * Double.parseDouble(
properties.getProperty("mem_threshold_dangerous",
- Long.toString(conf.memThresholdDangerous)).trim()));
+ Long.toString(conf.getMemThresholdDangerous())).trim())));
- conf.memMonitorInterval = Long
+ conf.setMemMonitorInterval(Long
.parseLong(properties.getProperty("mem_monitor_interval",
- Long.toString(conf.memMonitorInterval)).trim());
+ Long.toString(conf.getMemMonitorInterval())).trim()));
- conf.memControllerType = Integer
+ conf.setMemControllerType(Integer
.parseInt(properties.getProperty("mem_controller_type",
- Integer.toString(conf.memControllerType)).trim());
- conf.memControllerType = conf.memControllerType >= ControllerType.values().length ? 0
- : conf.memControllerType;
+ Integer.toString(conf.getMemControllerType())).trim()));
+ conf.setMemControllerType(conf.getMemControllerType() >= ControllerType.values().length ? 0
+ : conf.getMemControllerType());
- conf.bufferwriteMetaSizeThreshold = Long.parseLong(properties
+ conf.setBufferwriteMetaSizeThreshold(Long.parseLong(properties
.getProperty("bufferwrite_meta_size_threshold",
- Long.toString(conf.bufferwriteMetaSizeThreshold)).trim());
- conf.bufferwriteFileSizeThreshold = Long.parseLong(properties
+ Long.toString(conf.getBufferwriteMetaSizeThreshold())).trim()));
+ conf.setBufferwriteFileSizeThreshold(Long.parseLong(properties
.getProperty("bufferwrite_file_size_threshold",
- Long.toString(conf.bufferwriteFileSizeThreshold)).trim());
+ Long.toString(conf.getBufferwriteFileSizeThreshold())).trim()));
- conf.overflowMetaSizeThreshold = Long.parseLong(
+ conf.setOverflowMetaSizeThreshold(Long.parseLong(
properties.getProperty("overflow_meta_size_threshold",
- Long.toString(conf.overflowMetaSizeThreshold)).trim());
- conf.overflowFileSizeThreshold = Long.parseLong(
+ Long.toString(conf.getOverflowMetaSizeThreshold())).trim()));
+ conf.setOverflowFileSizeThreshold(Long.parseLong(
properties.getProperty("overflow_file_size_threshold",
- Long.toString(conf.overflowFileSizeThreshold)).trim());
+ Long.toString(conf.getOverflowFileSizeThreshold())).trim()));
- conf.isPostbackEnable = Boolean
+ conf.setPostbackEnable(Boolean
.parseBoolean(properties.getProperty("is_postback_enable",
- Boolean.toString(conf.isPostbackEnable)));
- conf.postbackServerPort = Integer
+ Boolean.toString(conf.isPostbackEnable()))));
+ conf.setPostbackServerPort(Integer
.parseInt(properties.getProperty("postback_server_port",
- Integer.toString(conf.postbackServerPort)).trim());
- conf.update_historical_data_possibility = Boolean.parseBoolean(
+ Integer.toString(conf.getPostbackServerPort())).trim()));
+ conf.setUpdate_historical_data_possibility(Boolean.parseBoolean(
properties.getProperty("update_historical_data_possibility",
- Boolean.toString(conf.isPostbackEnable)));
- conf.ipWhiteList = properties.getProperty("IP_white_list", conf.ipWhiteList);
+ Boolean.toString(conf.isPostbackEnable()))));
+ conf.setIpWhiteList(properties.getProperty("IP_white_list", conf.getIpWhiteList()));
- if (conf.memThresholdWarning <= 0) {
- conf.memThresholdWarning = IoTDBConstant.MEM_THRESHOLD_WARNING_DEFAULT;
+ if (conf.getMemThresholdWarning() <= 0) {
+ conf.setMemThresholdWarning(IoTDBConstant.MEM_THRESHOLD_WARNING_DEFAULT);
}
- if (conf.memThresholdDangerous < conf.memThresholdWarning) {
- conf.memThresholdDangerous = Math.max(conf.memThresholdWarning,
- IoTDBConstant.MEM_THRESHOLD_DANGEROUS_DEFAULT);
+ if (conf.getMemThresholdDangerous() < conf.getMemThresholdWarning()) {
+ conf.setMemThresholdDangerous(Math.max(conf.getMemThresholdWarning(),
+ IoTDBConstant.MEM_THRESHOLD_DANGEROUS_DEFAULT));
}
- conf.concurrentFlushThread = Integer
+ conf.setConcurrentFlushThread(Integer
.parseInt(properties.getProperty("concurrent_flush_thread",
- Integer.toString(conf.concurrentFlushThread)));
- if (conf.concurrentFlushThread <= 0) {
- conf.concurrentFlushThread = Runtime.getRuntime().availableProcessors();
+ Integer.toString(conf.getConcurrentFlushThread()))));
+ if (conf.getConcurrentFlushThread() <= 0) {
+ conf.setConcurrentFlushThread(Runtime.getRuntime().availableProcessors());
}
- conf.enableMemMonitor = Boolean
+ conf.setEnableMemMonitor(Boolean
.parseBoolean(properties.getProperty("enable_mem_monitor",
- Boolean.toString(conf.enableMemMonitor)).trim());
- conf.enableSmallFlush = Boolean
+ Boolean.toString(conf.isEnableMemMonitor())).trim()));
+ conf.setEnableSmallFlush(Boolean
.parseBoolean(properties.getProperty("enable_small_flush",
- Boolean.toString(conf.enableSmallFlush)).trim());
- conf.smallFlushInterval = Long
+ Boolean.toString(conf.isEnableSmallFlush())).trim()));
+ conf.setSmallFlushInterval(Long
.parseLong(properties.getProperty("small_flush_interval",
- Long.toString(conf.smallFlushInterval)).trim());
- conf.externalSortThreshold = Integer.parseInt(
+ Long.toString(conf.getSmallFlushInterval())).trim()));
+ conf.setExternalSortThreshold(Integer.parseInt(
properties.getProperty("external_sort_threshold",
- Integer.toString(conf.externalSortThreshold)).trim());
- conf.mManagerCacheSize = Integer
+ Integer.toString(conf.getExternalSortThreshold())).trim()));
+ conf.setmManagerCacheSize(Integer
.parseInt(properties.getProperty("schema_manager_cache_size",
- Integer.toString(conf.mManagerCacheSize)).trim());
+ Integer.toString(conf.getmManagerCacheSize())).trim()));
int maxLogEntrySize = Integer
.parseInt(properties.getProperty("max_log_entry_size",
- Integer.toString(conf.maxLogEntrySize)).trim());
- conf.maxLogEntrySize = maxLogEntrySize > 0 ? maxLogEntrySize :
- conf.maxLogEntrySize;
+ Integer.toString(conf.getMaxLogEntrySize())).trim());
+ conf.setMaxLogEntrySize(maxLogEntrySize > 0 ? maxLogEntrySize :
+ conf.getMaxLogEntrySize());
- conf.languageVersion = properties.getProperty("language_version",
- conf.languageVersion).trim();
+ conf.setLanguageVersion(properties.getProperty("language_version",
+ conf.getLanguageVersion()).trim());
- String tmpTimeZone = properties.getProperty("time_zone", conf.zoneID.toString());
+ String tmpTimeZone = properties.getProperty("time_zone", conf.getZoneID().toString());
try {
- conf.zoneID = ZoneId.of(tmpTimeZone.trim());
- LOGGER.info("Time zone has been set to {}", conf.zoneID);
+ conf.setZoneID(ZoneId.of(tmpTimeZone.trim()));
+ LOGGER.info("Time zone has been set to {}", conf.getZoneID());
} catch (Exception e) {
- LOGGER.error("Time zone foramt error {}, use default configuration {}", tmpTimeZone,
- conf.zoneID);
+ LOGGER.error("Time zone format error {}, use default configuration {}", tmpTimeZone,
+ conf.getZoneID(), e);
}
} catch (IOException e) {
- LOGGER.warn("Cannot load config file because {}, use default configuration", e.getMessage());
+ LOGGER.warn("Cannot load config file because, use default configuration", e);
} catch (Exception e) {
- LOGGER.warn("Error format in config file because {}, use default configuration",
- e.getMessage());
+ LOGGER.warn("Incorrect format in config file, use default configuration", e);
} finally {
// update all data seriesPath
conf.updatePath();
@@ -262,7 +261,7 @@ public class IoTDBDescriptor {
try {
inputStream.close();
} catch (IOException e) {
- LOGGER.error("Fail to close config file input stream because {}", e.getMessage());
+ LOGGER.error("Fail to close config file input stream because ", e);
}
}
}
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 789a81e..ad9c847 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
@@ -46,12 +46,12 @@ public class Directories {
String strategyName = "";
try {
- strategyName = IoTDBDescriptor.getInstance().getConfig().multDirStrategyClassName;
+ strategyName = IoTDBDescriptor.getInstance().getConfig().getMultDirStrategyClassName();
Class<?> clazz = Class.forName(strategyName);
strategy = (DirectoryStrategy) clazz.newInstance();
strategy.init(tsfileFolders);
} catch (Exception e) {
- LOGGER.error("can't find strategy {} for mult-directories.", strategyName);
+ LOGGER.error("can't find strategy {} for mult-directories.", strategyName, e);
}
}
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/conf/directories/strategy/MinDirOccupiedSpaceFirstStrategy.java b/iotdb/src/main/java/org/apache/iotdb/db/conf/directories/strategy/MinDirOccupiedSpaceFirstStrategy.java
index d6bb2dd..8174a36 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/conf/directories/strategy/MinDirOccupiedSpaceFirstStrategy.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/conf/directories/strategy/MinDirOccupiedSpaceFirstStrategy.java
@@ -68,7 +68,7 @@ public class MinDirOccupiedSpaceFirstStrategy extends DirectoryStrategy {
.sum();
}
} catch (IOException e) {
- LOGGER.error("Cannot calculate occupied space for seriesPath {}.", path);
+ LOGGER.error("Cannot calculate occupied space for seriesPath {}.", path, e);
}
return size / DATA_SIZE_SHIFT;
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/conf/directories/strategy/MinFolderOccupiedSpaceFirstStrategy.java b/iotdb/src/main/java/org/apache/iotdb/db/conf/directories/strategy/MinFolderOccupiedSpaceFirstStrategy.java
index 224aee9..90e3119 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/conf/directories/strategy/MinFolderOccupiedSpaceFirstStrategy.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/conf/directories/strategy/MinFolderOccupiedSpaceFirstStrategy.java
@@ -68,7 +68,7 @@ public class MinFolderOccupiedSpaceFirstStrategy extends DirectoryStrategy {
.sum();
}
} catch (IOException e) {
- LOGGER.error("Cannot calculate occupied space for seriesPath {}.", path);
+ LOGGER.error("Cannot calculate occupied space for seriesPath {}.", path, e);
}
return size / DATA_SIZE_SHIFT;
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/engine/bufferwrite/BufferWriteProcessor.java b/iotdb/src/main/java/org/apache/iotdb/db/engine/bufferwrite/BufferWriteProcessor.java
index dc56312..e09feec 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/engine/bufferwrite/BufferWriteProcessor.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/engine/bufferwrite/BufferWriteProcessor.java
@@ -23,6 +23,7 @@ import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicLong;
@@ -101,10 +102,11 @@ public class BufferWriteProcessor extends Processor {
this.baseDir = baseDir;
this.fileName = fileName;
- if (baseDir.length() > 0 && baseDir.charAt(baseDir.length() - 1) != File.separatorChar) {
- baseDir = baseDir + File.separatorChar;
+ String bDir = baseDir;
+ if (bDir.length() > 0 && bDir.charAt(bDir.length() - 1) != File.separatorChar) {
+ bDir = bDir + File.separatorChar;
}
- String dataDirPath = baseDir + processorName;
+ String dataDirPath = bDir + processorName;
File dataDir = new File(dataDirPath);
if (!dataDir.exists()) {
dataDir.mkdirs();
@@ -124,7 +126,7 @@ public class BufferWriteProcessor extends Processor {
filenodeFlushAction = parameters.get(FileNodeConstants.FILENODE_PROCESSOR_FLUSH_ACTION);
workMemTable = new PrimitiveMemTable();
- if (IoTDBDescriptor.getInstance().getConfig().enableWal) {
+ if (IoTDBDescriptor.getInstance().getConfig().isEnableWal()) {
try {
logNode = MultiFileLogNodeManager.getInstance().getNode(
processorName + IoTDBConstant.BUFFERWRITE_LOG_NODE_SUFFIX,
@@ -194,9 +196,9 @@ public class BufferWriteProcessor extends Processor {
}
private void checkMemThreshold4Flush(long addedMemory) throws BufferWriteProcessorException {
- addedMemory = memSize.addAndGet(addedMemory);
- if (addedMemory > memThreshold) {
- String usageMem = MemUtils.bytesCntToStr(addedMemory);
+ long newMem = memSize.addAndGet(addedMemory);
+ if (newMem > memThreshold) {
+ String usageMem = MemUtils.bytesCntToStr(newMem);
String threshold = MemUtils.bytesCntToStr(memThreshold);
String processorName = getProcessorName();
LOGGER.info("The usage of memory {} in bufferwrite processor {} reaches the threshold {}",
@@ -286,7 +288,7 @@ public class BufferWriteProcessor extends Processor {
}
filenodeFlushAction.act();
- if (IoTDBDescriptor.getInstance().getConfig().enableWal) {
+ if (IoTDBDescriptor.getInstance().getConfig().isEnableWal()) {
logNode.notifyEndFlush(null);
}
result = true;
@@ -347,7 +349,7 @@ public class BufferWriteProcessor extends Processor {
LOGGER.error("Failed to flush bufferwrite row group when calling the action function.");
throw new IOException(e);
}
- if (IoTDBDescriptor.getInstance().getConfig().enableWal) {
+ if (IoTDBDescriptor.getInstance().getConfig().isEnableWal()) {
logNode.notifyStartFlush();
}
valueCount = 0;
@@ -460,15 +462,15 @@ public class BufferWriteProcessor extends Processor {
IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
long metaSize = getMetaSize();
long fileSize = getFileSize();
- if (metaSize >= config.bufferwriteMetaSizeThreshold
- || fileSize >= config.bufferwriteFileSizeThreshold) {
+ if (metaSize >= config.getBufferwriteMetaSizeThreshold()
+ || fileSize >= config.getBufferwriteFileSizeThreshold()) {
LOGGER.info(
"The bufferwrite processor {}, size({}) of the file {} reaches threshold {}, "
+ "size({}) of metadata reaches threshold {}.",
getProcessorName(), MemUtils.bytesCntToStr(fileSize), this.fileName,
- MemUtils.bytesCntToStr(config.bufferwriteFileSizeThreshold),
+ MemUtils.bytesCntToStr(config.getBufferwriteFileSizeThreshold()),
MemUtils.bytesCntToStr(metaSize),
- MemUtils.bytesCntToStr(config.bufferwriteFileSizeThreshold));
+ MemUtils.bytesCntToStr(config.getBufferwriteFileSizeThreshold()));
rollToNewFile();
return true;
@@ -536,4 +538,25 @@ public class BufferWriteProcessor extends Processor {
flushMemTable.delete(deviceId, measurementId, timestamp);
}
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ if (!super.equals(o)) {
+ return false;
+ }
+ BufferWriteProcessor that = (BufferWriteProcessor) o;
+ return Objects.equals(baseDir, that.baseDir) &&
+ Objects.equals(fileName, that.fileName);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(super.hashCode(), baseDir, fileName);
+ }
}
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/engine/bufferwrite/RestorableTsFileIOWriter.java b/iotdb/src/main/java/org/apache/iotdb/db/engine/bufferwrite/RestorableTsFileIOWriter.java
index 7331104..7898246 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/engine/bufferwrite/RestorableTsFileIOWriter.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/engine/bufferwrite/RestorableTsFileIOWriter.java
@@ -114,12 +114,12 @@ public class RestorableTsFileIOWriter extends TsFileIOWriter {
try {
Files.deleteIfExists(insertFile.toPath());
} catch (IOException e) {
- LOGGER.info("remove unsealed tsfile failed: {}", e.getMessage());
+ LOGGER.info("remove unsealed tsfile failed: ", e);
}
try {
Files.deleteIfExists(restoreFile.toPath());
} catch (IOException e) {
- LOGGER.info("remove unsealed tsfile restore file failed: {}", e.getMessage());
+ LOGGER.info("remove unsealed tsfile restore file failed: ", e);
}
this.out = new DefaultTsFileOutput(new FileOutputStream(insertFile));
@@ -290,7 +290,7 @@ public class RestorableTsFileIOWriter extends TsFileIOWriter {
try {
Files.delete(Paths.get(restoreFilePath));
} catch (IOException e) {
- LOGGER.info("delete restore file {} failed, because {}.", restoreFilePath, e.getMessage());
+ LOGGER.info("delete restore file {} failed, because ", restoreFilePath, e);
}
}
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/engine/cache/RowGroupBlockMetaDataCache.java b/iotdb/src/main/java/org/apache/iotdb/db/engine/cache/RowGroupBlockMetaDataCache.java
index 482715a..044fb5d 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/engine/cache/RowGroupBlockMetaDataCache.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/engine/cache/RowGroupBlockMetaDataCache.java
@@ -132,6 +132,22 @@ public class RowGroupBlockMetaDataCache {
protected boolean removeEldestEntry(Map.Entry<String, TsDeviceMetadata> eldest) {
return size() > maxCapacity;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ return super.equals(o);
+ }
+
+ @Override
+ public int hashCode() {
+ return super.hashCode();
+ }
}
@Override
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/engine/filenode/FileNodeFlushFuture.java b/iotdb/src/main/java/org/apache/iotdb/db/engine/filenode/FileNodeFlushFuture.java
index 660c949..85c5bb4 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/engine/filenode/FileNodeFlushFuture.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/engine/filenode/FileNodeFlushFuture.java
@@ -55,9 +55,9 @@ public class FileNodeFlushFuture implements Future<Boolean> {
*/
@Override
public boolean cancel(boolean mayInterruptIfRunning) {
- boolean result = bufferWriteFlushFuture.cancel(mayInterruptIfRunning);
- result = result & overflowFlushFuture.cancel(mayInterruptIfRunning);
- return result;
+ boolean bwResult = bufferWriteFlushFuture.cancel(mayInterruptIfRunning);
+ boolean ofResult = overflowFlushFuture.cancel(mayInterruptIfRunning);
+ return bwResult && ofResult;
}
@Override
@@ -72,9 +72,9 @@ public class FileNodeFlushFuture implements Future<Boolean> {
@Override
public Boolean get() throws InterruptedException, ExecutionException {
- boolean result = bufferWriteFlushFuture.get();
- result = result & overflowFlushFuture.get();
- return result;
+ boolean bwResult = bufferWriteFlushFuture.get();
+ boolean ofResult = overflowFlushFuture.get();
+ return bwResult && ofResult;
}
@Override
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/engine/filenode/FileNodeManager.java b/iotdb/src/main/java/org/apache/iotdb/db/engine/filenode/FileNodeManager.java
index 049235f..4135de3 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/engine/filenode/FileNodeManager.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/engine/filenode/FileNodeManager.java
@@ -113,7 +113,7 @@ public class FileNodeManager implements IStatistic, IService {
LOGGER.info("{} dir home doesn't exist, create it", dir.getPath());
}
//TODO merge this with label A
- if (TsFileDBConf.enableStatMonitor) {
+ if (TsFileDBConf.isEnableStatMonitor()) {
StatMonitor statMonitor = StatMonitor.getInstance();
registStatMetadata();
statMonitor.registStatistics(MonitorConstants.STAT_STORAGE_DELTA_NAME, this);
@@ -323,7 +323,7 @@ public class FileNodeManager implements IStatistic, IService {
private void writeLog(TSRecord tsRecord, boolean isMonitor, WriteLogNode logNode)
throws FileNodeManagerException {
try {
- if (IoTDBDescriptor.getInstance().getConfig().enableWal) {
+ if (IoTDBDescriptor.getInstance().getConfig().isEnableWal()) {
List<String> measurementList = new ArrayList<>();
List<String> insertValues = new ArrayList<>();
for (DataPoint dp : tsRecord.dataPointList) {
@@ -433,14 +433,14 @@ public class FileNodeManager implements IStatistic, IService {
if (bufferWriteProcessor
.getFileSize() > IoTDBDescriptor.getInstance()
- .getConfig().bufferwriteFileSizeThreshold) {
+ .getConfig().getBufferwriteFileSizeThreshold()) {
if (LOGGER.isInfoEnabled()) {
LOGGER.info(
"The filenode processor {} will close the bufferwrite processor, "
+ "because the size[{}] of tsfile {} reaches the threshold {}",
filenodeName, MemUtils.bytesCntToStr(bufferWriteProcessor.getFileSize()),
bufferWriteProcessor.getFileName(), MemUtils.bytesCntToStr(
- IoTDBDescriptor.getInstance().getConfig().bufferwriteFileSizeThreshold));
+ IoTDBDescriptor.getInstance().getConfig().getBufferwriteFileSizeThreshold()));
}
fileNodeProcessor.closeBufferWrite();
@@ -485,7 +485,7 @@ public class FileNodeManager implements IStatistic, IService {
// write wal
try {
- if (IoTDBDescriptor.getInstance().getConfig().enableWal) {
+ if (IoTDBDescriptor.getInstance().getConfig().isEnableWal()) {
overflowProcessor.getLogNode().write(
new UpdatePlan(startTime, finalEndTime, v, new Path(deviceId
+ "." + measurementId)));
@@ -514,7 +514,7 @@ public class FileNodeManager implements IStatistic, IService {
fileNodeProcessor.getProcessorName());
} else {
// write wal
- if (IoTDBDescriptor.getInstance().getConfig().enableWal) {
+ if (IoTDBDescriptor.getInstance().getConfig().isEnableWal()) {
// get processors for wal
String filenodeName = fileNodeProcessor.getProcessorName();
OverflowProcessor overflowProcessor;
@@ -846,7 +846,7 @@ public class FileNodeManager implements IStatistic, IService {
if (processorMap.containsKey(processorName)) {
deleteFileNodeBlocked(processorName);
}
- String fileNodePath = TsFileDBConf.fileNodeDir;
+ String fileNodePath = TsFileDBConf.getFileNodeDir();
fileNodePath = standardizeDir(fileNodePath) + processorName;
FileUtils.deleteDirectory(new File(fileNodePath));
@@ -1187,7 +1187,8 @@ public class FileNodeManager implements IStatistic, IService {
private FileNodeManagerHolder() {
}
- private static final FileNodeManager INSTANCE = new FileNodeManager(TsFileDBConf.fileNodeDir);
+ private static final FileNodeManager INSTANCE = new FileNodeManager(
+ TsFileDBConf.getFileNodeDir());
}
}
\ No newline at end of file
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 11f0d6a..0d43be8 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
@@ -289,7 +289,7 @@ public class FileNodeProcessor extends Processor implements IStatistic {
addAllFileIntoIndex(newFileNodes);
}
// RegistStatService
- if (TsFileDBConf.enableStatMonitor) {
+ if (TsFileDBConf.isEnableStatMonitor()) {
StatMonitor statMonitor = StatMonitor.getInstance();
registStatMetadata();
statMonitor.registStatistics(statStorageDeltaName, this);
@@ -941,14 +941,14 @@ public class FileNodeProcessor extends Processor implements IStatistic {
if (overflowProcessor != null) {
if (overflowProcessor.getFileSize() < IoTDBDescriptor.getInstance()
- .getConfig().overflowFileSizeThreshold) {
+ .getConfig().getOverflowFileSizeThreshold()) {
if (LOGGER.isInfoEnabled()) {
LOGGER.info(
"Skip this merge taks submission, because the size{} of overflow processor {} "
+ "does not reaches the threshold {}.",
MemUtils.bytesCntToStr(overflowProcessor.getFileSize()), getProcessorName(),
MemUtils.bytesCntToStr(
- IoTDBDescriptor.getInstance().getConfig().overflowFileSizeThreshold));
+ IoTDBDescriptor.getInstance().getConfig().getOverflowFileSizeThreshold()));
}
return null;
}
@@ -1766,7 +1766,7 @@ public class FileNodeProcessor extends Processor implements IStatistic {
* deregister the filenode processor.
*/
public void delete() throws ProcessorException {
- if (TsFileDBConf.enableStatMonitor) {
+ if (TsFileDBConf.isEnableStatMonitor()) {
// remove the monitor
LOGGER.info("Deregister the filenode processor: {} from monitor.", getProcessorName());
StatMonitor.getInstance().deregistStatistics(statStorageDeltaName);
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 44ded49..fe6753a 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
@@ -37,8 +37,8 @@ public abstract class BasicMemController implements IService {
BasicMemController(IoTDBConfig config) {
this.config = config;
- warningThreshold = config.memThresholdWarning;
- dangerouseThreshold = config.memThresholdDangerous;
+ warningThreshold = config.getMemThresholdWarning();
+ dangerouseThreshold = config.getMemThresholdDangerous();
}
/**
@@ -47,7 +47,8 @@ public abstract class BasicMemController implements IService {
* @return BasicMemController
*/
public static BasicMemController getInstance() {
- switch (ControllerType.values()[IoTDBDescriptor.getInstance().getConfig().memControllerType]) {
+ switch (ControllerType.values()[IoTDBDescriptor.getInstance().getConfig()
+ .getMemControllerType()]) {
case JVM:
return JVMMemController.getInstance();
case RECORD:
@@ -59,7 +60,7 @@ public abstract class BasicMemController implements IService {
@Override
public void start() throws StartupException {
try {
- if (config.enableMemMonitor) {
+ if (config.isEnableMemMonitor()) {
if (monitorThread == null) {
monitorThread = new MemMonitorThread(config);
monitorThread.start();
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/engine/memcontrol/FlushPartialPolicy.java b/iotdb/src/main/java/org/apache/iotdb/db/engine/memcontrol/FlushPartialPolicy.java
index 721bb54..31a5860 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/engine/memcontrol/FlushPartialPolicy.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/engine/memcontrol/FlushPartialPolicy.java
@@ -32,7 +32,7 @@ public class FlushPartialPolicy implements Policy {
private static final Logger LOGGER = LoggerFactory.getLogger(FlushPartialPolicy.class);
private Thread workerThread;
- private long sleepInterval = IoTDBDescriptor.getInstance().getConfig().smallFlushInterval;
+ private long sleepInterval = IoTDBDescriptor.getInstance().getConfig().getSmallFlushInterval();
@Override
public void execute() {
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/engine/memcontrol/MemMonitorThread.java b/iotdb/src/main/java/org/apache/iotdb/db/engine/memcontrol/MemMonitorThread.java
index a83b264..05226aa 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/engine/memcontrol/MemMonitorThread.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/engine/memcontrol/MemMonitorThread.java
@@ -38,9 +38,9 @@ public class MemMonitorThread extends Thread {
*/
public MemMonitorThread(IoTDBConfig config) {
this.setName(ThreadName.MEMORY_MONITOR.getName());
- long confInterval = config.memMonitorInterval;
+ long confInterval = config.getMemMonitorInterval();
this.checkInterval = confInterval > 0 ? confInterval : this.checkInterval;
- if (config.enableSmallFlush) {
+ if (config.isEnableSmallFlush()) {
this.safePolicy = new FlushPartialPolicy();
} else {
this.safePolicy = new NoActPolicy();
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/engine/modification/ModificationFile.java b/iotdb/src/main/java/org/apache/iotdb/db/engine/modification/ModificationFile.java
index 9727b2b..598a0b9 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/engine/modification/ModificationFile.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/engine/modification/ModificationFile.java
@@ -76,7 +76,7 @@ public class ModificationFile {
public void abort() throws IOException {
synchronized (this) {
- if (modifications.size() > 0) {
+ if (!modifications.isEmpty()) {
writer.abort();
modifications.remove(modifications.size() - 1);
}
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/engine/modification/io/LocalTextModificationAccessor.java b/iotdb/src/main/java/org/apache/iotdb/db/engine/modification/io/LocalTextModificationAccessor.java
index 5d2d8fd..9e86400 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/engine/modification/io/LocalTextModificationAccessor.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/engine/modification/io/LocalTextModificationAccessor.java
@@ -61,6 +61,7 @@ public class LocalTextModificationAccessor implements ModificationReader, Modifi
try {
reader = new BufferedReader(new FileReader(filePath));
} catch (FileNotFoundException e) {
+ logger.debug("No modification has been written to this file", e);
return new ArrayList<>();
}
String line;
@@ -68,7 +69,7 @@ public class LocalTextModificationAccessor implements ModificationReader, Modifi
List<Modification> modificationList = new ArrayList<>();
try {
while ((line = reader.readLine()) != null) {
- if (line.equals(ABORT_MARK) && modificationList.size() > 0) {
+ if (line.equals(ABORT_MARK) && !modificationList.isEmpty()) {
modificationList.remove(modificationList.size() - 1);
} else {
modificationList.add(decodeModification(line));
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/engine/overflow/io/OverflowProcessor.java b/iotdb/src/main/java/org/apache/iotdb/db/engine/overflow/io/OverflowProcessor.java
index 4b3d2be..7b9c7bf 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/engine/overflow/io/OverflowProcessor.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/engine/overflow/io/OverflowProcessor.java
@@ -100,7 +100,7 @@ public class OverflowProcessor extends Processor {
super(processorName);
this.fileSchema = fileSchema;
this.versionController = versionController;
- String overflowDirPath = TsFileDBConf.overflowDataDir;
+ String overflowDirPath = TsFileDBConf.getOverflowDataDir();
if (overflowDirPath.length() > 0
&& overflowDirPath.charAt(overflowDirPath.length() - 1) != File.separatorChar) {
overflowDirPath = overflowDirPath + File.separatorChar;
@@ -118,7 +118,7 @@ public class OverflowProcessor extends Processor {
filenodeFlushAction = parameters
.get(FileNodeConstants.FILENODE_PROCESSOR_FLUSH_ACTION);
- if (IoTDBDescriptor.getInstance().getConfig().enableWal) {
+ if (IoTDBDescriptor.getInstance().getConfig().isEnableWal()) {
logNode = MultiFileLogNodeManager.getInstance().getNode(
processorName + IoTDBConstant.OVERFLOW_LOG_NODE_SUFFIX,
getOverflowRestoreFile(),
@@ -438,7 +438,7 @@ public class OverflowProcessor extends Processor {
getProcessorName());
filenodeFlushAction.act();
// write-ahead log
- if (IoTDBDescriptor.getInstance().getConfig().enableWal) {
+ if (IoTDBDescriptor.getInstance().getConfig().isEnableWal()) {
logNode.notifyEndFlush(null);
}
result = true;
@@ -504,7 +504,7 @@ public class OverflowProcessor extends Processor {
throw new IOException(e);
}
- if (IoTDBDescriptor.getInstance().getConfig().enableWal) {
+ if (IoTDBDescriptor.getInstance().getConfig().isEnableWal()) {
try {
logNode.notifyStartFlush();
} catch (IOException e) {
@@ -605,15 +605,15 @@ public class OverflowProcessor extends Processor {
"The overflow processor {}, the size of metadata reaches {},"
+ " the size of file reaches {}.",
getProcessorName(), MemUtils.bytesCntToStr(metaSize), MemUtils.bytesCntToStr(fileSize));
- if (metaSize >= config.overflowMetaSizeThreshold
- || fileSize >= config.overflowFileSizeThreshold) {
+ if (metaSize >= config.getOverflowMetaSizeThreshold()
+ || fileSize >= config.getOverflowFileSizeThreshold()) {
LOGGER.info(
"The overflow processor {}, size({}) of the file {} reaches threshold {},"
+ " size({}) of metadata reaches threshold {}.",
getProcessorName(), MemUtils.bytesCntToStr(fileSize), workResource.getInsertFilePath(),
- MemUtils.bytesCntToStr(config.overflowMetaSizeThreshold),
+ MemUtils.bytesCntToStr(config.getOverflowMetaSizeThreshold()),
MemUtils.bytesCntToStr(metaSize),
- MemUtils.bytesCntToStr(config.overflowMetaSizeThreshold));
+ MemUtils.bytesCntToStr(config.getOverflowMetaSizeThreshold()));
return true;
} else {
return false;
@@ -656,8 +656,7 @@ public class OverflowProcessor extends Processor {
Objects.equals(filenodeFlushAction, that.filenodeFlushAction) &&
Objects.equals(fileSchema, that.fileSchema) &&
Objects.equals(memSize, that.memSize) &&
- Objects.equals(logNode, that.logNode) &&
- Objects.equals(flushFuture, that.flushFuture);
+ Objects.equals(logNode, that.logNode);
}
@Override
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/engine/overflow/io/OverflowResource.java b/iotdb/src/main/java/org/apache/iotdb/db/engine/overflow/io/OverflowResource.java
index adf384d..67916b2 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/engine/overflow/io/OverflowResource.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/engine/overflow/io/OverflowResource.java
@@ -109,8 +109,14 @@ public class OverflowResource {
try(FileInputStream inputStream = new FileInputStream(positionFilePath)) {
byte[] insertPositionData = new byte[8];
byte[] updatePositionData = new byte[8];
- inputStream.read(insertPositionData);
- inputStream.read(updatePositionData);
+ int byteRead = inputStream.read(insertPositionData);
+ if (byteRead != 8) {
+ throw new IOException("Not enough bytes for insertPositionData");
+ }
+ byteRead = inputStream.read(updatePositionData);
+ if (byteRead != 8) {
+ throw new IOException("Not enough bytes for updatePositionData");
+ }
long lastInsertPosition = BytesUtils.bytesToLong(insertPositionData);
long lastUpdatePosition = BytesUtils.bytesToLong(updatePositionData);
return new Pair<>(lastInsertPosition, lastUpdatePosition);
@@ -121,6 +127,7 @@ public class OverflowResource {
if (insertTempFile.exists()) {
left = insertTempFile.length();
}
+ LOGGER.warn("Cannot read position info, returning a default value", e);
return new Pair<>(left, right);
}
}
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/engine/pool/FlushManager.java b/iotdb/src/main/java/org/apache/iotdb/db/engine/pool/FlushManager.java
index 9a1e323..7c996aa 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/engine/pool/FlushManager.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/engine/pool/FlushManager.java
@@ -39,7 +39,7 @@ public class FlushManager {
private FlushManager() {
IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
- this.threadCnt = config.concurrentFlushThread;
+ this.threadCnt = config.getConcurrentFlushThread();
pool = IoTDBThreadPoolFactory.newFixedThreadPool(threadCnt, ThreadName.FLUSH_SERVICE.getName());
}
@@ -56,7 +56,7 @@ public class FlushManager {
throw new ProcessorException("Flush Pool is not terminated!");
}
IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
- pool = Executors.newFixedThreadPool(config.concurrentFlushThread);
+ pool = Executors.newFixedThreadPool(config.getConcurrentFlushThread());
}
public FlushManager(ExecutorService pool) {
@@ -82,8 +82,9 @@ public class FlushManager {
+ EXIT_WAIT_TIME + " ms");
}
} catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
throw new ProcessorException("Interrupted while waiting flush thread pool to exit. "
- + e.getMessage());
+ , e);
}
}
}
@@ -107,8 +108,8 @@ public class FlushManager {
+ EXIT_WAIT_TIME + " ms");
}
} catch (InterruptedException e) {
- throw new ProcessorException("Interrupted while waiting flush thread pool to exit. "
- + e.getMessage());
+ Thread.currentThread().interrupt();
+ throw new ProcessorException("Interrupted while waiting flush thread pool to exit. ", e);
}
}
}
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/engine/pool/MergeManager.java b/iotdb/src/main/java/org/apache/iotdb/db/engine/pool/MergeManager.java
index cd1c36a..75190f2 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/engine/pool/MergeManager.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/engine/pool/MergeManager.java
@@ -36,7 +36,7 @@ public class MergeManager {
private MergeManager() {
IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
- this.threadCnt = config.mergeConcurrentThreads;
+ this.threadCnt = config.getMergeConcurrentThreads();
pool = IoTDBThreadPoolFactory.newFixedThreadPool(threadCnt, ThreadName.MERGE_SERVICE.getName());
}
@@ -54,7 +54,7 @@ public class MergeManager {
throw new ProcessorException("Merge pool is not terminated!");
}
IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
- pool = Executors.newFixedThreadPool(config.mergeConcurrentThreads);
+ pool = Executors.newFixedThreadPool(config.getMergeConcurrentThreads());
}
/**
@@ -74,8 +74,9 @@ public class MergeManager {
"Merge thread pool doesn't exit after " + timeOut + " ms");
}
} catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
throw new ProcessorException(
- "Interrupted while waiting merge thread pool to exit. Because " + e.getMessage());
+ "Interrupted while waiting merge thread pool to exit. ", e);
}
}
}
@@ -97,8 +98,9 @@ public class MergeManager {
"Merge thread pool doesn't exit after " + timeOut + " ms");
}
} catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
throw new ProcessorException(
- "Interrupted while waiting merge thread pool to exit. Because" + e.getMessage());
+ "Interrupted while waiting merge thread pool to exit.", e);
}
}
}
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/engine/version/SimpleFileVersionController.java b/iotdb/src/main/java/org/apache/iotdb/db/engine/version/SimpleFileVersionController.java
index 8cf64d7..c8ba1fb 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/engine/version/SimpleFileVersionController.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/engine/version/SimpleFileVersionController.java
@@ -54,7 +54,7 @@ public class SimpleFileVersionController implements VersionController {
try {
checkPersist();
} catch (IOException e) {
- LOGGER.error(e.getMessage());
+ LOGGER.error("Error occurred when getting next version.", e);
}
return currVersion;
}
@@ -88,7 +88,7 @@ public class SimpleFileVersionController implements VersionController {
private void restore() throws IOException {
File directory = new File(directoryPath);
File[] versionFiles = directory.listFiles((dir, name) -> name.startsWith(FILE_PREFIX));
- File versionFile = null;
+ File versionFile;
if (versionFiles != null && versionFiles.length > 0) {
long maxVersion = 0;
int maxVersionIndex = 0;
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/exception/ProcessorException.java b/iotdb/src/main/java/org/apache/iotdb/db/exception/ProcessorException.java
index 8747205..8250496 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/exception/ProcessorException.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/exception/ProcessorException.java
@@ -40,4 +40,8 @@ public class ProcessorException extends Exception {
public ProcessorException() {
super();
}
+
+ public ProcessorException(String msg, Throwable e) {
+ super(msg, e);
+ }
}
\ No newline at end of file
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/exception/builder/ExceptionBuilder.java b/iotdb/src/main/java/org/apache/iotdb/db/exception/builder/ExceptionBuilder.java
index 1dad8aa..4880688 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/exception/builder/ExceptionBuilder.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/exception/builder/ExceptionBuilder.java
@@ -73,7 +73,7 @@ public class ExceptionBuilder {
* load information.
*/
public void loadInfo() {
- String language = IoTDBDescriptor.getInstance().getConfig().languageVersion.toLowerCase();
+ String language = IoTDBDescriptor.getInstance().getConfig().getLanguageVersion().toLowerCase();
String url = System.getProperty(IoTDBConstant.IOTDB_CONF, null);
if (url == null) {
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 ea7c37f..1788010 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
@@ -31,9 +31,9 @@ import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
import org.apache.iotdb.db.exception.MetadataArgsErrorException;
@@ -45,6 +45,8 @@ import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
import org.apache.iotdb.tsfile.read.common.Path;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
/**
@@ -56,6 +58,7 @@ import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
*/
public class MManager {
+ private static final Logger LOGGER = LoggerFactory.getLogger(MManager.class);
private static final String ROOT_NAME = MetadataConstant.ROOT;
// the lock for read/write
private ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
@@ -69,10 +72,10 @@ public class MManager {
private String metadataDirPath;
private RandomDeleteCache<String, PathCheckRet> checkAndGetDataTypeCache;
- private RandomDeleteCache<String, MNode> mnodecache;
+ private RandomDeleteCache<String, MNode> mNodeCache;
private MManager() {
- metadataDirPath = IoTDBDescriptor.getInstance().getConfig().metadataDir;
+ metadataDirPath = IoTDBDescriptor.getInstance().getConfig().getMetadataDir();
if (metadataDirPath.length() > 0
&& metadataDirPath.charAt(metadataDirPath.length() - 1) != File.separatorChar) {
metadataDirPath = metadataDirPath + File.separatorChar;
@@ -85,7 +88,7 @@ public class MManager {
logFilePath = metadataDirPath + MetadataConstant.METADATA_LOG;
writeToLog = false;
- int cacheSize = IoTDBDescriptor.getInstance().getConfig().mManagerCacheSize;
+ int cacheSize = IoTDBDescriptor.getInstance().getConfig().getmManagerCacheSize();
checkAndGetDataTypeCache = new RandomDeleteCache<String, PathCheckRet>(cacheSize) {
@Override
public void beforeRemove(PathCheckRet object) throws CacheException {
@@ -98,7 +101,7 @@ public class MManager {
}
};
- mnodecache = new RandomDeleteCache<String, MNode>(cacheSize) {
+ mNodeCache = new RandomDeleteCache<String, MNode>(cacheSize) {
@Override
public void beforeRemove(MNode object) throws CacheException {
//allowed to do nothing
@@ -121,46 +124,54 @@ public class MManager {
return MManagerHolder.INSTANCE;
}
+ //Because the writer will be used later and should not be closed here.
+ @SuppressWarnings("squid:S2093")
private void init() {
lock.writeLock().lock();
File dataFile = new File(datafilePath);
File logFile = new File(logFilePath);
try {
- try {
- if (dataFile.exists()) {
- // init the metadata from the serialized file
- FileInputStream fis = new FileInputStream(dataFile);
- ObjectInputStream ois = new ObjectInputStream(fis);
- mgraph = (MGraph) ois.readObject();
- ois.close();
- fis.close();
- dataFile.delete();
- } else {
- // init the metadata from the operation log
- mgraph = new MGraph(ROOT_NAME);
- if (logFile.exists()) {
- FileReader fr = new FileReader(logFile);
- BufferedReader br = new BufferedReader(fr);
- String cmd;
- while ((cmd = br.readLine()) != null) {
- operation(cmd);
- }
- br.close();
- }
- }
- FileWriter fw = new FileWriter(logFile, true);
- logWriter = new BufferedWriter(fw);
- writeToLog = true;
- } catch (Exception e) {
- e.printStackTrace();
- throw new RuntimeException(e);
+ if (dataFile.exists()) {
+ initFromDataFile(dataFile);
+ } else {
+ initFromLog(logFile);
}
+ logWriter = new BufferedWriter(new FileWriter(logFile, true));
+ writeToLog = true;
+ } catch (PathErrorException | MetadataArgsErrorException
+ | ClassNotFoundException | IOException e) {
+ mgraph = new MGraph(ROOT_NAME);
+ LOGGER.error("Cannot read MGraph from file, using an empty new one");
} finally {
lock.writeLock().unlock();
}
}
+ private void initFromDataFile(File dataFile) throws IOException, ClassNotFoundException {
+ // init the metadata from the serialized file
+ try(FileInputStream fis = new FileInputStream(dataFile);
+ ObjectInputStream ois = new ObjectInputStream(fis)) {
+ mgraph = (MGraph) ois.readObject();
+ dataFile.delete();
+ }
+ }
+
+ private void initFromLog(File logFile)
+ throws IOException, PathErrorException, MetadataArgsErrorException {
+ // init the metadata from the operation log
+ mgraph = new MGraph(ROOT_NAME);
+ if (logFile.exists()) {
+ try( FileReader fr = new FileReader(logFile);
+ BufferedReader br = new BufferedReader(fr)) {
+ String cmd;
+ while ((cmd = br.readLine()) != null) {
+ operation(cmd);
+ }
+ }
+ }
+ }
+
/**
* function for clearing mgraph.
*/
@@ -177,43 +188,54 @@ public class MManager {
throws PathErrorException, IOException, MetadataArgsErrorException {
//see addPathToMTree() to get the detailed format of the cmd
String[] args = cmd.trim().split(",");
- if (args[0].equals(MetadataOperationType.ADD_PATH_TO_MTREE)) {
- String[] leftArgs;
- Map<String, String> props = null;
- if (args.length > 5) {
- String[] kv = new String[2];
- props = new HashMap<>(args.length - 5 + 1, 1);
- leftArgs = new String[args.length - 5];
- for (int k = 5; k < args.length; k++) {
- kv = args[k].split("=");
- props.put(kv[0], kv[1]);
+ switch (args[0]) {
+ case MetadataOperationType.ADD_PATH_TO_MTREE:
+ String[] leftArgs;
+ Map<String, String> props = null;
+ if (args.length > 5) {
+ String[] kv = new String[2];
+ props = new HashMap<>(args.length - 5 + 1, 1);
+ leftArgs = new String[args.length - 5];
+ for (int k = 5; k < args.length; k++) {
+ kv = args[k].split("=");
+ props.put(kv[0], kv[1]);
+ }
+ } else {
+ //when ????
+ leftArgs = new String[0];
}
- } else {
- //when ????
- leftArgs = new String[0];
- }
- addPathToMTree(args[1], TSDataType.deserialize(Short.valueOf(args[2])),
- TSEncoding.deserialize(Short.valueOf(args[3])),
- CompressionType.deserialize(Short.valueOf(args[4])),
- props);
- } else if (args[0].equals(MetadataOperationType.DELETE_PATH_FROM_MTREE)) {
- deletePathFromMTree(args[1]);
- } else if (args[0].equals(MetadataOperationType.SET_STORAGE_LEVEL_TO_MTREE)) {
- setStorageLevelToMTree(args[1]);
- } else if (args[0].equals(MetadataOperationType.ADD_A_PTREE)) {
- addAPTree(args[1]);
- } else if (args[0].equals(MetadataOperationType.ADD_A_PATH_TO_PTREE)) {
- addPathToPTree(args[1]);
- } else if (args[0].equals(MetadataOperationType.DELETE_PATH_FROM_PTREE)) {
- deletePathFromPTree(args[1]);
- } else if (args[0].equals(MetadataOperationType.LINK_MNODE_TO_PTREE)) {
- linkMNodeToPTree(args[1], args[2]);
- } else if (args[0].equals(MetadataOperationType.UNLINK_MNODE_FROM_PTREE)) {
- unlinkMNodeFromPTree(args[1], args[2]);
- }
- }
-
- private void initLogStream() {
+ addPathToMTree(args[1], TSDataType.deserialize(Short.valueOf(args[2])),
+ TSEncoding.deserialize(Short.valueOf(args[3])),
+ CompressionType.deserialize(Short.valueOf(args[4])),
+ props);
+ break;
+ case MetadataOperationType.DELETE_PATH_FROM_MTREE:
+ deletePathFromMTree(args[1]);
+ break;
+ case MetadataOperationType.SET_STORAGE_LEVEL_TO_MTREE:
+ setStorageLevelToMTree(args[1]);
+ break;
+ case MetadataOperationType.ADD_A_PTREE:
+ addAPTree(args[1]);
+ break;
+ case MetadataOperationType.ADD_A_PATH_TO_PTREE:
+ addPathToPTree(args[1]);
+ break;
+ case MetadataOperationType.DELETE_PATH_FROM_PTREE:
+ deletePathFromPTree(args[1]);
+ break;
+ case MetadataOperationType.LINK_MNODE_TO_PTREE:
+ linkMNodeToPTree(args[1], args[2]);
+ break;
+ case MetadataOperationType.UNLINK_MNODE_FROM_PTREE:
+ unlinkMNodeFromPTree(args[1], args[2]);
+ break;
+ default:
+ LOGGER.error("Unrecognizable command {}", cmd);
+ }
+ }
+
+ private void initLogStream() throws IOException {
if (logWriter == null) {
File logFile = new File(logFilePath);
File metadataDir = new File(metadataDirPath);
@@ -221,14 +243,8 @@ public class MManager {
metadataDir.mkdirs();
}
FileWriter fileWriter;
- try {
-
- fileWriter = new FileWriter(logFile, true);
- logWriter = new BufferedWriter(fileWriter);
- } catch (IOException e) {
- e.printStackTrace();
- throw new RuntimeException(e);
- }
+ fileWriter = new FileWriter(logFile, true);
+ logWriter = new BufferedWriter(fileWriter);
}
}
@@ -290,7 +306,7 @@ public class MManager {
lock.writeLock().lock();
try {
checkAndGetDataTypeCache.clear();
- mnodecache.clear();
+ mNodeCache.clear();
String dataFileName = mgraph.deletePath(path);
if (writeToLog) {
initLogStream();
@@ -312,7 +328,7 @@ public class MManager {
lock.writeLock().lock();
try {
checkAndGetDataTypeCache.clear();
- mnodecache.clear();
+ mNodeCache.clear();
mgraph.setStorageLevel(path);
if (writeToLog) {
initLogStream();
@@ -423,21 +439,6 @@ public class MManager {
}
/**
- * Extract the deviceId from given seriesPath.
- *
- * @return String represents the deviceId
- */
- public String getDeviceTypeByPath(String path) throws PathErrorException {
-
- lock.readLock().lock();
- try {
- return mgraph.getDeviceTypeByPath(path);
- } finally {
- lock.readLock().unlock();
- }
- }
-
- /**
* Get series type for given seriesPath.
*
* @return TSDataType
@@ -496,6 +497,8 @@ public class MManager {
*
* @return a HashMap contains all distinct device type separated by device Type
*/
+ // future feature
+ @SuppressWarnings("unused")
public Map<String, List<MeasurementSchema>> getSchemaForAllType() throws PathErrorException {
lock.readLock().lock();
@@ -526,7 +529,7 @@ public class MManager {
*
* @return A HashSet instance which stores all storage group info
*/
- public HashSet<String> getAllStorageGroup() throws PathErrorException {
+ public Set<String> getAllStorageGroup() throws PathErrorException {
lock.readLock().lock();
try {
@@ -543,8 +546,7 @@ public class MManager {
* @return a list contains all column schema
*/
@Deprecated
- public ArrayList<MeasurementSchema> getSchemaForOneType(String path) throws PathErrorException {
-
+ public List<MeasurementSchema> getSchemaForOneType(String path) throws PathErrorException {
lock.readLock().lock();
try {
return mgraph.getSchemaForOneType(path);
@@ -554,10 +556,9 @@ public class MManager {
}
/**
- * Get all ColumnSchemas for the filenode seriesPath.
+ * Get all MeasurementSchemas for the filenode seriesPath.
*/
- public ArrayList<MeasurementSchema> getSchemaForFileName(String path) {
-
+ public List<MeasurementSchema> getSchemaForFileName(String path) {
lock.readLock().lock();
try {
return mgraph.getSchemaForOneFileNode(path);
@@ -597,6 +598,8 @@ public class MManager {
*
* @return The total count of storage-level nodes.
*/
+ // future feature
+ @SuppressWarnings("unused")
public int getFileCountForOneType(String path) throws PathErrorException {
lock.readLock().lock();
@@ -619,7 +622,7 @@ public class MManager {
try {
return mgraph.getFileNameByPath(path);
} catch (PathErrorException e) {
- throw new PathErrorException(String.format(e.getMessage()));
+ throw new PathErrorException(e);
} finally {
lock.readLock().unlock();
}
@@ -634,22 +637,7 @@ public class MManager {
try {
return mgraph.getFileNameByPath(node, path);
} catch (PathErrorException e) {
- throw new PathErrorException(String.format(e.getMessage()));
- } finally {
- lock.readLock().unlock();
- }
- }
-
- /**
- * function for getting file name by path with check.
- */
- public String getFileNameByPathWithCheck(MNode node, String path) throws PathErrorException {
-
- lock.readLock().lock();
- try {
- return mgraph.getFileNameByPath(node, path);
- } catch (PathErrorException e) {
- throw new PathErrorException(String.format(e.getMessage()));
+ throw new PathErrorException(e);
} finally {
lock.readLock().unlock();
}
@@ -675,12 +663,8 @@ public class MManager {
lock.readLock().lock();
try {
- HashMap<String, ArrayList<String>> res = getAllPathGroupByFileName(ROOT_NAME);
- List<String> fileNameList = new ArrayList<>();
- for (String fileName : res.keySet()) {
- fileNameList.add(fileName);
- }
- return fileNameList;
+ Map<String, ArrayList<String>> res = getAllPathGroupByFileName(ROOT_NAME);
+ return new ArrayList<>(res.keySet());
} finally {
lock.readLock().unlock();
}
@@ -689,7 +673,7 @@ public class MManager {
/**
* return a HashMap contains all the paths separated by File Name.
*/
- public HashMap<String, ArrayList<String>> getAllPathGroupByFileName(String path)
+ public Map<String, ArrayList<String>> getAllPathGroupByFileName(String path)
throws PathErrorException {
lock.readLock().lock();
try {
@@ -703,12 +687,12 @@ public class MManager {
* Return all paths for given seriesPath if the seriesPath is abstract. Or return the seriesPath
* itself.
*/
- public ArrayList<String> getPaths(String path) throws PathErrorException {
+ public List<String> getPaths(String path) throws PathErrorException {
lock.readLock().lock();
try {
ArrayList<String> res = new ArrayList<>();
- HashMap<String, ArrayList<String>> pathsGroupByFilename = getAllPathGroupByFileName(path);
+ Map<String, ArrayList<String>> pathsGroupByFilename = getAllPathGroupByFileName(path);
for (ArrayList<String> ps : pathsGroupByFilename.values()) {
res.addAll(ps);
}
@@ -786,7 +770,7 @@ public class MManager {
public MNode getNodeByDeviceIdFromCache(String deviceId) throws PathErrorException {
lock.readLock().lock();
try {
- return mnodecache.get(deviceId);
+ return mNodeCache.get(deviceId);
} catch (CacheException e) {
throw new PathErrorException(e);
} finally {
@@ -807,7 +791,7 @@ public class MManager {
}
/**
- * Get ColumnSchema for given seriesPath. Notice: Path must be a complete Path from root to leaf
+ * Get MeasurementSchema for given seriesPath. Notice: Path must be a complete Path from root to leaf
* node.
*/
public MeasurementSchema getSchemaForOnePath(String path) throws PathErrorException {
@@ -913,7 +897,7 @@ public class MManager {
lock.readLock().lock();
try {
- getFileNameByPathWithCheck(node, path);
+ getFileNameByPath(node, path);
return true;
} finally {
lock.readLock().unlock();
@@ -926,21 +910,19 @@ public class MManager {
public void flushObjectToFile() throws IOException {
lock.writeLock().lock();
- try {
- File dataFile = new File(datafilePath);
- // delete old metadata data file
- if (dataFile.exists()) {
- dataFile.delete();
- }
- File metadataDir = new File(metadataDirPath);
- if (!metadataDir.exists()) {
- metadataDir.mkdirs();
- }
- File tempFile = new File(datafilePath + MetadataConstant.METADATA_TEMP);
- FileOutputStream fos = new FileOutputStream(tempFile);
- ObjectOutputStream oos = new ObjectOutputStream(fos);
+ File dataFile = new File(datafilePath);
+ // delete old metadata data file
+ if (dataFile.exists()) {
+ dataFile.delete();
+ }
+ File metadataDir = new File(metadataDirPath);
+ if (!metadataDir.exists()) {
+ metadataDir.mkdirs();
+ }
+ File tempFile = new File(datafilePath + MetadataConstant.METADATA_TEMP);
+ try(FileOutputStream fos = new FileOutputStream(tempFile);
+ ObjectOutputStream oos = new ObjectOutputStream(fos)) {
oos.writeObject(mgraph);
- oos.close();
// close the logFile stream
if (logWriter != null) {
logWriter.close();
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/monitor/StatMonitor.java b/iotdb/src/main/java/org/apache/iotdb/db/monitor/StatMonitor.java
index f1ef62b..fdb4d84 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/monitor/StatMonitor.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/monitor/StatMonitor.java
@@ -75,10 +75,10 @@ public class StatMonitor implements IService {
MManager mmanager = MManager.getInstance();
statisticMap = new HashMap<>();
IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
- statMonitorDetectFreqSec = config.statMonitorDetectFreqSec;
- statMonitorRetainIntervalSec = config.statMonitorRetainIntervalSec;
- backLoopPeriod = config.backLoopPeriodSec;
- if (config.enableStatMonitor) {
+ statMonitorDetectFreqSec = config.getStatMonitorDetectFreqSec();
+ statMonitorRetainIntervalSec = config.getStatMonitorRetainIntervalSec();
+ backLoopPeriod = config.getBackLoopPeriodSec();
+ if (config.isEnableStatMonitor()) {
try {
String prefix = MonitorConstants.STAT_STORAGE_GROUP_PREFIX;
if (!mmanager.pathExist(prefix)) {
@@ -289,7 +289,7 @@ public class StatMonitor implements IService {
@Override
public void start() throws StartupException {
try {
- if (IoTDBDescriptor.getInstance().getConfig().enableStatMonitor) {
+ if (IoTDBDescriptor.getInstance().getConfig().isEnableStatMonitor()) {
activate();
}
} catch (Exception e) {
@@ -302,7 +302,7 @@ public class StatMonitor implements IService {
@Override
public void stop() {
- if (IoTDBDescriptor.getInstance().getConfig().enableStatMonitor) {
+ if (IoTDBDescriptor.getInstance().getConfig().isEnableStatMonitor()) {
close();
}
}
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/postback/conf/PostBackSenderConfig.java b/iotdb/src/main/java/org/apache/iotdb/db/postback/conf/PostBackSenderConfig.java
index aeaf8d3..b0d1894 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/postback/conf/PostBackSenderConfig.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/postback/conf/PostBackSenderConfig.java
@@ -31,13 +31,13 @@ public class PostBackSenderConfig {
private String[] iotdbBufferwriteDirectory = IoTDBDescriptor.getInstance().getConfig()
.getBufferWriteDirs();
private String dataDirectory =
- new File(IoTDBDescriptor.getInstance().getConfig().dataDir).getAbsolutePath()
+ new File(IoTDBDescriptor.getInstance().getConfig().getDataDir()).getAbsolutePath()
+ File.separator;
private String uuidPath;
private String lastFileInfo;
private String[] snapshotPaths;
private String schemaPath =
- new File(IoTDBDescriptor.getInstance().getConfig().metadataDir).getAbsolutePath()
+ new File(IoTDBDescriptor.getInstance().getConfig().getMetadataDir()).getAbsolutePath()
+ File.separator + "mlog.txt";
private String serverIp = "127.0.0.1";
private int serverPort = 5555;
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/postback/receiver/ServerManager.java b/iotdb/src/main/java/org/apache/iotdb/db/postback/receiver/ServerManager.java
index 3a28438..0a82d71 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/postback/receiver/ServerManager.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/postback/receiver/ServerManager.java
@@ -57,18 +57,18 @@ public class ServerManager {
Factory protocolFactory;
TProcessor processor;
TThreadPoolServer.Args poolArgs;
- if (!conf.isPostbackEnable) {
+ if (!conf.isPostbackEnable()) {
return;
}
try {
- if (conf.ipWhiteList == null) {
+ if (conf.getIpWhiteList() == null) {
LOGGER.error(
"IoTDB post back receiver: Postback server failed to start because IP white "
+ "list is null, please set IP white list!");
return;
}
- conf.ipWhiteList = conf.ipWhiteList.replaceAll(" ", "");
- serverTransport = new TServerSocket(conf.postbackServerPort);
+ conf.setIpWhiteList(conf.getIpWhiteList().replaceAll(" ", ""));
+ serverTransport = new TServerSocket(conf.getPostbackServerPort());
protocolFactory = new TBinaryProtocol.Factory();
processor = new ServerService.Processor<>(new ServerServiceImpl());
poolArgs = new TThreadPoolServer.Args(serverTransport);
@@ -88,7 +88,7 @@ public class ServerManager {
* close postback receiver's server.
*/
public void closeServer() {
- if (conf.isPostbackEnable && poolServer != null) {
+ if (conf.isPostbackEnable() && poolServer != null) {
poolServer.stop();
serverTransport.close();
LOGGER.info("Stop postback server.");
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/postback/receiver/ServerServiceImpl.java b/iotdb/src/main/java/org/apache/iotdb/db/postback/receiver/ServerServiceImpl.java
index 1324abd..adac27c 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/postback/receiver/ServerServiceImpl.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/postback/receiver/ServerServiceImpl.java
@@ -81,7 +81,7 @@ public class ServerServiceImpl implements ServerService.Iface {
private IoTDBConfig tsfileDBconfig = IoTDBDescriptor.getInstance().getConfig();
private String postbackPath;
// Absolute seriesPath of IoTDB data directory
- private String dataPath = new File(tsfileDBconfig.dataDir).getAbsolutePath() + File.separator;
+ private String dataPath = new File(tsfileDBconfig.getDataDir()).getAbsolutePath() + File.separator;
// Absolute paths of IoTDB bufferWrite directory
private String[] bufferWritePaths = tsfileDBconfig.getBufferWriteDirs();
private IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
@@ -129,7 +129,7 @@ public class ServerServiceImpl implements ServerService.Iface {
}
}
}
- return PostbackUtils.verifyIPSegment(config.ipWhiteList, ipAddress);
+ return PostbackUtils.verifyIPSegment(config.getIpWhiteList(), ipAddress);
}
/**
@@ -210,7 +210,7 @@ public class ServerServiceImpl implements ServerService.Iface {
if (status == 0) {
Statement statement = null;
try (Connection connection = DriverManager.getConnection("jdbc:iotdb://localhost:" +
- config.rpcPort + "/", IoTDBConstant.ADMIN_NAME, IoTDBConstant.ADMIN_PW)) {
+ config.getRpcPort() + "/", IoTDBConstant.ADMIN_NAME, IoTDBConstant.ADMIN_PW)) {
Class.forName(JDBC_DRIVER_NAME);
statement = connection.createStatement();
@@ -383,7 +383,7 @@ public class ServerServiceImpl implements ServerService.Iface {
Statement statement = null;
TsFileSequenceReader reader = null;
try (Connection connection = DriverManager.getConnection(
- String.format("jdbc:iotdb://localhost:%d/", config.rpcPort), "root",
+ String.format("jdbc:iotdb://localhost:%d/", config.getRpcPort()), "root",
"root")) {
Class.forName(JDBC_DRIVER_NAME);
statement = connection.createStatement();
@@ -479,7 +479,7 @@ public class ServerServiceImpl implements ServerService.Iface {
TsFileSequenceReader reader = null;
Statement statement = null;
try (Connection connection = DriverManager.getConnection(
- String.format("jdbc:iotdb://localhost:%d/", config.rpcPort), "root",
+ String.format("jdbc:iotdb://localhost:%d/", config.getRpcPort()), "root",
"root")) {
Class.forName(JDBC_DRIVER_NAME);
statement = connection.createStatement();
@@ -667,7 +667,7 @@ public class ServerServiceImpl implements ServerService.Iface {
try {
if (!fileNodeManager.appendFileToFileNode(storageGroup, fileNode, path)) {
// it is a file with overflow data
- if (config.update_historical_data_possibility) {
+ if (config.isUpdate_historical_data_possibility()) {
mergeOldData(path);
} else {
List<String> overlapFiles = fileNodeManager.getOverlapFilesFromFileNode(
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/qp/executor/OverflowQPExecutor.java b/iotdb/src/main/java/org/apache/iotdb/db/qp/executor/OverflowQPExecutor.java
index 86a3cc2..061bb47 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/qp/executor/OverflowQPExecutor.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/qp/executor/OverflowQPExecutor.java
@@ -542,13 +542,13 @@ public class OverflowQPExecutor extends QueryProcessExecutor {
Set<String> pathSet = new HashSet<>();
// Attention: Monitor storage group seriesPath is not allowed to be deleted
for (Path p : deletePathList) {
- ArrayList<String> subPaths = mManager.getPaths(p.getFullPath());
+ List<String> subPaths = mManager.getPaths(p.getFullPath());
if (subPaths.isEmpty()) {
throw new ProcessorException(String
.format("There are no timeseries in the prefix of %s seriesPath",
p.getFullPath()));
}
- ArrayList<String> newSubPaths = new ArrayList<>();
+ List<String> newSubPaths = new ArrayList<>();
for (String eachSubPath : subPaths) {
String filenodeName = mManager.getFileNameByPath(eachSubPath);
@@ -565,8 +565,7 @@ public class OverflowQPExecutor extends QueryProcessExecutor {
"Timeseries %s does not exist and cannot be delete its metadata and data", p));
}
}
- List<String> fullPath = new ArrayList<>();
- fullPath.addAll(pathSet);
+ List<String> fullPath = new ArrayList<>(pathSet);
try {
deleteDataOfTimeSeries(fullPath);
} catch (ProcessorException e) {
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/query/control/FileReaderManager.java b/iotdb/src/main/java/org/apache/iotdb/db/query/control/FileReaderManager.java
index ade8029..90e1932 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/query/control/FileReaderManager.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/query/control/FileReaderManager.java
@@ -87,7 +87,7 @@ public class FileReaderManager implements IService {
private void clearUnUsedFilesInFixTime() {
- long examinePeriod = IoTDBDescriptor.getInstance().getConfig().cacheFileReaderClearPeriod;
+ long examinePeriod = IoTDBDescriptor.getInstance().getConfig().getCacheFileReaderClearPeriod();
executorService.scheduleAtFixedRate(() -> {
synchronized (this) {
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/service/CloseMergeService.java b/iotdb/src/main/java/org/apache/iotdb/db/service/CloseMergeService.java
index d5e59c9..0915cd3 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/service/CloseMergeService.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/service/CloseMergeService.java
@@ -40,10 +40,10 @@ public class CloseMergeService implements IService {
private static final Logger LOGGER = LoggerFactory.getLogger(CloseMergeService.class);
private static IoTDBConfig dbConfig = IoTDBDescriptor.getInstance().getConfig();
- private static final long MERGE_DELAY = dbConfig.periodTimeForMerge;
- private static final long CLOSE_DELAY = dbConfig.periodTimeForFlush;
- private static final long MERGE_PERIOD = dbConfig.periodTimeForMerge;
- private static final long CLOSE_PERIOD = dbConfig.periodTimeForFlush;
+ private static final long MERGE_DELAY = dbConfig.getPeriodTimeForMerge();
+ private static final long CLOSE_DELAY = dbConfig.getPeriodTimeForFlush();
+ private static final long MERGE_PERIOD = dbConfig.getPeriodTimeForMerge();
+ private static final long CLOSE_PERIOD = dbConfig.getPeriodTimeForFlush();
private static CloseMergeService closeMergeService = new CloseMergeService();
private Runnable mergeService = new MergeServiceThread();
private Runnable closeService = new CloseServiceThread();
@@ -74,7 +74,7 @@ public class CloseMergeService implements IService {
* start service.
*/
public void startService() {
- if (dbConfig.enableTimingCloseAndMerge) {
+ if (dbConfig.isEnableTimingCloseAndMerge()) {
if (!isStart) {
LOGGER.info("Start the close and merge service");
closeAndMergeDaemon.start();
@@ -93,7 +93,7 @@ public class CloseMergeService implements IService {
* close service.
*/
public void closeService() {
- if (dbConfig.enableTimingCloseAndMerge) {
+ if (dbConfig.isEnableTimingCloseAndMerge()) {
if (isStart) {
LOGGER.info("Prepare to shutdown the close and merge service.");
isStart = false;
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 9ab6e8e..9689166 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,7 +27,6 @@ import org.apache.iotdb.db.conf.IoTDBDescriptor;
import org.apache.iotdb.db.engine.filenode.FileNodeManager;
import org.apache.iotdb.db.engine.memcontrol.BasicMemController;
import org.apache.iotdb.db.exception.FileNodeManagerException;
-import org.apache.iotdb.db.exception.FileNodeProcessorException;
import org.apache.iotdb.db.exception.PathErrorException;
import org.apache.iotdb.db.exception.RecoverException;
import org.apache.iotdb.db.exception.StartupException;
@@ -95,7 +94,7 @@ public class IoTDB implements IoTDBMBean {
// When registering statMonitor, we should start recovering some statistics
// with latest values stored
// Warn: registMonitor() method should be called after systemDataRecovery()
- if (IoTDBDescriptor.getInstance().getConfig().enableStatMonitor) {
+ if (IoTDBDescriptor.getInstance().getConfig().isEnableStatMonitor()) {
StatMonitor.getInstance().recovery();
}
@@ -164,10 +163,10 @@ public class IoTDB implements IoTDBMBean {
}
}
IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
- boolean enableWal = config.enableWal;
- config.enableWal = false;
+ boolean enableWal = config.isEnableWal();
+ config.setEnableWal(false);
writeLogManager.recover();
- config.enableWal = enableWal;
+ config.setEnableWal(enableWal);
}
private static class IoTDBHolder {
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/service/JDBCService.java b/iotdb/src/main/java/org/apache/iotdb/db/service/JDBCService.java
index cb28312..ea78d5d 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/service/JDBCService.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/service/JDBCService.java
@@ -21,7 +21,6 @@ package org.apache.iotdb.db.service;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.locks.ReentrantLock;
import org.apache.iotdb.db.concurrent.IoTDBThreadPoolFactory;
import org.apache.iotdb.db.concurrent.ThreadName;
@@ -91,7 +90,7 @@ public class JDBCService implements JDBCServiceMBean, IService {
@Override
public int getRPCPort() {
IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
- return config.rpcPort;
+ return config.getRpcPort();
}
@Override
@@ -139,8 +138,8 @@ public class JDBCService implements JDBCServiceMBean, IService {
}
LOGGER.info("{}: start {} successfully, listening on ip {} port {}", IoTDBConstant.GLOBAL_DB_NAME,
- this.getID().getName(), IoTDBDescriptor.getInstance().getConfig().rpcAddress,
- IoTDBDescriptor.getInstance().getConfig().rpcPort);
+ this.getID().getName(), IoTDBDescriptor.getInstance().getConfig().getRpcAddress(),
+ IoTDBDescriptor.getInstance().getConfig().getRpcPort());
}
private void reset() {
@@ -200,7 +199,8 @@ public class JDBCService implements JDBCServiceMBean, IService {
public void run() {
try {
IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
- serverTransport = new TServerSocket(new InetSocketAddress(config.rpcAddress, config.rpcPort));
+ serverTransport = new TServerSocket(new InetSocketAddress(config.getRpcAddress(),
+ config.getRpcPort()));
poolArgs = new TThreadPoolServer.Args(serverTransport);
poolArgs.executorService = IoTDBThreadPoolFactory.createJDBCClientThreadPool(poolArgs,
ThreadName.JDBC_CLIENT.getName());
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/service/Monitor.java b/iotdb/src/main/java/org/apache/iotdb/db/service/Monitor.java
index 6e8809b..6348f50 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/service/Monitor.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/service/Monitor.java
@@ -41,7 +41,7 @@ public class Monitor implements MonitorMBean, IService {
@Override
public long getDataSizeInByte() {
try {
- return FileUtils.sizeOfDirectory(new File(config.dataDir));
+ return FileUtils.sizeOfDirectory(new File(config.getDataDir()));
} catch (Exception e) {
LOGGER.error("meet error while trying to get data size.", e);
return -1;
@@ -69,7 +69,7 @@ public class Monitor implements MonitorMBean, IService {
@Override
public String getBaseDirectory() {
try {
- File file = new File(config.dataDir);
+ File file = new File(config.getDataDir());
return file.getAbsolutePath();
} catch (Exception e) {
LOGGER.error("meet error while trying to get base dir.", e);
@@ -79,7 +79,7 @@ public class Monitor implements MonitorMBean, IService {
@Override
public boolean getWriteAheadLogStatus() {
- return config.enableWal;
+ return config.isEnableWal();
}
@Override
@@ -132,12 +132,12 @@ public class Monitor implements MonitorMBean, IService {
@Override
public long getMergePeriodInSecond() {
- return config.periodTimeForMerge;
+ return config.getPeriodTimeForMerge();
}
@Override
public long getClosePeriodInSecond() {
- return config.periodTimeForFlush;
+ return config.getPeriodTimeForFlush();
}
@Override
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java b/iotdb/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
index e1f4ff5..9aa7383 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
@@ -27,6 +27,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.apache.iotdb.db.auth.AuthException;
import org.apache.iotdb.db.auth.AuthorityChecker;
import org.apache.iotdb.db.auth.authorizer.IAuthorizer;
@@ -248,7 +249,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
break;
case "SHOW_STORAGE_GROUP":
try {
- HashSet<String> storageGroups = MManager.getInstance().getAllStorageGroup();
+ Set<String> storageGroups = MManager.getInstance().getAllStorageGroup();
resp.setShowStorageGroups(storageGroups);
} catch (PathErrorException e) {
status = getErrorStatus(String.format("Failed to fetch storage groups' metadata because: %s", e));
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/utils/LoadDataUtils.java b/iotdb/src/main/java/org/apache/iotdb/db/utils/LoadDataUtils.java
index 2fdef09..69a6935 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/utils/LoadDataUtils.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/utils/LoadDataUtils.java
@@ -66,7 +66,7 @@ public class LoadDataUtils {
public LoadDataUtils() {
writeInstanceMap = new HashSet<>();
fileNodeManager = FileNodeManager.getInstance();
- writeInstanceThreshold = conf.writeInstanceThreshold;
+ writeInstanceThreshold = conf.getWriteInstanceThreshold();
}
/**
@@ -206,7 +206,7 @@ public class LoadDataUtils {
this.mmanager = mmanager;
// get measurement schema
try {
- ArrayList<MeasurementSchema> meaSchema = mmanager.getSchemaForOneType(measureType);
+ List<MeasurementSchema> meaSchema = mmanager.getSchemaForOneType(measureType);
fileSchema = FileSchemaUtils.getFileSchemaFromColumnSchema(meaSchema, measureType);
} catch (PathErrorException e) {
logger.error("the seriesPath of input measurement schema meet error!", e);
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 6c07132..32d9b47 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
@@ -255,12 +255,12 @@ public class OpenFileNumUtil {
public enum OpenFileNumStatistics {
TOTAL_OPEN_FILE_NUM(null),
- DATA_OPEN_FILE_NUM(Collections.singletonList(config.dataDir)),
+ DATA_OPEN_FILE_NUM(Collections.singletonList(config.getDataDir())),
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)),
+ OVERFLOW_OPEN_FILE_NUM(Collections.singletonList(config.getOverflowDataDir())),
+ WAL_OPEN_FILE_NUM(Collections.singletonList(config.getWalFolder())),
+ METADATA_OPEN_FILE_NUM(Collections.singletonList(config.getMetadataDir())),
+ DIGEST_OPEN_FILE_NUM(Collections.singletonList(config.getFileNodeDir())),
SOCKET_OPEN_FILE_NUM(null);
// path is a list of directory corresponding to the OpenFileNumStatistics enum element,
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/writelog/io/LogWriter.java b/iotdb/src/main/java/org/apache/iotdb/db/writelog/io/LogWriter.java
index ee28b8e..9e54750 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/writelog/io/LogWriter.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/writelog/io/LogWriter.java
@@ -60,7 +60,7 @@ public class LogWriter implements ILogWriter {
}
buffer.flip();
outputStream.write(buffer);
- if (config.forceWalPeriodInMs == 0) {
+ if (config.getForceWalPeriodInMs() == 0) {
outputStream.force(true);
}
}
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/writelog/manager/MultiFileLogNodeManager.java b/iotdb/src/main/java/org/apache/iotdb/db/writelog/manager/MultiFileLogNodeManager.java
index 63b7438..7fe68de 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/writelog/manager/MultiFileLogNodeManager.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/writelog/manager/MultiFileLogNodeManager.java
@@ -62,7 +62,7 @@ public class MultiFileLogNodeManager implements WriteLogNodeManager, IService {
}
logger.debug("Timed sync finished");
try {
- Thread.sleep(config.flushWalPeriodInMs);
+ Thread.sleep(config.getFlushWalPeriodInMs());
} catch (InterruptedException e) {
logger.info("WAL sync thread exits.");
Thread.currentThread().interrupt();
@@ -87,7 +87,7 @@ public class MultiFileLogNodeManager implements WriteLogNodeManager, IService {
}
logger.debug("Timed force finished");
try {
- Thread.sleep(config.forceWalPeriodInMs);
+ Thread.sleep(config.getForceWalPeriodInMs());
} catch (InterruptedException e) {
logger.info("WAL force thread exits.");
Thread.currentThread().interrupt();
@@ -190,7 +190,7 @@ public class MultiFileLogNodeManager implements WriteLogNodeManager, IService {
}
private String bufferWriteWALPath(String fileNodeName) {
- return config.walFolder + File.separator + fileNodeName
+ return config.getWalFolder() + File.separator + fileNodeName
+ IoTDBConstant.BUFFERWRITE_LOG_NODE_SUFFIX;
}
@@ -201,21 +201,21 @@ public class MultiFileLogNodeManager implements WriteLogNodeManager, IService {
}
private String overflowWALPath(String fileNodeName) {
- return config.walFolder + File.separator + fileNodeName
+ return config.getWalFolder() + File.separator + fileNodeName
+ IoTDBConstant.OVERFLOW_LOG_NODE_SUFFIX;
}
@Override
public void start() throws StartupException {
try {
- if (!config.enableWal) {
+ if (!config.isEnableWal()) {
return;
}
if (!isActivated(syncThread)) {
InstanceHolder.instance.syncThread = new Thread(InstanceHolder.instance.syncTask,
ThreadName.WAL_DAEMON.getName());
InstanceHolder.instance.syncThread.start();
- if (config.forceWalPeriodInMs > 0 && !isActivated(forceThread)) {
+ if (config.getForceWalPeriodInMs() > 0 && !isActivated(forceThread)) {
InstanceHolder.instance.forceThread = new Thread(InstanceHolder.instance.forceTask,
ThreadName.WAL_FORCE_DAEMON.getName());
InstanceHolder.instance.forceThread.start();
@@ -233,7 +233,7 @@ public class MultiFileLogNodeManager implements WriteLogNodeManager, IService {
@Override
public void stop() {
- if (!config.enableWal) {
+ if (!config.isEnableWal()) {
return;
}
close();
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/writelog/node/ExclusiveWriteLogNode.java b/iotdb/src/main/java/org/apache/iotdb/db/writelog/node/ExclusiveWriteLogNode.java
index d197539..2c1fd72 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/writelog/node/ExclusiveWriteLogNode.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/writelog/node/ExclusiveWriteLogNode.java
@@ -61,7 +61,7 @@ public class ExclusiveWriteLogNode implements WriteLogNode, Comparable<Exclusive
private IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
- private List<byte[]> logCache = new ArrayList<>(config.flushWalThreshold);
+ private List<byte[]> logCache = new ArrayList<>(config.getFlushWalThreshold());
private ReadWriteLock lock = new ReentrantReadWriteLock();
@@ -77,7 +77,7 @@ public class ExclusiveWriteLogNode implements WriteLogNode, Comparable<Exclusive
public ExclusiveWriteLogNode(String identifier, String restoreFilePath,
String processorStoreFilePath) {
this.identifier = identifier;
- this.logDirectory = config.walFolder + File.separator + this.identifier;
+ this.logDirectory = config.getWalFolder() + File.separator + this.identifier;
new File(logDirectory).mkdirs();
recoverPerformer = new ExclusiveLogRecoverPerformer(restoreFilePath, processorStoreFilePath,
@@ -99,7 +99,7 @@ public class ExclusiveWriteLogNode implements WriteLogNode, Comparable<Exclusive
byte[] logBytes = PhysicalPlanLogTransfer.operatorToLog(plan);
logCache.add(logBytes);
- if (logCache.size() >= config.flushWalThreshold) {
+ if (logCache.size() >= config.getFlushWalThreshold()) {
sync();
}
} finally {
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/writelog/transfer/PhysicalPlanCodec.java b/iotdb/src/main/java/org/apache/iotdb/db/writelog/transfer/PhysicalPlanCodec.java
index b611a4a..ae98f38 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/writelog/transfer/PhysicalPlanCodec.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/writelog/transfer/PhysicalPlanCodec.java
@@ -75,7 +75,7 @@ public enum PhysicalPlanCodec {
@Override
public byte[] encode(DeletePlan t) {
if (localBuffer.get() == null) {
- localBuffer.set(ByteBuffer.allocate(config.maxLogEntrySize));
+ localBuffer.set(ByteBuffer.allocate(config.getMaxLogEntrySize()));
}
int type = SystemLogOperator.DELETE;
@@ -112,7 +112,7 @@ public enum PhysicalPlanCodec {
public byte[] encode(UpdatePlan updatePlan) {
int type = SystemLogOperator.UPDATE;
if (localBuffer.get() == null) {
- localBuffer.set(ByteBuffer.allocate(config.maxLogEntrySize));
+ localBuffer.set(ByteBuffer.allocate(config.getMaxLogEntrySize()));
}
ByteBuffer buffer = localBuffer.get();
@@ -169,7 +169,7 @@ public enum PhysicalPlanCodec {
public byte[] encode(InsertPlan plan) {
int type = SystemLogOperator.INSERT;
if (localBuffer.get() == null) {
- localBuffer.set(ByteBuffer.allocate(config.maxLogEntrySize));
+ localBuffer.set(ByteBuffer.allocate(config.getMaxLogEntrySize()));
}
ByteBuffer buffer = localBuffer.get();
buffer.clear();
diff --git a/iotdb/src/test/java/org/apache/iotdb/db/engine/PathUtils.java b/iotdb/src/test/java/org/apache/iotdb/db/engine/PathUtils.java
index 2909258..315586b 100644
--- a/iotdb/src/test/java/org/apache/iotdb/db/engine/PathUtils.java
+++ b/iotdb/src/test/java/org/apache/iotdb/db/engine/PathUtils.java
@@ -40,7 +40,7 @@ public class PathUtils {
}
public static File getOverflowWriteDir(String nameSpacePath) {
- String overflowWriteDir = config.overflowDataDir;
+ String overflowWriteDir = config.getOverflowDataDir();
if (overflowWriteDir.length() > 0
&& overflowWriteDir.charAt(overflowWriteDir.length() - 1) != File.separatorChar) {
overflowWriteDir = overflowWriteDir + File.separatorChar;
@@ -51,7 +51,7 @@ public class PathUtils {
}
public static File getFileNodeDir(String nameSpacePath) {
- String filenodeDir = config.fileNodeDir;
+ String filenodeDir = config.getFileNodeDir();
if (filenodeDir.length() > 0
&& filenodeDir.charAt(filenodeDir.length() - 1) != File.separatorChar) {
filenodeDir = filenodeDir + File.separatorChar;
diff --git a/iotdb/src/test/java/org/apache/iotdb/db/engine/memcontrol/BufferwriteFileSizeControlTest.java b/iotdb/src/test/java/org/apache/iotdb/db/engine/memcontrol/BufferwriteFileSizeControlTest.java
index a61fa07..fc307d3 100644
--- a/iotdb/src/test/java/org/apache/iotdb/db/engine/memcontrol/BufferwriteFileSizeControlTest.java
+++ b/iotdb/src/test/java/org/apache/iotdb/db/engine/memcontrol/BufferwriteFileSizeControlTest.java
@@ -103,14 +103,14 @@ public class BufferwriteFileSizeControlTest {
pageCheckSizeThreshold = TsFileConf.pageCheckSizeThreshold;
pageSizeInByte = TsFileConf.pageSizeInByte;
maxStringLength = TsFileConf.maxStringLength;
- fileSizeThreshold = dbConfig.bufferwriteFileSizeThreshold;
- memMonitorInterval = dbConfig.memMonitorInterval;
+ fileSizeThreshold = dbConfig.getBufferwriteFileSizeThreshold();
+ memMonitorInterval = dbConfig.getMemMonitorInterval();
// new value
TsFileConf.groupSizeInByte = 200000;
TsFileConf.pageCheckSizeThreshold = 3;
TsFileConf.pageSizeInByte = 10000;
TsFileConf.maxStringLength = 2;
- dbConfig.bufferwriteFileSizeThreshold = 5 * 1024 * 1024;
+ dbConfig.setBufferwriteFileSizeThreshold(5 * 1024 * 1024);
BasicMemController.getInstance().setCheckInterval(600 * 1000);
// init metadata
MetadataManagerHelper.initMetadata();
@@ -123,7 +123,7 @@ public class BufferwriteFileSizeControlTest {
TsFileConf.pageCheckSizeThreshold = pageCheckSizeThreshold;
TsFileConf.pageSizeInByte = pageSizeInByte;
TsFileConf.maxStringLength = maxStringLength;
- dbConfig.bufferwriteFileSizeThreshold = fileSizeThreshold;
+ dbConfig.setBufferwriteFileSizeThreshold(fileSizeThreshold);
BasicMemController.getInstance().setCheckInterval(memMonitorInterval);
// clean environment
EnvironmentUtils.cleanEnv();
@@ -166,7 +166,7 @@ public class BufferwriteFileSizeControlTest {
e.printStackTrace();
}
processor.close();
- assertTrue(processor.getFileSize() < dbConfig.bufferwriteFileSizeThreshold);
+ assertTrue(processor.getFileSize() < dbConfig.getBufferwriteFileSizeThreshold());
fail("Method unimplemented");
}
}
diff --git a/iotdb/src/test/java/org/apache/iotdb/db/engine/memcontrol/BufferwriteMetaSizeControlTest.java b/iotdb/src/test/java/org/apache/iotdb/db/engine/memcontrol/BufferwriteMetaSizeControlTest.java
index dbacdf4..62ef909 100644
--- a/iotdb/src/test/java/org/apache/iotdb/db/engine/memcontrol/BufferwriteMetaSizeControlTest.java
+++ b/iotdb/src/test/java/org/apache/iotdb/db/engine/memcontrol/BufferwriteMetaSizeControlTest.java
@@ -103,14 +103,14 @@ public class BufferwriteMetaSizeControlTest {
pageCheckSizeThreshold = TsFileConf.pageCheckSizeThreshold;
pageSizeInByte = TsFileConf.pageSizeInByte;
maxStringLength = TsFileConf.maxStringLength;
- metaSizeThreshold = dbConfig.bufferwriteFileSizeThreshold;
- memMonitorInterval = dbConfig.memMonitorInterval;
+ metaSizeThreshold = dbConfig.getBufferwriteFileSizeThreshold();
+ memMonitorInterval = dbConfig.getMemMonitorInterval();
// new value
TsFileConf.groupSizeInByte = 200000;
TsFileConf.pageCheckSizeThreshold = 3;
TsFileConf.pageSizeInByte = 10000;
TsFileConf.maxStringLength = 2;
- dbConfig.bufferwriteMetaSizeThreshold = 1024 * 1024;
+ dbConfig.setBufferwriteMetaSizeThreshold(1024 * 1024);
BasicMemController.getInstance().setCheckInterval(600 * 1000);
// init metadata
MetadataManagerHelper.initMetadata();
@@ -123,7 +123,7 @@ public class BufferwriteMetaSizeControlTest {
TsFileConf.pageCheckSizeThreshold = pageCheckSizeThreshold;
TsFileConf.pageSizeInByte = pageSizeInByte;
TsFileConf.maxStringLength = maxStringLength;
- dbConfig.bufferwriteMetaSizeThreshold = metaSizeThreshold;
+ dbConfig.setBufferwriteMetaSizeThreshold(metaSizeThreshold);
BasicMemController.getInstance().setCheckInterval(memMonitorInterval);
// clean environment
EnvironmentUtils.cleanEnv();
@@ -165,7 +165,7 @@ public class BufferwriteMetaSizeControlTest {
} catch (InterruptedException e) {
e.printStackTrace();
}
- assertTrue(processor.getMetaSize() < dbConfig.bufferwriteFileSizeThreshold);
+ assertTrue(processor.getMetaSize() < dbConfig.getBufferwriteFileSizeThreshold());
processor.close();
fail("Method unimplemented");
diff --git a/iotdb/src/test/java/org/apache/iotdb/db/engine/memcontrol/IoTDBMemControlTest.java b/iotdb/src/test/java/org/apache/iotdb/db/engine/memcontrol/IoTDBMemControlTest.java
index 8e2b8d1..0d39851 100644
--- a/iotdb/src/test/java/org/apache/iotdb/db/engine/memcontrol/IoTDBMemControlTest.java
+++ b/iotdb/src/test/java/org/apache/iotdb/db/engine/memcontrol/IoTDBMemControlTest.java
@@ -82,13 +82,13 @@ public class IoTDBMemControlTest {
if (testFlag) {
deamon = IoTDB.getInstance();
- config.memThresholdWarning = 3 * IoTDBConstant.MB;
- config.memThresholdDangerous = 5 * IoTDBConstant.MB;
+ config.setMemThresholdWarning(3 * IoTDBConstant.MB);
+ config.setMemThresholdDangerous(5 * IoTDBConstant.MB);
BasicMemController.getInstance().setCheckInterval(15 * 1000);
BasicMemController.getInstance()
- .setDangerousThreshold(config.memThresholdDangerous); // force initialize
- BasicMemController.getInstance().setWarningThreshold(config.memThresholdWarning);
+ .setDangerousThreshold(config.getMemThresholdDangerous()); // force initialize
+ BasicMemController.getInstance().setWarningThreshold(config.getMemThresholdWarning());
deamon.active();
EnvironmentUtils.envSetUp();
@@ -143,7 +143,7 @@ public class IoTDBMemControlTest {
"\"sadasgagfdhdshdhdfhdfhdhdhdfherherdfsdfbdfsherhedfjerjerdfshfdshxzcvenerhreherjnfdgntrnt"
+ "ddfhdsf,joreinmoidnfh\"")));
long recordMemSize = MemUtils.getTsRecordMemBufferwrite(record);
- long insertCnt = config.memThresholdDangerous / recordMemSize * 2;
+ long insertCnt = config.getMemThresholdDangerous() / recordMemSize * 2;
System.out.println(Thread.currentThread().getId() + " to insert " + insertCnt);
try {
connection = DriverManager
diff --git a/iotdb/src/test/java/org/apache/iotdb/db/engine/memcontrol/OverflowFileSizeControlTest.java b/iotdb/src/test/java/org/apache/iotdb/db/engine/memcontrol/OverflowFileSizeControlTest.java
index 7d27f26..ddf7a3b 100644
--- a/iotdb/src/test/java/org/apache/iotdb/db/engine/memcontrol/OverflowFileSizeControlTest.java
+++ b/iotdb/src/test/java/org/apache/iotdb/db/engine/memcontrol/OverflowFileSizeControlTest.java
@@ -98,9 +98,9 @@ public class OverflowFileSizeControlTest {
parameters.put(FileNodeConstants.OVERFLOW_FLUSH_ACTION, overflowflushaction);
parameters.put(FileNodeConstants.FILENODE_PROCESSOR_FLUSH_ACTION, filenodeflushaction);
- overflowFileSize = dbConfig.overflowFileSizeThreshold;
+ overflowFileSize = dbConfig.getOverflowFileSizeThreshold();
groupSize = tsconfig.groupSizeInByte;
- dbConfig.overflowFileSizeThreshold = 10 * 1024 * 1024;
+ dbConfig.setOverflowFileSizeThreshold(10 * 1024 * 1024);
tsconfig.groupSizeInByte = 1024 * 1024;
MetadataManagerHelper.initMetadata();
@@ -108,7 +108,7 @@ public class OverflowFileSizeControlTest {
@After
public void tearDown() throws Exception {
- dbConfig.overflowFileSizeThreshold = overflowFileSize;
+ dbConfig.setOverflowFileSizeThreshold(overflowFileSize);
tsconfig.groupSizeInByte = groupSize;
EnvironmentUtils.cleanEnv();
}
@@ -132,7 +132,7 @@ public class OverflowFileSizeControlTest {
// wait to flush
Thread.sleep(1000);
ofprocessor.close();
- assertTrue(ofprocessor.getFileSize() < dbConfig.overflowFileSizeThreshold);
+ assertTrue(ofprocessor.getFileSize() < dbConfig.getOverflowFileSizeThreshold());
fail("Method unimplemented");
} catch (OverflowProcessorException e) {
e.printStackTrace();
diff --git a/iotdb/src/test/java/org/apache/iotdb/db/engine/memcontrol/OverflowMetaSizeControlTest.java b/iotdb/src/test/java/org/apache/iotdb/db/engine/memcontrol/OverflowMetaSizeControlTest.java
index de6a586..2334ee7 100644
--- a/iotdb/src/test/java/org/apache/iotdb/db/engine/memcontrol/OverflowMetaSizeControlTest.java
+++ b/iotdb/src/test/java/org/apache/iotdb/db/engine/memcontrol/OverflowMetaSizeControlTest.java
@@ -98,9 +98,9 @@ public class OverflowMetaSizeControlTest {
parameters.put(FileNodeConstants.OVERFLOW_FLUSH_ACTION, overflowflushaction);
parameters.put(FileNodeConstants.FILENODE_PROCESSOR_FLUSH_ACTION, filenodeflushaction);
- overflowFileSize = dbConfig.overflowMetaSizeThreshold;
+ overflowFileSize = dbConfig.getOverflowMetaSizeThreshold();
groupSize = tsconfig.groupSizeInByte;
- dbConfig.overflowMetaSizeThreshold = 3 * 1024 * 1024;
+ dbConfig.setOverflowMetaSizeThreshold(3 * 1024 * 1024);
tsconfig.groupSizeInByte = 1024 * 1024;
MetadataManagerHelper.initMetadata();
@@ -108,7 +108,7 @@ public class OverflowMetaSizeControlTest {
@After
public void tearDown() throws Exception {
- dbConfig.overflowMetaSizeThreshold = overflowFileSize;
+ dbConfig.setOverflowMetaSizeThreshold(overflowFileSize);
tsconfig.groupSizeInByte = groupSize;
EnvironmentUtils.cleanEnv();
}
@@ -132,7 +132,7 @@ public class OverflowMetaSizeControlTest {
}
// wait to flush
Thread.sleep(1000);
- assertTrue(ofprocessor.getMetaSize() < dbConfig.overflowMetaSizeThreshold);
+ assertTrue(ofprocessor.getMetaSize() < dbConfig.getOverflowMetaSizeThreshold());
ofprocessor.close();
fail("Method unimplemented");
} catch (OverflowProcessorException e) {
diff --git a/iotdb/src/test/java/org/apache/iotdb/db/engine/modification/DeletionFileNodeTest.java b/iotdb/src/test/java/org/apache/iotdb/db/engine/modification/DeletionFileNodeTest.java
index 1a76dd7..35bfc84 100644
--- a/iotdb/src/test/java/org/apache/iotdb/db/engine/modification/DeletionFileNodeTest.java
+++ b/iotdb/src/test/java/org/apache/iotdb/db/engine/modification/DeletionFileNodeTest.java
@@ -229,7 +229,7 @@ public class DeletionFileNodeTest {
new Deletion(processorName + "." + measurements[3], 105, 30),
};
- String fileNodePath = IoTDBDescriptor.getInstance().getConfig().overflowDataDir + File.separator
+ String fileNodePath = IoTDBDescriptor.getInstance().getConfig().getOverflowDataDir() + File.separator
+ processorName + File.separator + "0" + File.separator;
File fileNodeDir = new File(fileNodePath);
File[] modFiles = fileNodeDir.listFiles((dir, name)
diff --git a/iotdb/src/test/java/org/apache/iotdb/db/engine/overflow/io/OverflowProcessorBenchmark.java b/iotdb/src/test/java/org/apache/iotdb/db/engine/overflow/io/OverflowProcessorBenchmark.java
index db95d1d..161c291 100644
--- a/iotdb/src/test/java/org/apache/iotdb/db/engine/overflow/io/OverflowProcessorBenchmark.java
+++ b/iotdb/src/test/java/org/apache/iotdb/db/engine/overflow/io/OverflowProcessorBenchmark.java
@@ -71,11 +71,11 @@ public class OverflowProcessorBenchmark {
}
private static void before() throws IOException {
- FileUtils.deleteDirectory(new File(TsFileDBConf.overflowDataDir));
+ FileUtils.deleteDirectory(new File(TsFileDBConf.getOverflowDataDir()));
}
private static void after() throws IOException {
- FileUtils.deleteDirectory(new File(TsFileDBConf.overflowDataDir));
+ FileUtils.deleteDirectory(new File(TsFileDBConf.getOverflowDataDir()));
}
public static void main(String[] args) throws IOException, OverflowProcessorException {
diff --git a/iotdb/src/test/java/org/apache/iotdb/db/engine/version/SysTimeVersionControllerTest.java b/iotdb/src/test/java/org/apache/iotdb/db/engine/version/SysTimeVersionControllerTest.java
index 4e063ad..1912d8a 100644
--- a/iotdb/src/test/java/org/apache/iotdb/db/engine/version/SysTimeVersionControllerTest.java
+++ b/iotdb/src/test/java/org/apache/iotdb/db/engine/version/SysTimeVersionControllerTest.java
@@ -29,8 +29,9 @@ public class SysTimeVersionControllerTest {
public void test() {
VersionController versionController = SysTimeVersionController.INSTANCE;
long diff = versionController.currVersion() - System.currentTimeMillis();
- assertTrue(diff >= -1 && diff <= 1);
+ // TODO these comparisons can fail in very rare conditions, how to fix?
+ assertTrue(diff >= -2 && diff <= 2);
diff = versionController.nextVersion() - System.currentTimeMillis();
- assertTrue(diff >= -1 && diff <= 1);
+ assertTrue(diff >= -2 && diff <= 2);
}
}
\ No newline at end of file
diff --git a/iotdb/src/test/java/org/apache/iotdb/db/metadata/MManagerAdvancedTest.java b/iotdb/src/test/java/org/apache/iotdb/db/metadata/MManagerAdvancedTest.java
index d5bcb68..2ead48c 100644
--- a/iotdb/src/test/java/org/apache/iotdb/db/metadata/MManagerAdvancedTest.java
+++ b/iotdb/src/test/java/org/apache/iotdb/db/metadata/MManagerAdvancedTest.java
@@ -25,6 +25,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.apache.iotdb.db.exception.MetadataArgsErrorException;
import org.apache.iotdb.db.exception.PathErrorException;
import org.apache.iotdb.db.utils.EnvironmentUtils;
@@ -80,11 +81,11 @@ public class MManagerAdvancedTest {
}
// test filename by seriesPath
assertEquals("root.vehicle.d0", mmanager.getFileNameByPath("root.vehicle.d0.s1"));
- HashMap<String, ArrayList<String>> map = mmanager
+ Map<String, ArrayList<String>> map = mmanager
.getAllPathGroupByFileName("root.vehicle.d1.*");
assertEquals(1, map.keySet().size());
assertEquals(6, map.get("root.vehicle.d1").size());
- ArrayList<String> paths = mmanager.getPaths("root.vehicle.d0");
+ List<String> paths = mmanager.getPaths("root.vehicle.d0");
assertEquals(6, paths.size());
paths = mmanager.getPaths("root.vehicle.d2");
assertEquals(0, paths.size());
diff --git a/iotdb/src/test/java/org/apache/iotdb/db/monitor/MonitorTest.java b/iotdb/src/test/java/org/apache/iotdb/db/monitor/MonitorTest.java
index b198fcb..48fa61a 100644
--- a/iotdb/src/test/java/org/apache/iotdb/db/monitor/MonitorTest.java
+++ b/iotdb/src/test/java/org/apache/iotdb/db/monitor/MonitorTest.java
@@ -52,13 +52,13 @@ public class MonitorTest {
// modify stat parameter
EnvironmentUtils.closeMemControl();
EnvironmentUtils.envSetUp();
- tsdbconfig.enableStatMonitor = true;
- tsdbconfig.backLoopPeriodSec = 1;
+ tsdbconfig.setEnableStatMonitor(true);
+ tsdbconfig.setBackLoopPeriodSec(1);
}
@After
public void tearDown() throws Exception {
- tsdbconfig.enableStatMonitor = false;
+ tsdbconfig.setEnableStatMonitor(false);
statMonitor.close();
EnvironmentUtils.cleanEnv();
}
diff --git a/iotdb/src/test/java/org/apache/iotdb/db/postback/sender/IoTDBSingleClientPostBackTest.java b/iotdb/src/test/java/org/apache/iotdb/db/postback/sender/IoTDBSingleClientPostBackTest.java
index b3f8898..d401369 100644
--- a/iotdb/src/test/java/org/apache/iotdb/db/postback/sender/IoTDBSingleClientPostBackTest.java
+++ b/iotdb/src/test/java/org/apache/iotdb/db/postback/sender/IoTDBSingleClientPostBackTest.java
@@ -181,7 +181,7 @@ public class IoTDBSingleClientPostBackTest {
deamon = IoTDB.getInstance();
deamon.active();
EnvironmentUtils.envSetUp();
- conf.overflowFileSizeThreshold = 0;
+ conf.setOverflowFileSizeThreshold(0);
}
setConfig();
}
diff --git a/iotdb/src/test/java/org/apache/iotdb/db/query/control/FileReaderManagerTest.java b/iotdb/src/test/java/org/apache/iotdb/db/query/control/FileReaderManagerTest.java
index cff2664..fe17a1a 100644
--- a/iotdb/src/test/java/org/apache/iotdb/db/query/control/FileReaderManagerTest.java
+++ b/iotdb/src/test/java/org/apache/iotdb/db/query/control/FileReaderManagerTest.java
@@ -39,13 +39,13 @@ public class FileReaderManagerTest {
@Before
public void setUp() {
- cacheFileReaderClearPeriod = dbConfig.cacheFileReaderClearPeriod;
- dbConfig.cacheFileReaderClearPeriod = 3000;
+ cacheFileReaderClearPeriod = dbConfig.getCacheFileReaderClearPeriod();
+ dbConfig.setCacheFileReaderClearPeriod(3000);
}
@After
public void tearDown() {
- dbConfig.cacheFileReaderClearPeriod = cacheFileReaderClearPeriod;
+ dbConfig.setCacheFileReaderClearPeriod(cacheFileReaderClearPeriod);
}
@Test
diff --git a/iotdb/src/test/java/org/apache/iotdb/db/utils/EnvironmentUtils.java b/iotdb/src/test/java/org/apache/iotdb/db/utils/EnvironmentUtils.java
index 3b0c599..e45fe1f 100644
--- a/iotdb/src/test/java/org/apache/iotdb/db/utils/EnvironmentUtils.java
+++ b/iotdb/src/test/java/org/apache/iotdb/db/utils/EnvironmentUtils.java
@@ -103,17 +103,17 @@ public class EnvironmentUtils {
cleanDir(path);
}
// delete overflow
- cleanDir(config.overflowDataDir);
+ cleanDir(config.getOverflowDataDir());
// delete filenode
- cleanDir(config.fileNodeDir);
+ cleanDir(config.getFileNodeDir());
// delete metadata
- cleanDir(config.metadataDir);
+ cleanDir(config.getMetadataDir());
// delete wal
- cleanDir(config.walFolder);
+ cleanDir(config.getWalFolder());
// delete derby
- cleanDir(config.derbyHome);
+ cleanDir(config.getDerbyHome());
// delete index
- cleanDir(config.indexFileDir);
+ cleanDir(config.getIndexFileDir());
// delte data
cleanDir("data");
// delte derby log
@@ -139,7 +139,7 @@ public class EnvironmentUtils {
* this function should be called before all code in the setup
*/
public static void closeStatMonitor() {
- config.enableStatMonitor = false;
+ config.setEnableStatMonitor(false);
}
/**
@@ -147,14 +147,14 @@ public class EnvironmentUtils {
* this function should be called before all code in the setup
*/
public static void closeMemControl() {
- config.enableMemMonitor = false;
+ config.setEnableMemMonitor(false);
}
public static void envSetUp() throws StartupException {
// disable the memory control
- config.enableMemMonitor = false;
+ config.setEnableMemMonitor(false);
// disable the system monitor
- config.enableStatMonitor = false;
+ config.setEnableStatMonitor(false);
IAuthorizer authorizer = null;
try {
authorizer = LocalFileAuthorizer.getInstance();
diff --git a/iotdb/src/test/java/org/apache/iotdb/db/writelog/PerformanceTest.java b/iotdb/src/test/java/org/apache/iotdb/db/writelog/PerformanceTest.java
index ce0af29..cc101e9 100644
--- a/iotdb/src/test/java/org/apache/iotdb/db/writelog/PerformanceTest.java
+++ b/iotdb/src/test/java/org/apache/iotdb/db/writelog/PerformanceTest.java
@@ -56,15 +56,15 @@ public class PerformanceTest {
@Before
public void setUp() throws Exception {
- enableWal = config.enableWal;
- config.enableWal = true;
+ enableWal = config.isEnableWal();
+ config.setEnableWal(true);
EnvironmentUtils.envSetUp();
}
@After
public void tearDown() throws Exception {
EnvironmentUtils.cleanEnv();
- config.enableWal = enableWal;
+ config.setEnableWal(enableWal);
}
@Test
@@ -75,12 +75,12 @@ public class PerformanceTest {
}
int[] batchSizes = new int[]{100, 500, 1000, 5000, 10000};
long[] forceCycle = new long[]{10, 0};
- int oldBatchSize = config.flushWalThreshold;
- long oldForceCycle = config.forceWalPeriodInMs;
+ int oldBatchSize = config.getFlushWalThreshold();
+ long oldForceCycle = config.getForceWalPeriodInMs();
for (int j = 0; j < batchSizes.length; j++) {
for (int k = 0; k < forceCycle.length; k++) {
- config.flushWalThreshold = batchSizes[j];
- config.forceWalPeriodInMs = forceCycle[k];
+ config.setFlushWalThreshold(batchSizes[j]);
+ config.setForceWalPeriodInMs(forceCycle[k]);
File tempRestore = new File("testtemp", "restore");
File tempProcessorStore = new File("testtemp", "processorStore");
tempRestore.getParentFile().mkdirs();
@@ -106,10 +106,10 @@ public class PerformanceTest {
logNode.write(deletePlan);
}
logNode.forceSync();
- System.out.println("forceWalPeriodInMs = " + config.forceWalPeriodInMs);
+ System.out.println("forceWalPeriodInMs = " + config.getForceWalPeriodInMs());
System.out.println(
3000000 + " logs use " + (System.currentTimeMillis() - time) + " ms at batch size "
- + config.flushWalThreshold);
+ + config.getFlushWalThreshold());
logNode.delete();
tempRestore.delete();
@@ -117,8 +117,8 @@ public class PerformanceTest {
tempRestore.getParentFile().delete();
}
}
- config.flushWalThreshold = oldBatchSize;
- config.forceWalPeriodInMs = oldForceCycle;
+ config.setFlushWalThreshold(oldBatchSize);
+ config.setForceWalPeriodInMs(oldForceCycle);
}
@Test
diff --git a/iotdb/src/test/java/org/apache/iotdb/db/writelog/RecoverTest.java b/iotdb/src/test/java/org/apache/iotdb/db/writelog/RecoverTest.java
index 650f24e..cb9e6c4 100644
--- a/iotdb/src/test/java/org/apache/iotdb/db/writelog/RecoverTest.java
+++ b/iotdb/src/test/java/org/apache/iotdb/db/writelog/RecoverTest.java
@@ -54,15 +54,15 @@ public class RecoverTest {
@Before
public void setUp() throws Exception {
- enableWal = config.enableWal;
- config.enableWal = true;
+ enableWal = config.isEnableWal();
+ config.setEnableWal(true);
EnvironmentUtils.envSetUp();
}
@After
public void tearDown() throws Exception {
EnvironmentUtils.cleanEnv();
- config.enableWal = enableWal;
+ config.setEnableWal(enableWal);
}
@Test
diff --git a/iotdb/src/test/java/org/apache/iotdb/db/writelog/WriteLogNodeManagerTest.java b/iotdb/src/test/java/org/apache/iotdb/db/writelog/WriteLogNodeManagerTest.java
index b6fa93e..3a031ee 100644
--- a/iotdb/src/test/java/org/apache/iotdb/db/writelog/WriteLogNodeManagerTest.java
+++ b/iotdb/src/test/java/org/apache/iotdb/db/writelog/WriteLogNodeManagerTest.java
@@ -51,22 +51,22 @@ public class WriteLogNodeManagerTest {
@Before
public void setUp() throws Exception {
- enableWal = config.enableWal;
- config.enableWal = true;
+ enableWal = config.isEnableWal();
+ config.setEnableWal(true);
EnvironmentUtils.envSetUp();
}
@After
public void tearDown() throws Exception {
EnvironmentUtils.cleanEnv();
- config.enableWal = enableWal;
+ config.setEnableWal(enableWal);
}
@Test
public void testAutoSync() throws IOException, InterruptedException {
// this test check that nodes in a manager will sync periodically.
- int flushWalPeriod = config.flushWalThreshold;
- config.flushWalPeriodInMs = 10000;
+ int flushWalPeriod = config.getFlushWalThreshold();
+ config.setFlushWalPeriodInMs(10000);
File tempRestore = File.createTempFile("managerTest", "restore");
File tempProcessorStore = File.createTempFile("managerTest", "processorStore");
@@ -87,11 +87,11 @@ public class WriteLogNodeManagerTest {
File walFile = new File(logNode.getLogDirectory() + File.separator + "wal");
assertTrue(!walFile.exists());
- Thread.sleep(config.flushWalPeriodInMs + 1000);
+ Thread.sleep(config.getFlushWalPeriodInMs() + 1000);
assertTrue(walFile.exists());
logNode.delete();
- config.flushWalPeriodInMs = flushWalPeriod;
+ config.setFlushWalPeriodInMs(flushWalPeriod);
tempRestore.delete();
tempProcessorStore.delete();
tempRestore.getParentFile().delete();
diff --git a/iotdb/src/test/java/org/apache/iotdb/db/writelog/WriteLogNodeTest.java b/iotdb/src/test/java/org/apache/iotdb/db/writelog/WriteLogNodeTest.java
index 26caf61..6efb056 100644
--- a/iotdb/src/test/java/org/apache/iotdb/db/writelog/WriteLogNodeTest.java
+++ b/iotdb/src/test/java/org/apache/iotdb/db/writelog/WriteLogNodeTest.java
@@ -48,15 +48,15 @@ public class WriteLogNodeTest {
@Before
public void setUp() throws Exception {
- enableWal = config.enableWal;
- config.enableWal = true;
+ enableWal = config.isEnableWal();
+ config.setEnableWal(true);
EnvironmentUtils.envSetUp();
}
@After
public void tearDown() throws Exception {
EnvironmentUtils.cleanEnv();
- config.enableWal = enableWal;
+ config.setEnableWal(enableWal);
}
@Test
@@ -86,7 +86,7 @@ public class WriteLogNodeTest {
logNode.forceSync();
File walFile = new File(
- config.walFolder + File.separator + "root.logTestDevice" + File.separator + "wal");
+ config.getWalFolder() + File.separator + "root.logTestDevice" + File.separator + "wal");
assertTrue(walFile.exists());
RandomAccessFile raf = new RandomAccessFile(walFile, "r");
@@ -160,12 +160,12 @@ public class WriteLogNodeTest {
logNode.forceSync();
File walFile = new File(
- config.walFolder + File.separator + "root.logTestDevice" + File.separator + "wal");
+ config.getWalFolder() + File.separator + "root.logTestDevice" + File.separator + "wal");
assertTrue(walFile.exists());
logNode.notifyStartFlush();
File oldWalFile = new File(
- config.walFolder + File.separator + "root.logTestDevice" + File.separator + "wal-old");
+ config.getWalFolder() + File.separator + "root.logTestDevice" + File.separator + "wal-old");
assertTrue(oldWalFile.exists());
assertTrue(oldWalFile.length() > 0);
@@ -182,8 +182,8 @@ public class WriteLogNodeTest {
@Test
public void testSyncThreshold() throws IOException {
// this test checks that if more logs than threshold are written, a sync will be triggered.
- int flushWalThreshold = config.flushWalThreshold;
- config.flushWalThreshold = 3;
+ int flushWalThreshold = config.getFlushWalThreshold();
+ config.setFlushWalThreshold(3);
File tempRestore = new File("testtemp", "restore");
File tempProcessorStore = new File("testtemp", "processorStore");
tempRestore.getParentFile().mkdirs();
@@ -203,7 +203,7 @@ public class WriteLogNodeTest {
logNode.write(updatePlan);
File walFile = new File(
- config.walFolder + File.separator + "root.logTestDevice" + File.separator + "wal");
+ config.getWalFolder() + File.separator + "root.logTestDevice" + File.separator + "wal");
assertTrue(!walFile.exists());
logNode.write(deletePlan);
@@ -212,7 +212,7 @@ public class WriteLogNodeTest {
logNode.delete();
tempRestore.delete();
tempProcessorStore.delete();
- config.flushWalThreshold = flushWalThreshold;
+ config.setFlushWalThreshold(flushWalThreshold);
tempRestore.getParentFile().delete();
}
@@ -242,7 +242,7 @@ public class WriteLogNodeTest {
logNode.forceSync();
File walFile = new File(
- config.walFolder + File.separator + "root.logTestDevice" + File.separator + "wal");
+ config.getWalFolder() + File.separator + "root.logTestDevice" + File.separator + "wal");
assertTrue(walFile.exists());
assertTrue(new File(logNode.getLogDirectory()).exists());