You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/04/13 09:49:55 UTC
[GitHub] [iotdb] SpriCoder opened a new pull request, #5510: [IOTDB-2899] Feature/set storage group
SpriCoder opened a new pull request, #5510:
URL: https://github.com/apache/iotdb/pull/5510
See more details: https://issues.apache.org/jira/browse/IOTDB-2899
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [iotdb] SpriCoder commented on pull request #5510: [IOTDB-2899] Feature/set storage group
Posted by GitBox <gi...@apache.org>.
SpriCoder commented on PR #5510:
URL: https://github.com/apache/iotdb/pull/5510#issuecomment-1097983819
Thanks for you review. all problem are already fixed. @JackieTien97 PTAL!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [iotdb] JackieTien97 commented on a diff in pull request #5510: [IOTDB-2899] Feature/set storage group
Posted by GitBox <gi...@apache.org>.
JackieTien97 commented on code in PR #5510:
URL: https://github.com/apache/iotdb/pull/5510#discussion_r849362990
##########
server/src/main/java/org/apache/iotdb/db/mpp/sql/analyze/Analyzer.java:
##########
@@ -230,6 +231,16 @@ public Analysis visitAlterTimeseries(
return analysis;
}
+ @Override
+ public Analysis visitSetStorageGroup(
+ SetStorageGroupStatement setStorageGroupStatement, MPPQueryContext context) {
+ Analysis analysis = new Analysis();
+ analysis.setStatement(setStorageGroupStatement);
+
+ // TODO SpriCoder check what to do
+ return analysis;
+ }
+
Review Comment:
You don't need to do analyze here, Config related Statement won't reach here.
##########
server/src/main/java/org/apache/iotdb/db/mpp/execution/config/SetStorageGroupTask.java:
##########
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.mpp.execution.config;
+
+import org.apache.iotdb.common.rpc.thrift.TSStatus;
+import org.apache.iotdb.commons.exception.BadNodeUrlException;
+import org.apache.iotdb.confignode.rpc.thrift.TSetStorageGroupReq;
+import org.apache.iotdb.db.client.ConfigNodeClient;
+import org.apache.iotdb.db.exception.metadata.MetadataException;
+import org.apache.iotdb.db.mpp.sql.statement.Statement;
+import org.apache.iotdb.db.mpp.sql.statement.metadata.SetStorageGroupStatement;
+import org.apache.iotdb.rpc.IoTDBConnectionException;
+import org.apache.iotdb.rpc.TSStatusCode;
+
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SetStorageGroupTask implements IConfigTask {
+ private static final Logger LOGGER = LoggerFactory.getLogger(SetStorageGroupTask.class);
+ private Statement statement;
+
+ public SetStorageGroupTask(Statement statement) {
+ this.statement = statement;
+ }
+
+ @Override
+ public ListenableFuture<Void> execute() throws IoTDBConnectionException, MetadataException {
+ if (!(statement instanceof SetStorageGroupStatement)) {
+ LOGGER.error("SetStorageGroup not get SetStorageGroupStatement");
+ return Futures.immediateVoidFuture();
+ }
+ // Construct request using statement
+ SetStorageGroupStatement setStorageGroupStatement = (SetStorageGroupStatement) statement;
+ TSetStorageGroupReq req =
+ new TSetStorageGroupReq(setStorageGroupStatement.getStorageGroupPath().getFullPath());
+
+ // Send request to some API server
+ ConfigNodeClient configNodeClient = null;
+ try {
+ configNodeClient = new ConfigNodeClient();
+ } catch (IoTDBConnectionException | BadNodeUrlException e) {
+ throw new MetadataException(e.getMessage());
+ }
+
+ // Get response or throw exception
+ TSStatus tsStatus = configNodeClient.setStorageGroup(req);
+ if (TSStatusCode.SUCCESS_STATUS.getStatusCode() != tsStatus.getCode()) {
+ throw new MetadataException("Failed to set storage Group");
+ }
+ // If the action is executed successfully, return the Future.
+ // If your operation is async, you can return the corresponding future directly.
+ return Futures.immediateVoidFuture();
Review Comment:
Avoid throw checked exception out of this scope.
##########
server/src/main/java/org/apache/iotdb/db/mpp/execution/config/SetStorageGroupTask.java:
##########
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.mpp.execution.config;
+
+import org.apache.iotdb.common.rpc.thrift.TSStatus;
+import org.apache.iotdb.commons.exception.BadNodeUrlException;
+import org.apache.iotdb.confignode.rpc.thrift.TSetStorageGroupReq;
+import org.apache.iotdb.db.client.ConfigNodeClient;
+import org.apache.iotdb.db.exception.metadata.MetadataException;
+import org.apache.iotdb.db.mpp.sql.statement.Statement;
+import org.apache.iotdb.db.mpp.sql.statement.metadata.SetStorageGroupStatement;
+import org.apache.iotdb.rpc.IoTDBConnectionException;
+import org.apache.iotdb.rpc.TSStatusCode;
+
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SetStorageGroupTask implements IConfigTask {
+ private static final Logger LOGGER = LoggerFactory.getLogger(SetStorageGroupTask.class);
+ private Statement statement;
+
+ public SetStorageGroupTask(Statement statement) {
+ this.statement = statement;
+ }
+
+ @Override
+ public ListenableFuture<Void> execute() throws IoTDBConnectionException, MetadataException {
+ if (!(statement instanceof SetStorageGroupStatement)) {
+ LOGGER.error("SetStorageGroup not get SetStorageGroupStatement");
+ return Futures.immediateVoidFuture();
+ }
+ // Construct request using statement
+ SetStorageGroupStatement setStorageGroupStatement = (SetStorageGroupStatement) statement;
+ TSetStorageGroupReq req =
+ new TSetStorageGroupReq(setStorageGroupStatement.getStorageGroupPath().getFullPath());
+
+ // Send request to some API server
+ ConfigNodeClient configNodeClient = null;
+ try {
+ configNodeClient = new ConfigNodeClient();
+ } catch (IoTDBConnectionException | BadNodeUrlException e) {
+ throw new MetadataException(e.getMessage());
+ }
+
+ // Get response or throw exception
+ TSStatus tsStatus = configNodeClient.setStorageGroup(req);
+ if (TSStatusCode.SUCCESS_STATUS.getStatusCode() != tsStatus.getCode()) {
+ throw new MetadataException("Failed to set storage Group");
+ }
+ // If the action is executed successfully, return the Future.
+ // If your operation is async, you can return the corresponding future directly.
+ return Futures.immediateVoidFuture();
Review Comment:
```
SettableFuture<Void> future = SettableFuture.create();
try {
// do something you want to do
future.set(null);
} catch (IoTDBConnectionException | BadNodeUrlException e) {
// catch checked exception here.
future.setException(e);
}
return future;
```
##########
server/src/main/java/org/apache/iotdb/db/mpp/execution/config/IConfigTask.java:
##########
@@ -17,10 +17,13 @@
* under the License.
*/
-package org.apache.iotdb.db.mpp.execution;
+package org.apache.iotdb.db.mpp.execution.config;
+
+import org.apache.iotdb.db.exception.metadata.MetadataException;
+import org.apache.iotdb.rpc.IoTDBConnectionException;
import com.google.common.util.concurrent.ListenableFuture;
public interface IConfigTask {
- ListenableFuture<Void> execute();
+ ListenableFuture<Void> execute() throws IoTDBConnectionException, MetadataException;
Review Comment:
You don' have to throw these checked execption here.
##########
server/src/main/java/org/apache/iotdb/db/mpp/sql/parser/ASTVisitor.java:
##########
@@ -1564,6 +1564,11 @@ private String[] parsePrivilege(IoTDBSqlParser.PrivilegesContext ctx) {
return privileges.toArray(new String[0]);
}
+ @Override
+ public Statement visitSetStorageGroup(IoTDBSqlParser.SetStorageGroupContext ctx) {
+ return super.visitSetStorageGroup(ctx);
Review Comment:
You should construct SetStorageGroupStatement here by yourselft. You can refer the implementation in `visitSetStorageGroup` of `IoTDBSqlVisitor`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [iotdb] JackieTien97 commented on a diff in pull request #5510: [IOTDB-2899] Feature/set storage group
Posted by GitBox <gi...@apache.org>.
JackieTien97 commented on code in PR #5510:
URL: https://github.com/apache/iotdb/pull/5510#discussion_r850029644
##########
server/src/main/java/org/apache/iotdb/db/mpp/execution/config/SetStorageGroupTask.java:
##########
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.mpp.execution.config;
+
+import org.apache.iotdb.common.rpc.thrift.TSStatus;
+import org.apache.iotdb.commons.exception.BadNodeUrlException;
+import org.apache.iotdb.confignode.rpc.thrift.TSetStorageGroupReq;
+import org.apache.iotdb.db.client.ConfigNodeClient;
+import org.apache.iotdb.db.exception.metadata.MetadataException;
+import org.apache.iotdb.db.mpp.sql.statement.Statement;
+import org.apache.iotdb.db.mpp.sql.statement.metadata.SetStorageGroupStatement;
+import org.apache.iotdb.rpc.IoTDBConnectionException;
+import org.apache.iotdb.rpc.TSStatusCode;
+
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SetStorageGroupTask implements IConfigTask {
+ private static final Logger LOGGER = LoggerFactory.getLogger(SetStorageGroupTask.class);
+ private Statement statement;
Review Comment:
```suggestion
private final SetStorageGroupStatement statement;
```
##########
server/src/main/java/org/apache/iotdb/db/mpp/execution/config/SetStorageGroupTask.java:
##########
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.mpp.execution.config;
+
+import org.apache.iotdb.common.rpc.thrift.TSStatus;
+import org.apache.iotdb.commons.exception.BadNodeUrlException;
+import org.apache.iotdb.confignode.rpc.thrift.TSetStorageGroupReq;
+import org.apache.iotdb.db.client.ConfigNodeClient;
+import org.apache.iotdb.db.exception.metadata.MetadataException;
+import org.apache.iotdb.db.mpp.sql.statement.Statement;
+import org.apache.iotdb.db.mpp.sql.statement.metadata.SetStorageGroupStatement;
+import org.apache.iotdb.rpc.IoTDBConnectionException;
+import org.apache.iotdb.rpc.TSStatusCode;
+
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SetStorageGroupTask implements IConfigTask {
+ private static final Logger LOGGER = LoggerFactory.getLogger(SetStorageGroupTask.class);
+ private Statement statement;
+
+ public SetStorageGroupTask(Statement statement) {
+ this.statement = statement;
+ }
+
+ @Override
+ public ListenableFuture<Void> execute() {
+ SettableFuture<Void> future = SettableFuture.create();
+ if (!(statement instanceof SetStorageGroupStatement)) {
+ LOGGER.error("SetStorageGroup not get SetStorageGroupStatement");
+ return Futures.immediateVoidFuture();
+ }
Review Comment:
Don't need to do this if judgement here.
##########
server/src/main/java/org/apache/iotdb/db/mpp/execution/config/SetStorageGroupTask.java:
##########
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.mpp.execution.config;
+
+import org.apache.iotdb.common.rpc.thrift.TSStatus;
+import org.apache.iotdb.commons.exception.BadNodeUrlException;
+import org.apache.iotdb.confignode.rpc.thrift.TSetStorageGroupReq;
+import org.apache.iotdb.db.client.ConfigNodeClient;
+import org.apache.iotdb.db.exception.metadata.MetadataException;
+import org.apache.iotdb.db.mpp.sql.statement.Statement;
+import org.apache.iotdb.db.mpp.sql.statement.metadata.SetStorageGroupStatement;
+import org.apache.iotdb.rpc.IoTDBConnectionException;
+import org.apache.iotdb.rpc.TSStatusCode;
+
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SetStorageGroupTask implements IConfigTask {
+ private static final Logger LOGGER = LoggerFactory.getLogger(SetStorageGroupTask.class);
+ private Statement statement;
+
+ public SetStorageGroupTask(Statement statement) {
Review Comment:
```suggestion
public SetStorageGroupTask(SetStorageGroupStatement statement) {
```
##########
server/src/main/java/org/apache/iotdb/db/mpp/execution/config/SetStorageGroupTask.java:
##########
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.mpp.execution.config;
+
+import org.apache.iotdb.common.rpc.thrift.TSStatus;
+import org.apache.iotdb.commons.exception.BadNodeUrlException;
+import org.apache.iotdb.confignode.rpc.thrift.TSetStorageGroupReq;
+import org.apache.iotdb.db.client.ConfigNodeClient;
+import org.apache.iotdb.db.exception.metadata.MetadataException;
+import org.apache.iotdb.db.mpp.sql.statement.Statement;
+import org.apache.iotdb.db.mpp.sql.statement.metadata.SetStorageGroupStatement;
+import org.apache.iotdb.rpc.IoTDBConnectionException;
+import org.apache.iotdb.rpc.TSStatusCode;
+
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SetStorageGroupTask implements IConfigTask {
+ private static final Logger LOGGER = LoggerFactory.getLogger(SetStorageGroupTask.class);
+ private Statement statement;
+
+ public SetStorageGroupTask(Statement statement) {
+ this.statement = statement;
+ }
+
+ @Override
+ public ListenableFuture<Void> execute() {
+ SettableFuture<Void> future = SettableFuture.create();
+ if (!(statement instanceof SetStorageGroupStatement)) {
+ LOGGER.error("SetStorageGroup not get SetStorageGroupStatement");
+ return Futures.immediateVoidFuture();
+ }
Review Comment:
```suggestion
```
##########
server/src/main/java/org/apache/iotdb/db/mpp/execution/config/SetStorageGroupTask.java:
##########
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.mpp.execution.config;
+
+import org.apache.iotdb.common.rpc.thrift.TSStatus;
+import org.apache.iotdb.commons.exception.BadNodeUrlException;
+import org.apache.iotdb.confignode.rpc.thrift.TSetStorageGroupReq;
+import org.apache.iotdb.db.client.ConfigNodeClient;
+import org.apache.iotdb.db.exception.metadata.MetadataException;
+import org.apache.iotdb.db.mpp.sql.statement.Statement;
+import org.apache.iotdb.db.mpp.sql.statement.metadata.SetStorageGroupStatement;
+import org.apache.iotdb.rpc.IoTDBConnectionException;
+import org.apache.iotdb.rpc.TSStatusCode;
+
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SetStorageGroupTask implements IConfigTask {
+ private static final Logger LOGGER = LoggerFactory.getLogger(SetStorageGroupTask.class);
+ private Statement statement;
+
+ public SetStorageGroupTask(Statement statement) {
+ this.statement = statement;
+ }
+
+ @Override
+ public ListenableFuture<Void> execute() {
+ SettableFuture<Void> future = SettableFuture.create();
+ if (!(statement instanceof SetStorageGroupStatement)) {
+ LOGGER.error("SetStorageGroup not get SetStorageGroupStatement");
+ return Futures.immediateVoidFuture();
+ }
+ // Construct request using statement
+ SetStorageGroupStatement setStorageGroupStatement = (SetStorageGroupStatement) statement;
+ TSetStorageGroupReq req =
+ new TSetStorageGroupReq(setStorageGroupStatement.getStorageGroupPath().getFullPath());
+
+ ConfigNodeClient configNodeClient = null;
+ try {
+ configNodeClient = new ConfigNodeClient();
+ // Send request to some API server
+ TSStatus tsStatus = configNodeClient.setStorageGroup(req);
+ // Get response or throw exception
+ if (TSStatusCode.SUCCESS_STATUS.getStatusCode() != tsStatus.getCode()) {
+ LOGGER.error("Failed to connect to config node.");
+ future.setException(new MetadataException("Failed to connect to config node."));
+ }
Review Comment:
```suggestion
} else {
future.set(null);
}
```
##########
server/src/main/java/org/apache/iotdb/db/mpp/execution/config/SetStorageGroupTask.java:
##########
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.mpp.execution.config;
+
+import org.apache.iotdb.common.rpc.thrift.TSStatus;
+import org.apache.iotdb.commons.exception.BadNodeUrlException;
+import org.apache.iotdb.confignode.rpc.thrift.TSetStorageGroupReq;
+import org.apache.iotdb.db.client.ConfigNodeClient;
+import org.apache.iotdb.db.exception.metadata.MetadataException;
+import org.apache.iotdb.db.mpp.sql.statement.Statement;
+import org.apache.iotdb.db.mpp.sql.statement.metadata.SetStorageGroupStatement;
+import org.apache.iotdb.rpc.IoTDBConnectionException;
+import org.apache.iotdb.rpc.TSStatusCode;
+
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SetStorageGroupTask implements IConfigTask {
+ private static final Logger LOGGER = LoggerFactory.getLogger(SetStorageGroupTask.class);
+ private Statement statement;
+
+ public SetStorageGroupTask(Statement statement) {
+ this.statement = statement;
+ }
+
+ @Override
+ public ListenableFuture<Void> execute() {
+ SettableFuture<Void> future = SettableFuture.create();
+ if (!(statement instanceof SetStorageGroupStatement)) {
+ LOGGER.error("SetStorageGroup not get SetStorageGroupStatement");
+ return Futures.immediateVoidFuture();
+ }
+ // Construct request using statement
+ SetStorageGroupStatement setStorageGroupStatement = (SetStorageGroupStatement) statement;
+ TSetStorageGroupReq req =
+ new TSetStorageGroupReq(setStorageGroupStatement.getStorageGroupPath().getFullPath());
+
+ ConfigNodeClient configNodeClient = null;
+ try {
+ configNodeClient = new ConfigNodeClient();
+ // Send request to some API server
+ TSStatus tsStatus = configNodeClient.setStorageGroup(req);
+ // Get response or throw exception
+ if (TSStatusCode.SUCCESS_STATUS.getStatusCode() != tsStatus.getCode()) {
+ LOGGER.error("Failed to connect to config node.");
+ future.setException(new MetadataException("Failed to connect to config node."));
Review Comment:
```suggestion
LOGGER.error("Failed to execute set storage group {} in config node, status is {}.", statement.getStorageGroupPath(), tsStatus);
future.setException(new StatementExecutionException(tsStatus));
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [iotdb] JackieTien97 merged pull request #5510: [IOTDB-2899] Feature/set storage group
Posted by GitBox <gi...@apache.org>.
JackieTien97 merged PR #5510:
URL: https://github.com/apache/iotdb/pull/5510
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org