@@ -821,85 +821,89 @@ public SettableFuture<ConfigTaskResult> createPipePlugin(
821821 return future ;
822822 }
823823
824- try (final ConfigNodeClient client =
825- CONFIG_NODE_CLIENT_MANAGER .borrowClient (ConfigNodeInfo .CONFIG_REGION_ID )) {
826- final String libRoot ;
827- final ByteBuffer jarFile ;
828- final String jarMd5 ;
824+ final String libRoot ;
825+ final ByteBuffer jarFile ;
826+ final String jarMd5 ;
829827
830- final String jarFileName = new File (uriString ).getName ();
831- try {
832- final URI uri = new URI (uriString );
833- if (uri .getScheme () == null ) {
834- future .setException (
835- new IoTDBException (
836- "The scheme of URI is not set, please specify the scheme of URI." ,
837- TSStatusCode .PIPE_PLUGIN_DOWNLOAD_ERROR .getStatusCode ()));
838- return future ;
839- }
840- if (!uri .getScheme ().equals ("file" )) {
841- // Download executable
842- final ExecutableResource resource =
843- PipePluginExecutableManager .getInstance ()
844- .request (Collections .singletonList (uriString ));
845- final String jarFilePathUnderTempDir =
846- PipePluginExecutableManager .getInstance ()
847- .getDirStringUnderTempRootByRequestId (resource .getRequestId ())
848- + jarFileName ;
849- // libRoot should be the path of the specified jar
850- libRoot = jarFilePathUnderTempDir ;
851- jarFile = ExecutableManager .transferToBytebuffer (jarFilePathUnderTempDir );
852- jarMd5 = DigestUtils .md5Hex (Files .newInputStream (Paths .get (jarFilePathUnderTempDir )));
853- } else {
854- // libRoot should be the path of the specified jar
855- libRoot = new File (new URI (uriString )).getAbsolutePath ();
856- // If jarPath is a file path on datanode, we transfer it to ByteBuffer and send it to
857- // ConfigNode.
858- jarFile = ExecutableManager .transferToBytebuffer (libRoot );
859- // Set md5 of the jar file
860- jarMd5 = DigestUtils .md5Hex (Files .newInputStream (Paths .get (libRoot )));
861- }
862- } catch (final IOException | URISyntaxException e ) {
863- LOGGER .warn (
864- "Failed to get executable for PipePlugin({}) using URI: {}." ,
865- createPipePluginStatement .getPluginName (),
866- createPipePluginStatement .getUriString (),
867- e );
828+ final String jarFileName = new File (uriString ).getName ();
829+ try {
830+ final URI uri = new URI (uriString );
831+ if (uri .getScheme () == null ) {
868832 future .setException (
869833 new IoTDBException (
870- "Failed to get executable for PipePlugin"
871- + createPipePluginStatement .getPluginName ()
872- + "', please check the URI." ,
834+ "The scheme of URI is not set, please specify the scheme of URI." ,
873835 TSStatusCode .PIPE_PLUGIN_DOWNLOAD_ERROR .getStatusCode ()));
874836 return future ;
875837 }
838+ if (!uri .getScheme ().equals ("file" )) {
839+ // Download executable
840+ final ExecutableResource resource =
841+ PipePluginExecutableManager .getInstance ().request (Collections .singletonList (uriString ));
842+ final String jarFilePathUnderTempDir =
843+ PipePluginExecutableManager .getInstance ()
844+ .getDirStringUnderTempRootByRequestId (resource .getRequestId ())
845+ + jarFileName ;
846+ // libRoot should be the path of the specified jar
847+ libRoot = jarFilePathUnderTempDir ;
848+ jarFile = ExecutableManager .transferToBytebuffer (jarFilePathUnderTempDir );
849+ jarMd5 = DigestUtils .md5Hex (Files .newInputStream (Paths .get (jarFilePathUnderTempDir )));
850+ } else {
851+ // libRoot should be the path of the specified jar
852+ libRoot = new File (new URI (uriString )).getAbsolutePath ();
853+ // If jarPath is a file path on datanode, we transfer it to ByteBuffer and send it to
854+ // ConfigNode.
855+ jarFile = ExecutableManager .transferToBytebuffer (libRoot );
856+ // Set md5 of the jar file
857+ jarMd5 = DigestUtils .md5Hex (Files .newInputStream (Paths .get (libRoot )));
858+ }
859+ } catch (final URISyntaxException | IllegalArgumentException e ) {
860+ future .setException (
861+ new IoTDBException (e .getMessage (), TSStatusCode .SEMANTIC_ERROR .getStatusCode ()));
862+ return future ;
863+ } catch (final IOException e ) {
864+ LOGGER .warn (
865+ "Failed to get executable for PipePlugin({}) using URI: {}." ,
866+ createPipePluginStatement .getPluginName (),
867+ createPipePluginStatement .getUriString (),
868+ e );
869+ future .setException (
870+ new IoTDBException (
871+ "Failed to get executable for PipePlugin "
872+ + createPipePluginStatement .getPluginName ()
873+ + ", please check the URI." ,
874+ TSStatusCode .PIPE_PLUGIN_DOWNLOAD_ERROR .getStatusCode ()));
875+ return future ;
876+ }
876877
877- // try to create instance, this request will fail if creation is not successful
878- try (final PipePluginClassLoader classLoader = new PipePluginClassLoader (libRoot )) {
879- // ensure that jar file contains the class and the class is a pipe plugin
880- final Class <?> clazz =
881- Class .forName (createPipePluginStatement .getClassName (), true , classLoader );
882- final PipePlugin ignored = (PipePlugin ) clazz .getDeclaredConstructor ().newInstance ();
883- } catch (final ClassNotFoundException
884- | NoSuchMethodException
885- | InstantiationException
886- | IllegalAccessException
887- | InvocationTargetException
888- | ClassCastException e ) {
889- LOGGER .warn (
890- "Failed to create function when try to create PipePlugin({}) instance first." ,
891- createPipePluginStatement .getPluginName (),
892- e );
893- future .setException (
894- new IoTDBException (
895- "Failed to load class '"
896- + createPipePluginStatement .getClassName ()
897- + "', because it's not found in jar file or is invalid: "
898- + createPipePluginStatement .getUriString (),
899- TSStatusCode .PIPE_PLUGIN_LOAD_CLASS_ERROR .getStatusCode ()));
900- return future ;
901- }
878+ // try to create instance, this request will fail if creation is not successful
879+ try (final PipePluginClassLoader classLoader = new PipePluginClassLoader (libRoot )) {
880+ // ensure that jar file contains the class and the class is a pipe plugin
881+ final Class <?> clazz =
882+ Class .forName (createPipePluginStatement .getClassName (), true , classLoader );
883+ final PipePlugin ignored = (PipePlugin ) clazz .getDeclaredConstructor ().newInstance ();
884+ } catch (final ClassNotFoundException
885+ | NoSuchMethodException
886+ | InstantiationException
887+ | IllegalAccessException
888+ | InvocationTargetException
889+ | ClassCastException
890+ | IOException e ) {
891+ LOGGER .warn (
892+ "Failed to create pipePlugin when try to create PipePlugin({}) instance first." ,
893+ createPipePluginStatement .getPluginName (),
894+ e );
895+ future .setException (
896+ new IoTDBException (
897+ "Failed to load class '"
898+ + createPipePluginStatement .getClassName ()
899+ + "', because it's not found in jar file or is invalid: "
900+ + createPipePluginStatement .getUriString (),
901+ TSStatusCode .PIPE_PLUGIN_LOAD_CLASS_ERROR .getStatusCode ()));
902+ return future ;
903+ }
902904
905+ try (final ConfigNodeClient client =
906+ CONFIG_NODE_CLIENT_MANAGER .borrowClient (ConfigNodeInfo .CONFIG_REGION_ID )) {
903907 final TSStatus executionStatus =
904908 client .createPipePlugin (
905909 new TCreatePipePluginReq ()
@@ -924,7 +928,7 @@ public SettableFuture<ConfigTaskResult> createPipePlugin(
924928 } else {
925929 future .set (new ConfigTaskResult (TSStatusCode .SUCCESS_STATUS ));
926930 }
927- } catch (final ClientManagerException | TException | IOException e ) {
931+ } catch (final ClientManagerException | TException e ) {
928932 future .setException (e );
929933 }
930934 return future ;
@@ -939,7 +943,7 @@ public SettableFuture<ConfigTaskResult> dropPipePlugin(
939943 final TSStatus executionStatus =
940944 client .dropPipePlugin (
941945 new TDropPipePluginReq ()
942- .setPluginName (dropPipePluginStatement .getPluginName ())
946+ .setPluginName (dropPipePluginStatement .getPluginName (). toUpperCase () )
943947 .setIfExistsCondition (dropPipePluginStatement .hasIfExistsCondition ()));
944948 if (TSStatusCode .SUCCESS_STATUS .getStatusCode () != executionStatus .getCode ()) {
945949 LOGGER .warn (
0 commit comments