You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by lt...@apache.org on 2019/05/14 01:41:42 UTC
[incubator-iotdb] branch cluster updated: fix sonar issues
This is an automated email from the ASF dual-hosted git repository.
lta pushed a commit to branch cluster
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
The following commit(s) were added to refs/heads/cluster by this push:
new 77a9bd3 fix sonar issues
77a9bd3 is described below
commit 77a9bd3f6ac44e8044a156abd035ee0a1bbc45f3
Author: lta <li...@163.com>
AuthorDate: Tue May 14 09:41:25 2019 +0800
fix sonar issues
---
.../org/apache/iotdb/cluster/entity/Server.java | 1 -
.../cluster/qp/executor/AbstractQPExecutor.java | 8 ++++----
.../cluster/qp/executor/QueryMetadataExecutor.java | 13 ++++++------
.../ClusterRpcSingleQueryManager.java | 2 +-
.../cluster/query/utils/ClusterRpcReaderUtils.java | 1 -
.../query/utils/QueryPlanPartitionUtils.java | 10 +++++-----
.../querydata/InitSeriesReaderSyncProcessor.java | 1 -
.../cluster/service/TSServiceClusterImpl.java | 4 +---
.../iotdb/cluster/utils/QPExecutorUtils.java | 12 ++++++-----
.../cluster/qp/executor/NonQueryExecutorTest.java | 23 ++++++++++++----------
10 files changed, 38 insertions(+), 37 deletions(-)
diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/entity/Server.java b/cluster/src/main/java/org/apache/iotdb/cluster/entity/Server.java
index 7343ad1..842d2ed 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/entity/Server.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/entity/Server.java
@@ -138,7 +138,6 @@ public class Server {
registerManager.register(ClusterMonitor.INSTANCE);
} catch (StartupException e) {
stop();
- return;
}
}
diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/qp/executor/AbstractQPExecutor.java b/cluster/src/main/java/org/apache/iotdb/cluster/qp/executor/AbstractQPExecutor.java
index 492b7ad..1f0648c 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/qp/executor/AbstractQPExecutor.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/qp/executor/AbstractQPExecutor.java
@@ -95,7 +95,7 @@ public abstract class AbstractQPExecutor {
int taskRetryNum)
throws InterruptedException, RaftConnectionException {
asyncSendNonQuerySingleTask(task, leader, taskRetryNum);
- return syncGetNonQueryRes(task, leader, taskRetryNum);
+ return syncGetNonQueryRes(task, taskRetryNum);
}
/**
@@ -119,13 +119,13 @@ public abstract class AbstractQPExecutor {
* Synchronous get task response. If it's redirected or status is exception, the task needs to be
* resent. Note: If status is Exception, it marks that an exception occurred during the task is
* being sent instead of executed.
- * @param task rpc task
- * @param leader leader node of the group
+ * @param task rpc task
* @param taskRetryNum Retry time of the task
*/
- private BasicResponse syncGetNonQueryRes(SingleQPTask task, PeerId leader, int taskRetryNum)
+ private BasicResponse syncGetNonQueryRes(SingleQPTask task, int taskRetryNum)
throws InterruptedException, RaftConnectionException {
task.await();
+ PeerId leader;
if (task.getTaskState() != TaskState.FINISH) {
if (task.getTaskState() == TaskState.REDIRECT) {
/** redirect to the right leader **/
diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/qp/executor/QueryMetadataExecutor.java b/cluster/src/main/java/org/apache/iotdb/cluster/qp/executor/QueryMetadataExecutor.java
index ea88fcd..60117aa 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/qp/executor/QueryMetadataExecutor.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/qp/executor/QueryMetadataExecutor.java
@@ -63,6 +63,7 @@ public class QueryMetadataExecutor extends AbstractQPExecutor {
private static final Logger LOGGER = LoggerFactory.getLogger(QueryMetadataExecutor.class);
private static final String DOUB_SEPARATOR = "\\.";
private static final char SINGLE_SEPARATOR = '.';
+ private static final String RAFT_CONNECTION_ERROR = "Raft connection occurs error.";
public QueryMetadataExecutor() {
super();
@@ -140,7 +141,7 @@ public class QueryMetadataExecutor extends AbstractQPExecutor {
try {
res.addAll(queryTimeSeries(task, holder));
} catch (RaftConnectionException e) {
- throw new ProcessorException("Raft connection occurs error.", e);
+ throw new ProcessorException(RAFT_CONNECTION_ERROR, e);
}
}
@@ -168,7 +169,7 @@ public class QueryMetadataExecutor extends AbstractQPExecutor {
try {
asyncSendNonQuerySingleTask(task, holder, 0);
} catch (RaftConnectionException e) {
- throw new ProcessorException("Raft connection occurs error.", e);
+ throw new ProcessorException(RAFT_CONNECTION_ERROR, e);
}
}
for (int i = 0; i < taskList.size(); i++) {
@@ -184,7 +185,7 @@ public class QueryMetadataExecutor extends AbstractQPExecutor {
}
public Metadata processMetadataQuery()
- throws InterruptedException, ProcessorException, PathErrorException {
+ throws InterruptedException, ProcessorException {
Set<String> groupIdSet = router.getAllGroupId();
Metadata[] metadatas = new Metadata[groupIdSet.size()];
@@ -207,7 +208,7 @@ public class QueryMetadataExecutor extends AbstractQPExecutor {
try {
asyncSendNonQuerySingleTask(task, holder, 0);
} catch (RaftConnectionException e) {
- throw new ProcessorException("Raft connection occurs error.", e);
+ throw new ProcessorException(RAFT_CONNECTION_ERROR, e);
}
}
for (int i = 0; i < taskList.size(); i++) {
@@ -250,7 +251,7 @@ public class QueryMetadataExecutor extends AbstractQPExecutor {
try {
dataType = querySeriesType(task, holder);
} catch (RaftConnectionException e) {
- throw new ProcessorException("Raft connection occurs error.", e);
+ throw new ProcessorException(RAFT_CONNECTION_ERROR, e);
}
}
return dataType;
@@ -299,7 +300,7 @@ public class QueryMetadataExecutor extends AbstractQPExecutor {
try {
res.addAll(queryPaths(task, holder));
} catch (RaftConnectionException e) {
- throw new ProcessorException("Raft connection occurs error.", e);
+ throw new ProcessorException(RAFT_CONNECTION_ERROR, e);
}
}
diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/query/manager/coordinatornode/ClusterRpcSingleQueryManager.java b/cluster/src/main/java/org/apache/iotdb/cluster/query/manager/coordinatornode/ClusterRpcSingleQueryManager.java
index d9a5859..faeda22 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/query/manager/coordinatornode/ClusterRpcSingleQueryManager.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/query/manager/coordinatornode/ClusterRpcSingleQueryManager.java
@@ -134,7 +134,7 @@ public class ClusterRpcSingleQueryManager implements IClusterRpcSingleQueryManag
* group
*/
private void initSeriesReader(int readDataConsistencyLevel)
- throws IOException, RaftConnectionException {
+ throws RaftConnectionException {
// Init all series with data group of select series,if filter series has the same data group, init them together.
for (Entry<String, QueryPlan> entry : selectPathPlans.entrySet()) {
String groupId = entry.getKey();
diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/query/utils/ClusterRpcReaderUtils.java b/cluster/src/main/java/org/apache/iotdb/cluster/query/utils/ClusterRpcReaderUtils.java
index cfa3c89..424ba95 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/query/utils/ClusterRpcReaderUtils.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/query/utils/ClusterRpcReaderUtils.java
@@ -19,7 +19,6 @@
package org.apache.iotdb.cluster.query.utils;
import com.alipay.sofa.jraft.entity.PeerId;
-import java.io.IOException;
import java.util.List;
import java.util.Map;
import org.apache.iotdb.cluster.config.ClusterDescriptor;
diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/query/utils/QueryPlanPartitionUtils.java b/cluster/src/main/java/org/apache/iotdb/cluster/query/utils/QueryPlanPartitionUtils.java
index 4f7a5fe..be762e1 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/query/utils/QueryPlanPartitionUtils.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/query/utils/QueryPlanPartitionUtils.java
@@ -25,7 +25,6 @@ import java.util.Map.Entry;
import org.apache.iotdb.cluster.query.manager.coordinatornode.ClusterRpcSingleQueryManager;
import org.apache.iotdb.cluster.query.manager.coordinatornode.FilterGroupEntity;
import org.apache.iotdb.cluster.utils.QPExecutorUtils;
-import org.apache.iotdb.cluster.utils.hash.Router;
import org.apache.iotdb.db.exception.PathErrorException;
import org.apache.iotdb.db.qp.physical.crud.AggregationPlan;
import org.apache.iotdb.db.qp.physical.crud.GroupByPlan;
@@ -33,7 +32,6 @@ import org.apache.iotdb.db.qp.physical.crud.QueryPlan;
import org.apache.iotdb.tsfile.read.common.Path;
import org.apache.iotdb.tsfile.read.expression.ExpressionType;
import org.apache.iotdb.tsfile.read.expression.IExpression;
-import org.apache.iotdb.tsfile.read.filter.basic.Filter;
/**
* Utils for splitting query plan to several sub query plans by group id.
@@ -47,7 +45,8 @@ public class QueryPlanPartitionUtils {
/**
* Split query plan with no filter or with only global time filter by group id
*/
- public static void splitQueryPlanWithoutValueFilter(ClusterRpcSingleQueryManager singleQueryManager)
+ public static void splitQueryPlanWithoutValueFilter(
+ ClusterRpcSingleQueryManager singleQueryManager)
throws PathErrorException {
splitQueryPlanBySelectPath(singleQueryManager);
}
@@ -108,10 +107,11 @@ public class QueryPlanPartitionUtils {
ClusterRpcSingleQueryManager singleQueryManager) throws PathErrorException {
splitQueryPlanBySelectPath(singleQueryManager);
// split query plan by filter path
- Map<String, FilterGroupEntity> filterGroupEntityMap = singleQueryManager.getFilterGroupEntityMap();
+ Map<String, FilterGroupEntity> filterGroupEntityMap = singleQueryManager
+ .getFilterGroupEntityMap();
IExpression expression = queryPlan.getExpression();
ExpressionUtils.getAllExpressionSeries(expression, filterGroupEntityMap);
- for(FilterGroupEntity filterGroupEntity: filterGroupEntityMap.values()){
+ for (FilterGroupEntity filterGroupEntity : filterGroupEntityMap.values()) {
List<Path> filterSeriesList = filterGroupEntity.getFilterPaths();
// create filter sub query plan
QueryPlan subQueryPlan = new QueryPlan();
diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/rpc/raft/processor/querydata/InitSeriesReaderSyncProcessor.java b/cluster/src/main/java/org/apache/iotdb/cluster/rpc/raft/processor/querydata/InitSeriesReaderSyncProcessor.java
index 894d9eb..7474eec 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/rpc/raft/processor/querydata/InitSeriesReaderSyncProcessor.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/rpc/raft/processor/querydata/InitSeriesReaderSyncProcessor.java
@@ -24,7 +24,6 @@ import org.apache.iotdb.cluster.config.ClusterConstant;
import org.apache.iotdb.cluster.query.manager.querynode.ClusterLocalQueryManager;
import org.apache.iotdb.cluster.rpc.raft.processor.BasicSyncUserProcessor;
import org.apache.iotdb.cluster.rpc.raft.request.querydata.InitSeriesReaderRequest;
-import org.apache.iotdb.cluster.rpc.raft.response.querydata.InitSeriesReaderResponse;
import org.apache.iotdb.cluster.utils.QPExecutorUtils;
import org.apache.iotdb.cluster.utils.RaftUtils;
import org.apache.iotdb.db.exception.ProcessorException;
diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/service/TSServiceClusterImpl.java b/cluster/src/main/java/org/apache/iotdb/cluster/service/TSServiceClusterImpl.java
index e658468..ff716a3 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/service/TSServiceClusterImpl.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/service/TSServiceClusterImpl.java
@@ -266,11 +266,9 @@ public class TSServiceClusterImpl extends TSServiceImpl {
return nonQueryExecutor.processNonQuery(plan);
}
- /**
- * It's unnecessary to do this check. It has benn checked in transforming query physical plan.
- */
@Override
protected void checkFileLevelSet(List<Path> paths) throws PathErrorException {
+ //It's unnecessary to do this check. It has benn checked in transforming query physical plan.
}
@Override
diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/utils/QPExecutorUtils.java b/cluster/src/main/java/org/apache/iotdb/cluster/utils/QPExecutorUtils.java
index 809a01c..5a60351 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/utils/QPExecutorUtils.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/utils/QPExecutorUtils.java
@@ -45,10 +45,13 @@ public class QPExecutorUtils {
private static final PhysicalNode localNode = new PhysicalNode(CLUSTER_CONFIG.getIp(),
CLUSTER_CONFIG.getPort());
- private static final MManager mManager = MManager.getInstance();
+ private static final MManager mManager = MManager.getInstance();
private static final Server server = Server.getInstance();
+ private QPExecutorUtils() {
+ }
+
/**
* Get Storage Group Name by device name
*/
@@ -102,9 +105,9 @@ public class QPExecutorUtils {
*/
public static boolean canHandleNonQueryByGroupId(String groupId) {
boolean canHandle = false;
- if(groupId.equals(ClusterConfig.METADATA_GROUP_ID)){
+ if (groupId.equals(ClusterConfig.METADATA_GROUP_ID)) {
canHandle = ((MetadataRaftHolder) (server.getMetadataHolder())).getFsm().isLeader();
- }else {
+ } else {
if (checkDataGroupLeader(groupId)) {
canHandle = true;
}
@@ -141,8 +144,7 @@ public class QPExecutorUtils {
*/
public static String getGroupIdByDevice(String device) throws PathErrorException {
String storageGroup = QPExecutorUtils.getStroageGroupByDevice(device);
- String groupId = Router.getInstance().getGroupIdBySG(storageGroup);
- return groupId;
+ return Router.getInstance().getGroupIdBySG(storageGroup);
}
/**
diff --git a/cluster/src/test/java/org/apache/iotdb/cluster/qp/executor/NonQueryExecutorTest.java b/cluster/src/test/java/org/apache/iotdb/cluster/qp/executor/NonQueryExecutorTest.java
index 038505f..686cac9 100644
--- a/cluster/src/test/java/org/apache/iotdb/cluster/qp/executor/NonQueryExecutorTest.java
+++ b/cluster/src/test/java/org/apache/iotdb/cluster/qp/executor/NonQueryExecutorTest.java
@@ -96,22 +96,25 @@ public class NonQueryExecutorTest {
}
@Test
- public void getStorageGroupFromDeletePlan() throws Exception{
+ public void getStorageGroupFromDeletePlan() throws Exception {
String deleteStatement = "DELETE FROM root.vehicle.device.sensor,root.device0.sensor1 WHERE time <= 5000";
PhysicalPlan plan = processor.parseSQLToPhysicalPlan(deleteStatement);
try {
executor.getStorageGroupFromDeletePlan((DeletePlan) plan);
- } catch (Exception e){
- assertEquals("org.apache.iotdb.db.exception.PathErrorException: The prefix of the seriesPath root.device0.sensor1 is not one storage group seriesPath", e.getMessage());
+ } catch (Exception e) {
+ assertEquals(
+ "org.apache.iotdb.db.exception.PathErrorException: The prefix of the seriesPath root.device0.sensor1 is not one storage group seriesPath",
+ e.getMessage());
}
deleteStatement = "DELETE FROM root.vehicle.device.sensor,root.vehicle1.device0.sensor1 WHERE time <= 5000";
plan = processor.parseSQLToPhysicalPlan(deleteStatement);
try {
executor.getStorageGroupFromDeletePlan((DeletePlan) plan);
- } catch (Exception e){
- assertEquals("Delete function in distributed iotdb only supports single storage group", e.getMessage());
+ } catch (Exception e) {
+ assertEquals("Delete function in distributed iotdb only supports single storage group",
+ e.getMessage());
}
deleteStatement = "DELETE FROM root.vehicle.device1.sensor1, root.vehicle.device2.sensor2 WHERE time <= 5000";
@@ -119,13 +122,13 @@ public class NonQueryExecutorTest {
String storageGroup = executor.getStorageGroupFromDeletePlan((DeletePlan) plan);
assertEquals("root.vehicle", storageGroup);
-
deleteStatement = "DELETE FROM root WHERE time <= 5000";
plan = processor.parseSQLToPhysicalPlan(deleteStatement);
try {
executor.getStorageGroupFromDeletePlan((DeletePlan) plan);
- } catch (Exception e){
- assertEquals("Delete function in distributed iotdb only supports single storage group", e.getMessage());
+ } catch (Exception e) {
+ assertEquals("Delete function in distributed iotdb only supports single storage group",
+ e.getMessage());
}
deleteStatement = "DELETE FROM root.vehicle1.device0.sensor1, root.vehicle1.vehicle3.sensor2 WHERE time <= 5000";
@@ -136,12 +139,12 @@ public class NonQueryExecutorTest {
}
@Test
- public void getGroupIdFromMetadataPlan() throws Exception{
+ public void getGroupIdFromMetadataPlan() throws Exception {
String setSG = "set storage group to root.vehicle2";
PhysicalPlan plan = processor.parseSQLToPhysicalPlan(setSG);
String groupId = executor.getGroupIdFromMetadataPlan((MetadataPlan) plan);
- assertEquals(groupId, ClusterConfig.METADATA_GROUP_ID);
+ assertEquals(ClusterConfig.METADATA_GROUP_ID, groupId);
}
}
\ No newline at end of file