1616 * limitations under the License.
1717 */
1818
19-
2019
2120package com .dtstack .flink .sql .launcher ;
2221
23- import com .aiweiergou .tool .logger .api .ChangeLogLevelProcess ;
22+ //import com.aiweiergou.tool.logger.api.ChangeLogLevelProcess;
23+
2424import com .dtstack .flink .sql .constrant .ConfigConstrant ;
2525import com .google .common .collect .Lists ;
2626import com .alibaba .fastjson .JSON ;
4141import org .apache .flink .configuration .GlobalConfiguration ;
4242import org .apache .flink .runtime .jobgraph .JobGraph ;
4343import org .apache .flink .runtime .jobgraph .SavepointRestoreSettings ;
44+ import org .slf4j .Logger ;
45+ import org .slf4j .LoggerFactory ;
4446
4547import java .io .BufferedReader ;
4648import java .io .File ;
4749import java .io .FileInputStream ;
4850import java .io .IOException ;
4951import java .io .InputStreamReader ;
5052import java .net .URLDecoder ;
53+ import java .nio .charset .StandardCharsets ;
5154import java .util .LinkedList ;
5255import java .util .List ;
5356import java .util .Map ;
5659/**
5760 * Date: 2017/2/20
5861 * Company: www.dtstack.com
62+ *
5963 * @author xuchao
6064 */
6165
@@ -64,15 +68,16 @@ public class LauncherMain {
6468
6569 private static String SP = File .separator ;
6670
71+ private static final Logger LOG = LoggerFactory .getLogger (LauncherMain .class );
72+
6773
6874 private static String getLocalCoreJarPath (String localSqlRootJar ) throws Exception {
6975 String jarPath = PluginUtil .getCoreJarFileName (localSqlRootJar , CORE_JAR );
70- String corePath = localSqlRootJar + SP + jarPath ;
71- return corePath ;
76+ return localSqlRootJar + SP + jarPath ;
7277 }
7378
7479 public static void main (String [] args ) throws Exception {
75- if (args .length == 1 && args [0 ].endsWith (".json" )){
80+ if (args .length == 1 && args [0 ].endsWith (".json" )) {
7681 args = parseJson (args );
7782 }
7883 OptionParser optionParser = new OptionParser (args );
@@ -84,27 +89,31 @@ public static void main(String[] args) throws Exception {
8489 confProp = URLDecoder .decode (confProp , Charsets .UTF_8 .toString ());
8590 Properties confProperties = PluginUtil .jsonStrToObject (confProp , Properties .class );
8691
87- if (mode .equals (ClusterMode .local .name ())) {
88- String [] localArgs = argList .toArray (new String [argList .size ()]);
92+ // LOG.info("current mode is {}", mode);
93+ System .out .println ("current mode is " + mode );
94+
95+ if (mode .equals (ClusterMode .local .name ())) {
96+ String [] localArgs = argList .toArray (new String [0 ]);
8997 Main .main (localArgs );
9098 return ;
9199 }
92100
93101 String pluginRoot = launcherOptions .getLocalSqlPluginPath ();
94102 File jarFile = new File (getLocalCoreJarPath (pluginRoot ));
95- String [] remoteArgs = argList .toArray (new String [argList . size () ]);
103+ String [] remoteArgs = argList .toArray (new String [0 ]);
96104 PackagedProgram program = new PackagedProgram (jarFile , Lists .newArrayList (), remoteArgs );
97105
98106 String savePointPath = confProperties .getProperty (ConfigConstrant .SAVE_POINT_PATH_KEY );
99- if (StringUtils .isNotBlank (savePointPath )){
107+ if (StringUtils .isNotBlank (savePointPath )) {
100108 String allowNonRestoredState = confProperties .getOrDefault (ConfigConstrant .ALLOW_NON_RESTORED_STATE_KEY , "false" ).toString ();
101109 program .setSavepointRestoreSettings (SavepointRestoreSettings .forPath (savePointPath , BooleanUtils .toBoolean (allowNonRestoredState )));
102110 }
103111
104- if (mode .equals (ClusterMode .yarnPer .name ())){
112+ if (mode .equals (ClusterMode .yarnPer .name ())) {
105113 String flinkConfDir = launcherOptions .getFlinkconf ();
106114 Configuration config = StringUtils .isEmpty (flinkConfDir ) ? new Configuration () : GlobalConfiguration .loadConfiguration (flinkConfDir );
107115 JobGraph jobGraph = PackagedProgramUtils .createJobGraph (program , config , 1 );
116+ LOG .info ("current jobID is {}" , jobGraph .getJobID ());
108117 PerJobSubmitter .submit (launcherOptions , jobGraph , config );
109118 } else {
110119 ClusterClient clusterClient = ClusterClientFactory .createClusterClient (launcherOptions );
@@ -116,35 +125,35 @@ public static void main(String[] args) throws Exception {
116125
117126 private static String [] parseJson (String [] args ) {
118127 BufferedReader reader = null ;
119- String lastStr = "" ;
120- try {
128+ StringBuilder lastStr = new StringBuilder () ;
129+ try {
121130 FileInputStream fileInputStream = new FileInputStream (args [0 ]);
122- InputStreamReader inputStreamReader = new InputStreamReader (fileInputStream , "UTF-8" );
131+ InputStreamReader inputStreamReader = new InputStreamReader (fileInputStream , StandardCharsets . UTF_8 );
123132 reader = new BufferedReader (inputStreamReader );
124- String tempString = null ;
125- while ((tempString = reader .readLine ()) != null ){
126- lastStr += tempString ;
133+ String tempString ;
134+ while ((tempString = reader .readLine ()) != null ) {
135+ lastStr . append ( tempString ) ;
127136 }
128137 reader .close ();
129- }catch (IOException e ){
138+ } catch (IOException e ) {
130139 e .printStackTrace ();
131- }finally {
132- if (reader != null ){
140+ } finally {
141+ if (reader != null ) {
133142 try {
134143 reader .close ();
135144 } catch (IOException e ) {
136145 e .printStackTrace ();
137146 }
138147 }
139148 }
140- Map <String , Object > map = JSON .parseObject (lastStr , new TypeReference <Map <String , Object >>(){} );
149+ Map <String , Object > map = JSON .parseObject (lastStr .toString (), new TypeReference <Map <String , Object >>() {
150+ });
141151 List <String > list = new LinkedList <>();
142152
143153 for (Map .Entry <String , Object > entry : map .entrySet ()) {
144154 list .add ("-" + entry .getKey ());
145155 list .add (entry .getValue ().toString ());
146156 }
147- String [] array = list .toArray (new String [list .size ()]);
148- return array ;
157+ return list .toArray (new String [0 ]);
149158 }
150159}
0 commit comments