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

lta pushed a commit to branch Sync-Reconstruct
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git


The following commit(s) were added to refs/heads/Sync-Reconstruct by this push:
     new 32e82c9  fix sonar issues
32e82c9 is described below

commit 32e82c9d9e04fb0b1de68bec2c5ab77a238530c5
Author: lta <[email protected]>
AuthorDate: Wed Mar 20 11:25:04 2019 +0800

    fix sonar issues
---
 .../iotdb/db/sync/sender/FileSenderImpl.java       | 21 +++----------
 .../iotdb/db/sync/sender/FileManagerTest.java      |  2 --
 .../iotdb/db/sync/sender/SingleClientSyncTest.java | 36 ++++++----------------
 .../apache/iotdb/db/sync/test/SyncTestClient1.java |  1 -
 .../apache/iotdb/db/sync/test/SyncTestClient2.java |  1 -
 .../apache/iotdb/db/sync/test/SyncTestClient3.java |  1 -
 6 files changed, 15 insertions(+), 47 deletions(-)

diff --git 
a/iotdb/src/main/java/org/apache/iotdb/db/sync/sender/FileSenderImpl.java 
b/iotdb/src/main/java/org/apache/iotdb/db/sync/sender/FileSenderImpl.java
index a841093..5090fb1 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/sync/sender/FileSenderImpl.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/sync/sender/FileSenderImpl.java
@@ -70,16 +70,6 @@ public class FileSenderImpl implements FileSender {
   private List<String> schema = new ArrayList<>();
 
   /**
-   * Mark the identity of sender
-   **/
-  private String uuid;
-
-  /**
-   * Monitor sync status
-   **/
-  private Thread syncMonitor;
-
-  /**
    * Files that need to be synchronized
    */
   private Map<String, Set<String>> validAllFiles;
@@ -112,10 +102,7 @@ public class FileSenderImpl implements FileSender {
    */
   private final Runnable monitorSyncStatus = () -> {
     Date oldTime = new Date();
-    while (true) {
-      if (Thread.interrupted()) {
-        break;
-      }
+    while (!Thread.interrupted()) {
       Date currentTime = new Date();
       if (currentTime.getTime() / 1000 == oldTime.getTime() / 1000) {
         continue;
@@ -152,10 +139,10 @@ public class FileSenderImpl implements FileSender {
   }
 
   /**
-   * Start Monitor Thread
+   * Start Monitor Thread, monitor sync status
    */
   public void startMonitor() {
-    syncMonitor = new Thread(monitorSyncStatus, 
ThreadName.SYNC_MONITOR.getName());
+    Thread syncMonitor = new Thread(monitorSyncStatus, 
ThreadName.SYNC_MONITOR.getName());
     syncMonitor.setDaemon(true);
     syncMonitor.start();
   }
@@ -294,6 +281,8 @@ public class FileSenderImpl implements FileSender {
   @Override
   public boolean confirmIdentity(String uuidPath) throws 
SyncConnectionException, IOException {
     File file = new File(uuidPath);
+    /** Mark the identity of sender **/
+    String uuid;
     if (!file.getParentFile().exists()) {
       file.getParentFile().mkdirs();
     }
diff --git 
a/iotdb/src/test/java/org/apache/iotdb/db/sync/sender/FileManagerTest.java 
b/iotdb/src/test/java/org/apache/iotdb/db/sync/sender/FileManagerTest.java
index f531726..810481b 100644
--- a/iotdb/src/test/java/org/apache/iotdb/db/sync/sender/FileManagerTest.java
+++ b/iotdb/src/test/java/org/apache/iotdb/db/sync/sender/FileManagerTest.java
@@ -44,7 +44,6 @@ public class FileManagerTest {
 
   @Before
   public void setUp() throws IOException, InterruptedException {
-    Thread.sleep(1000);
     File file = new File(LAST_FILE_INFO_TEST);
     if (!file.getParentFile().exists()) {
       file.getParentFile().mkdirs();
@@ -61,7 +60,6 @@ public class FileManagerTest {
 
   @After
   public void tearDown() throws InterruptedException {
-    Thread.sleep(1000);
     delete(new File(POST_BACK_DIRECTORY_TEST));
     new File(POST_BACK_DIRECTORY_TEST).delete();
   }
diff --git 
a/iotdb/src/test/java/org/apache/iotdb/db/sync/sender/SingleClientSyncTest.java 
b/iotdb/src/test/java/org/apache/iotdb/db/sync/sender/SingleClientSyncTest.java
index c5b8c3a..99870bb 100644
--- 
a/iotdb/src/test/java/org/apache/iotdb/db/sync/sender/SingleClientSyncTest.java
+++ 
b/iotdb/src/test/java/org/apache/iotdb/db/sync/sender/SingleClientSyncTest.java
@@ -194,7 +194,6 @@ public class SingleClientSyncTest {
   public void tearDown() throws Exception {
     if (testFlag) {
       deamon.stop();
-      Thread.sleep(2000);
       EnvironmentUtils.cleanEnv();
     }
     if (success) {
@@ -204,12 +203,11 @@ public class SingleClientSyncTest {
     }
   }
 
-  public void testPostback() throws IOException, SyncConnectionException {
+  public void testPostback() throws IOException, SyncConnectionException, 
ClassNotFoundException, SQLException, InterruptedException {
     if (testFlag) {
       // the first time to sync
       logger.debug("It's the first time to sync!");
       try {
-        Thread.sleep(2000);
         Class.forName(Config.JDBC_DRIVER_NAME);
         try (Connection connection = DriverManager
             .getConnection(Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root",
@@ -219,9 +217,8 @@ public class SingleClientSyncTest {
             statement.execute(sql);
           }
           statement.close();
-          Thread.sleep(100);
         }
-      } catch (InterruptedException | SQLException | ClassNotFoundException e) 
{
+      } catch (SQLException | ClassNotFoundException e) {
         fail(e.getMessage());
       }
 
@@ -230,7 +227,6 @@ public class SingleClientSyncTest {
       // Compare data of sender and receiver
       dataSender.clear();
       try {
-        Thread.sleep(2000);
         Class.forName(Config.JDBC_DRIVER_NAME);
         try (Connection connection = DriverManager
             .getConnection(Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root",
@@ -262,14 +258,13 @@ public class SingleClientSyncTest {
         } catch (Exception e) {
           logger.error("", e);
         }
-      } catch (ClassNotFoundException | InterruptedException e) {
+      } catch (ClassNotFoundException e) {
         fail(e.getMessage());
         Thread.currentThread().interrupt();
       }
 
       dataReceiver.clear();
       try {
-        Thread.sleep(2000);
         Class.forName(Config.JDBC_DRIVER_NAME);
         Connection connection = null;
         try {
@@ -308,7 +303,7 @@ public class SingleClientSyncTest {
             connection.close();
           }
         }
-      } catch (ClassNotFoundException | SQLException | InterruptedException e) 
{
+      } catch (ClassNotFoundException | SQLException e) {
         fail(e.getMessage());
         Thread.currentThread().interrupt();
       }
@@ -324,7 +319,6 @@ public class SingleClientSyncTest {
       // the second time to sync
       logger.debug("It's the second time to sync!");
       try {
-        Thread.sleep(2000);
         Class.forName(Config.JDBC_DRIVER_NAME);
         Connection connection = null;
         try {
@@ -336,7 +330,6 @@ public class SingleClientSyncTest {
             statement.execute(sql);
           }
           statement.close();
-          Thread.sleep(100);
         } catch (Exception e) {
           logger.error("", e);
         } finally {
@@ -344,7 +337,7 @@ public class SingleClientSyncTest {
             connection.close();
           }
         }
-      } catch (ClassNotFoundException | SQLException | InterruptedException e) 
{
+      } catch (ClassNotFoundException | SQLException e) {
         fail(e.getMessage());
         Thread.currentThread().interrupt();
       }
@@ -354,7 +347,6 @@ public class SingleClientSyncTest {
       // Compare data of sender and receiver
       dataSender.clear();
       try {
-        Thread.sleep(2000);
         Class.forName(Config.JDBC_DRIVER_NAME);
         Connection connection = null;
         try {
@@ -392,14 +384,13 @@ public class SingleClientSyncTest {
             connection.close();
           }
         }
-      } catch (ClassNotFoundException | SQLException | InterruptedException e) 
{
+      } catch (ClassNotFoundException | SQLException e) {
         fail(e.getMessage());
         Thread.currentThread().interrupt();
       }
 
       dataReceiver.clear();
-      try {
-        Thread.sleep(2000);
+      {
         Class.forName(Config.JDBC_DRIVER_NAME);
         Connection connection = null;
         try {
@@ -437,9 +428,6 @@ public class SingleClientSyncTest {
             connection.close();
           }
         }
-      } catch (ClassNotFoundException | SQLException | InterruptedException e) 
{
-        fail(e.getMessage());
-        Thread.currentThread().interrupt();
       }
       logger.debug(String.valueOf(dataSender.size()));
       logger.debug(String.valueOf(dataReceiver.size()));
@@ -453,7 +441,6 @@ public class SingleClientSyncTest {
       // the third time to sync
       logger.debug("It's the third time to sync!");
       try {
-        Thread.sleep(2000);
         Class.forName(Config.JDBC_DRIVER_NAME);
         try (Connection connection = DriverManager
             .getConnection(Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root",
@@ -463,11 +450,10 @@ public class SingleClientSyncTest {
             statement.execute(sql);
           }
           statement.close();
-          Thread.sleep(100);
         } catch (Exception e) {
           logger.error("", e);
         }
-      } catch (ClassNotFoundException | InterruptedException e) {
+      } catch (ClassNotFoundException e) {
         fail(e.getMessage());
         Thread.currentThread().interrupt();
       }
@@ -477,7 +463,6 @@ public class SingleClientSyncTest {
       // Compare data of sender and receiver
       dataSender.clear();
       try {
-        Thread.sleep(2000);
         Class.forName(Config.JDBC_DRIVER_NAME);
         try (Connection connection = DriverManager
             .getConnection(String.format("jdbc:iotdb://%s:6667/", 
serverIpTest), "root",
@@ -531,14 +516,13 @@ public class SingleClientSyncTest {
         } catch (Exception e) {
           logger.error("", e);
         }
-      } catch (ClassNotFoundException | InterruptedException e) {
+      } catch (ClassNotFoundException e) {
         fail(e.getMessage());
         Thread.currentThread().interrupt();
       }
 
       dataReceiver.clear();
       try {
-        Thread.sleep(2000);
         Class.forName(Config.JDBC_DRIVER_NAME);
         Connection connection = null;
         try {
@@ -597,7 +581,7 @@ public class SingleClientSyncTest {
             connection.close();
           }
         }
-      } catch (ClassNotFoundException | SQLException | InterruptedException e) 
{
+      } catch (ClassNotFoundException | SQLException e) {
         fail(e.getMessage());
         Thread.currentThread().interrupt();
       }
diff --git 
a/iotdb/src/test/java/org/apache/iotdb/db/sync/test/SyncTestClient1.java 
b/iotdb/src/test/java/org/apache/iotdb/db/sync/test/SyncTestClient1.java
index 4b1f2bf..e7e7b9e 100644
--- a/iotdb/src/test/java/org/apache/iotdb/db/sync/test/SyncTestClient1.java
+++ b/iotdb/src/test/java/org/apache/iotdb/db/sync/test/SyncTestClient1.java
@@ -198,7 +198,6 @@ public class SyncTestClient1 {
           sqlCount = 0;
         }
       }
-      Thread.sleep(TIME_INTERVAL);
 
       if (abnormalFlag == 0) {
         abnormalCount += 1;
diff --git 
a/iotdb/src/test/java/org/apache/iotdb/db/sync/test/SyncTestClient2.java 
b/iotdb/src/test/java/org/apache/iotdb/db/sync/test/SyncTestClient2.java
index b7e6ba0..34e0d42 100644
--- a/iotdb/src/test/java/org/apache/iotdb/db/sync/test/SyncTestClient2.java
+++ b/iotdb/src/test/java/org/apache/iotdb/db/sync/test/SyncTestClient2.java
@@ -202,7 +202,6 @@ public class SyncTestClient2 {
           sqlCount = 0;
         }
       }
-      Thread.sleep(TIME_INTERVAL);
 
       if (abnormalFlag == 0) {
         abnormalCount += 1;
diff --git 
a/iotdb/src/test/java/org/apache/iotdb/db/sync/test/SyncTestClient3.java 
b/iotdb/src/test/java/org/apache/iotdb/db/sync/test/SyncTestClient3.java
index 73f6a9e..e8ca4ac 100644
--- a/iotdb/src/test/java/org/apache/iotdb/db/sync/test/SyncTestClient3.java
+++ b/iotdb/src/test/java/org/apache/iotdb/db/sync/test/SyncTestClient3.java
@@ -212,7 +212,6 @@ public class SyncTestClient3 {
           sqlCount = 0;
         }
       }
-      Thread.sleep(TIME_INTERVAL);
 
       if (abnormalFlag == 0) {
         abnormalCount += 1;

Reply via email to