You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2021/06/05 00:21:13 UTC
[iotdb] branch WaitClearCache updated: wait for clear cache
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch WaitClearCache
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/WaitClearCache by this push:
new 2780ea7 wait for clear cache
2780ea7 is described below
commit 2780ea763bba5a5348694cbc070940c70e9ec9ad
Author: JackieTien97 <Ja...@foxmail.com>
AuthorDate: Sat Jun 5 08:18:07 2021 +0800
wait for clear cache
---
.../iotdb/db/integration/IoTDBClearCacheIT.java | 25 ++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBClearCacheIT.java b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBClearCacheIT.java
index 07754e0..9f37e27 100644
--- a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBClearCacheIT.java
+++ b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBClearCacheIT.java
@@ -20,6 +20,7 @@ package org.apache.iotdb.db.integration;
import org.apache.iotdb.db.engine.cache.ChunkCache;
import org.apache.iotdb.db.engine.cache.TimeSeriesMetadataCache;
+import org.apache.iotdb.db.exception.StorageEngineException;
import org.apache.iotdb.db.utils.EnvironmentUtils;
import org.apache.iotdb.jdbc.Config;
@@ -32,6 +33,7 @@ import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
+import java.util.concurrent.TimeUnit;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -39,7 +41,7 @@ import static org.junit.Assert.fail;
public class IoTDBClearCacheIT {
- private static String[] sqls =
+ private static final String[] sqls =
new String[] {
"set storage group to root.ln",
"create timeseries root.ln.wf01.wt01.status with datatype=BOOLEAN,encoding=PLAIN",
@@ -112,6 +114,9 @@ public class IoTDBClearCacheIT {
"flush"
};
+ // the unit is ns
+ private static final long MAX_WAIT_TIME_FOR_CLEAR_CACHE = 60_000_000_000L;
+
@BeforeClass
public static void setUp() throws Exception {
EnvironmentUtils.closeStatMonitor();
@@ -163,7 +168,7 @@ public class IoTDBClearCacheIT {
statement.execute("CLEAR CACHE");
- assertTrue(ChunkCache.getInstance().isEmpty());
+ assertTrue(waitForClearCacheFinish());
assertTrue(TimeSeriesMetadataCache.getInstance().isEmpty());
} catch (Exception e) {
@@ -171,4 +176,20 @@ public class IoTDBClearCacheIT {
fail(e.getMessage());
}
}
+
+ /** wait until merge is finished */
+ private boolean waitForClearCacheFinish() throws StorageEngineException, InterruptedException {
+
+ long startTime = System.nanoTime();
+ // get the size of level 1's tsfile list to judge whether merge is finished
+ while (!ChunkCache.getInstance().isEmpty()
+ || !TimeSeriesMetadataCache.getInstance().isEmpty()) {
+ TimeUnit.MILLISECONDS.sleep(100);
+ // wait too long, just break
+ if ((System.nanoTime() - startTime) >= MAX_WAIT_TIME_FOR_CLEAR_CACHE) {
+ break;
+ }
+ }
+ return ChunkCache.getInstance().isEmpty() && TimeSeriesMetadataCache.getInstance().isEmpty();
+ }
}