{"id":990,"date":"2022-08-18T18:08:05","date_gmt":"2022-08-18T10:08:05","guid":{"rendered":"https:\/\/blog.frost-s.com\/?p=990"},"modified":"2022-08-19T09:30:13","modified_gmt":"2022-08-19T01:30:13","slug":"flink-%e6%ba%90%e7%a0%81%e8%b5%b0%e8%af%bb%e4%b8%80","status":"publish","type":"post","link":"https:\/\/blog.frost-s.com\/index.php\/2022\/08\/18\/flink-%e6%ba%90%e7%a0%81%e8%b5%b0%e8%af%bb%e4%b8%80\/","title":{"rendered":"Flink \u6e90\u7801\u8d70\u8bfb(\u4e00)"},"content":{"rendered":"\n<p>\u5b9e\u4f8b\u4ee5<a href=\"https:\/\/so.csdn.net\/so\/search?q=yarn&amp;spm=1001.2101.3001.7020\" target=\"_blank\" rel=\"noreferrer noopener\">yarn<\/a>-per-job\u4e3a\u4f8b\u3002<\/p>\n\n\n\n<p>flink\u63d0\u4ea4\u4f5c\u4e1a\u662f\u901a\u8fc7flink run\u8fdb\u884c\u63d0\u4ea4\u7684\uff0c\u53ef\u4ee5\u4ece\u63d0\u4ea4\u811a\u672c\u4e2d\u770b\u5230\u542f\u52a8\u7c7b\u5373\u7a0b\u5e8f\u7684\u5165\u53e3\u662f\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>org.apache.flink.client.cli.CliFrontend<\/code><\/pre>\n\n\n\n<p>\u5b9a\u4f4d\u5230\u6e90\u7801\u4e2dmain\u51fd\u6570\uff0c\u67e5\u770b\u6267\u884c\u903b\u8f91<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em>\/** Submits the job based on the arguments. *\/\npublic static void <\/em>main(<em>final <\/em>String&#91;] args) {\n    EnvironmentInformation.<em>logEnvironmentInfo<\/em>(LOG, \"Command Line Client\", args);\n\n    <em>\/\/ 1. find the configuration directory\n    final <\/em>String configurationDirectory = <em>getConfigurationDirectoryFromEnv<\/em>();\n\n    <em>\/\/ 2. load the global configuration\n    final <\/em>Configuration configuration =\n            GlobalConfiguration.<em>loadConfiguration<\/em>(configurationDirectory);\n\n    <em>\/\/ 3. load the custom command lines\n    final List<\/em>&lt;<em>CustomCommandLine<\/em>> customCommandLines =\n            <em>loadCustomCommandLines<\/em>(configuration, configurationDirectory);\n\n    <em>int <\/em>retCode = 31;\n    <em>try <\/em>{\n        <em>final <\/em>CliFrontend cli = <em>new <\/em>CliFrontend(configuration, customCommandLines);\n\n        SecurityUtils.<em>install<\/em>(<em>new <\/em>SecurityConfiguration(cli.configuration));\n        retCode = SecurityUtils.<em>getInstalledContext<\/em>().runSecured(() -> cli.parseAndRun(args));\n    } <em>catch <\/em>(Throwable t) {\n        <em>final <\/em>Throwable strippedThrowable =\n                ExceptionUtils.<em>stripException<\/em>(t, UndeclaredThrowableException.<em>class<\/em>);\n        LOG.error(\"Fatal error while running command line interface.\", strippedThrowable);\n        strippedThrowable.printStackTrace();\n    } <em>finally <\/em>{\n        System.<em>exit<\/em>(retCode);\n    }\n}<\/code><\/pre>\n\n\n\n<p>\u8fdb\u5165parseAndRun \u65b9\u6cd5\uff0c\u5f00\u59cb\u5230\u771f\u6b63\u6267\u884c\u8fc7\u7a0b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public int parseAndRun(String&#91;] args) {\n\n        \/\/ check for action\n        if (args.length &lt; 1) {\n            CliFrontendParser.printHelp(customCommandLines);\n            System.out.println(\"Please specify an action.\");\n            return 1;\n        }\n\n        \/\/ get action\n        String action = args&#91;0];\n\n        \/\/ remove action from parameters\n        final String&#91;] params = Arrays.copyOfRange(args, 1, args.length);\n\n        try {\n            \/\/ do action\n            switch (action) {\n                case ACTION_RUN:\n                    run(params);\n                    return 0;\n                case ACTION_RUN_APPLICATION:\n                    runApplication(params);\n                    return 0;\n                case ACTION_LIST:\n                    list(params);\n                    return 0;\n                case ACTION_INFO:\n                    info(params);\n                    return 0;\n                case ACTION_CANCEL:\n                    cancel(params);\n                    return 0;\n                case ACTION_STOP:\n                    stop(params);\n                    return 0;\n                case ACTION_SAVEPOINT:\n                    savepoint(params);\n                    return 0;\n                case \"-h\":\n                case \"--help\":\n                    CliFrontendParser.printHelp(customCommandLines);\n                    return 0;\n                case \"-v\":\n                case \"--version\":\n                    String version = EnvironmentInformation.getVersion();\n                    String commitID = EnvironmentInformation.getRevisionInformation().commitId;\n                    System.out.print(\"Version: \" + version);\n                    System.out.println(\n                            commitID.equals(EnvironmentInformation.UNKNOWN)\n                                    ? \"\"\n                                    : \", Commit ID: \" + commitID);\n                    return 0;\n                default:\n                    System.out.printf(\"\\\"%s\\\" is not a valid action.\\n\", action);\n                    System.out.println();\n                    System.out.println(\n                            \"Valid actions are \\\"run\\\", \\\"run-application\\\", \\\"list\\\", \\\"info\\\", \\\"savepoint\\\", \\\"stop\\\", or \\\"cancel\\\".\");\n                    System.out.println();\n                    System.out.println(\n                            \"Specify the version option (-v or --version) to print Flink version.\");\n                    System.out.println();\n                    System.out.println(\n                            \"Specify the help option (-h or --help) to get help on the command.\");\n                    return 1;\n            }\n        } catch (CliArgsException ce) {\n            return handleArgException(ce);\n        } catch (ProgramParametrizationException ppe) {\n            return handleParametrizationException(ppe);\n        } catch (ProgramMissingJobException pmje) {\n            return handleMissingJobException();\n        } catch (Exception e) {\n            return handleError(e);\n        }\n    }<\/code><\/pre>\n\n\n\n<p>\u7531action\u5e38\u91cf\u53ef\u77e5\u6709 run \u3001 run-application\u3001info\u3001list\u3001cancel\u3001stop\u3001savepoint\u51e0\u79cdaction<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b9e\u4f8b\u4ee5yarn-per-job\u4e3a\u4f8b\u3002 flink\u63d0\u4ea4\u4f5c\u4e1a\u662f\u901a\u8fc7flink run\u8fdb\u884c\u63d0\u4ea4\u7684\uff0c\u53ef\u4ee5\u4ece\u63d0\u4ea4\u811a\u672c\u4e2d\u770b [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.frost-s.com\/index.php\/wp-json\/wp\/v2\/posts\/990"}],"collection":[{"href":"https:\/\/blog.frost-s.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.frost-s.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.frost-s.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.frost-s.com\/index.php\/wp-json\/wp\/v2\/comments?post=990"}],"version-history":[{"count":2,"href":"https:\/\/blog.frost-s.com\/index.php\/wp-json\/wp\/v2\/posts\/990\/revisions"}],"predecessor-version":[{"id":994,"href":"https:\/\/blog.frost-s.com\/index.php\/wp-json\/wp\/v2\/posts\/990\/revisions\/994"}],"wp:attachment":[{"href":"https:\/\/blog.frost-s.com\/index.php\/wp-json\/wp\/v2\/media?parent=990"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.frost-s.com\/index.php\/wp-json\/wp\/v2\/categories?post=990"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.frost-s.com\/index.php\/wp-json\/wp\/v2\/tags?post=990"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}