Skip to content

Commit db02437

Browse files
authored
PipePlugin: Optimized the errorCode && Fixed the case-sensitive semantic (#16851)
* fix * fix
1 parent 45f2645 commit db02437

File tree

2 files changed

+69
-4
lines changed

2 files changed

+69
-4
lines changed

integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/treemodel/auto/basic/IoTDBPipeSyntaxIT.java

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.junit.experimental.categories.Category;
3838
import org.junit.runner.RunWith;
3939

40+
import java.io.File;
4041
import java.sql.Connection;
4142
import java.sql.SQLException;
4243
import java.sql.Statement;
@@ -757,4 +758,64 @@ public void testValidPipeWithoutWithSink() {
757758
fail(e.getMessage());
758759
}
759760
}
761+
762+
@Test
763+
public void testPipePluginValidation() {
764+
try (final Connection connection = senderEnv.getConnection();
765+
final Statement statement = connection.createStatement()) {
766+
try {
767+
statement.execute(
768+
"create pipePlugin TestProcessor as 'org.apache.iotdb.db.pipe.example.TestProcessor' USING URI 'xxx'");
769+
fail();
770+
} catch (final SQLException e) {
771+
Assert.assertEquals(
772+
"701: Untrusted uri xxx, current trusted_uri_pattern is file:.*", e.getMessage());
773+
}
774+
try {
775+
statement.execute(
776+
"create pipePlugin TestProcessor as 'org.apache.iotdb.db.pipe.example.TestProcessor' USING URI 'file:.*'");
777+
fail();
778+
} catch (final SQLException e) {
779+
Assert.assertEquals("701: URI is not hierarchical", e.getMessage());
780+
}
781+
try {
782+
statement.execute(
783+
String.format(
784+
"create pipePlugin TestProcessor as 'org.apache.iotdb.db.pipe.example.TestProcessor' USING URI '%s'",
785+
new File(
786+
System.getProperty("user.dir")
787+
+ File.separator
788+
+ "target"
789+
+ File.separator
790+
+ "test-classes"
791+
+ File.separator)
792+
.toURI()
793+
+ "PipePlugin.jar"));
794+
fail();
795+
} catch (final SQLException e) {
796+
Assert.assertEquals(
797+
"1603: Failed to get executable for PipePlugin TestProcessor, please check the URI.",
798+
e.getMessage());
799+
}
800+
try {
801+
statement.execute("drop pipePlugin test_processor");
802+
fail();
803+
} catch (final SQLException e) {
804+
Assert.assertEquals(
805+
"1601: Failed to drop pipe plugin TEST_PROCESSOR. Failures: TEST_PROCESSOR does not exist.",
806+
e.getMessage());
807+
}
808+
try {
809+
statement.execute("drop pipePlugin `Do-Nothing-Sink`");
810+
fail();
811+
} catch (final SQLException e) {
812+
Assert.assertEquals(
813+
"1601: Failed to drop PipePlugin [DO-NOTHING-SINK], the PipePlugin is a built-in PipePlugin",
814+
e.getMessage());
815+
}
816+
} catch (final SQLException e) {
817+
e.printStackTrace();
818+
fail(e.getMessage());
819+
}
820+
}
760821
}

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -994,17 +994,21 @@ public SettableFuture<ConfigTaskResult> createPipePlugin(
994994
// Set md5 of the jar file
995995
jarMd5 = DigestUtils.md5Hex(Files.newInputStream(Paths.get(libRoot)));
996996
}
997-
} catch (final IOException | URISyntaxException e) {
997+
} catch (final URISyntaxException | IllegalArgumentException e) {
998+
future.setException(
999+
new IoTDBException(e.getMessage(), TSStatusCode.SEMANTIC_ERROR.getStatusCode()));
1000+
return future;
1001+
} catch (final IOException e) {
9981002
LOGGER.warn(
9991003
"Failed to get executable for PipePlugin({}) using URI: {}.",
10001004
createPipePluginStatement.getPluginName(),
10011005
createPipePluginStatement.getUriString(),
10021006
e);
10031007
future.setException(
10041008
new IoTDBException(
1005-
"Failed to get executable for PipePlugin"
1009+
"Failed to get executable for PipePlugin "
10061010
+ createPipePluginStatement.getPluginName()
1007-
+ "', please check the URI.",
1011+
+ ", please check the URI.",
10081012
TSStatusCode.PIPE_PLUGIN_DOWNLOAD_ERROR.getStatusCode()));
10091013
return future;
10101014
}
@@ -1093,7 +1097,7 @@ public SettableFuture<ConfigTaskResult> dropPipePlugin(
10931097
final TSStatus executionStatus =
10941098
client.dropPipePlugin(
10951099
new TDropPipePluginReq()
1096-
.setPluginName(dropPipePluginStatement.getPluginName())
1100+
.setPluginName(dropPipePluginStatement.getPluginName().toUpperCase())
10971101
.setIfExistsCondition(dropPipePluginStatement.hasIfExistsCondition())
10981102
.setIsTableModel(dropPipePluginStatement.isTableModel()));
10991103
if (TSStatusCode.SUCCESS_STATUS.getStatusCode() != executionStatus.getCode()) {

0 commit comments

Comments
 (0)