You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by xi...@apache.org on 2023/04/18 04:42:55 UTC

[iotdb] branch guonengtest_smooth created (now c199636142)

This is an automated email from the ASF dual-hosted git repository.

xingtanzjr pushed a change to branch guonengtest_smooth
in repository https://gitbox.apache.org/repos/asf/iotdb.git


      at c199636142 add write concurrent control

This branch includes the following new commits:

     new c199636142 add write concurrent control

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[iotdb] 01/01: add write concurrent control

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xingtanzjr pushed a commit to branch guonengtest_smooth
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit c19963614246c6a53b8ddda0ff976f2d65166508
Author: Jinrui.Zhang <xi...@gmail.com>
AuthorDate: Tue Apr 18 12:42:33 2023 +0800

    add write concurrent control
---
 example/session/src/main/java/org/apache/iotdb/WriterTest.java | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/example/session/src/main/java/org/apache/iotdb/WriterTest.java b/example/session/src/main/java/org/apache/iotdb/WriterTest.java
index 299b4dd096..1e60ac6f19 100644
--- a/example/session/src/main/java/org/apache/iotdb/WriterTest.java
+++ b/example/session/src/main/java/org/apache/iotdb/WriterTest.java
@@ -30,6 +30,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Random;
 import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 
@@ -78,14 +79,15 @@ public class WriterTest {
     protected volatile boolean needResetLatch = true;
     protected CountDownLatch latch;
     protected long currentTimestamp;
-
+    protected Semaphore semaphore;
     protected int count;
 
     protected SyncWriteSignal(int count) {
       this.count = count;
+      this.semaphore = new Semaphore(20);
     }
 
-    protected void syncCountDownBeforeInsert() {
+    protected void syncCountDownBeforeInsert() throws InterruptedException {
       if (needResetLatch) {
         synchronized (this) {
           if (needResetLatch) {
@@ -95,9 +97,11 @@ public class WriterTest {
           }
         }
       }
+      semaphore.acquire();
     }
 
     protected void finishInsertAndWait(int loopIndex) throws InterruptedException {
+      semaphore.release();
       CountDownLatch currentLatch = latch;
       synchronized (this) {
         currentLatch.countDown();
@@ -127,8 +131,8 @@ public class WriterTest {
     @Override
     public void run() {
       for (int j = 0; j < WRITE_LOOP; j++) {
-        signal.syncCountDownBeforeInsert();
         try {
+          signal.syncCountDownBeforeInsert();
           int insertDeviceCount = insertRecords(index, signal.currentTimestamp);
           totalRowNumber.addAndGet(insertDeviceCount);
           signal.finishInsertAndWait(j);