5353 */
5454@ Slf4j
5555public class JobResultSaver {
56- private static final Log log = LogFactory .getLog (JobResultSaver .class );
56+ private static final Log logger = LogFactory .getLog (JobResultSaver .class );
5757
5858 // false: unused, true: using
5959 // 0: unused, 1: saving, 2: finished but still in use
@@ -92,8 +92,8 @@ public String genUniqueFileName() {
9292 public boolean saveFile (int resultId , String jsonData ) {
9393 // No need to wait, cuz id status must have been changed by genResultId before.
9494 // It's a check.
95- if (log .isDebugEnabled ()) {
96- log .debug ("save result " + resultId + ", data " + jsonData );
95+ if (logger .isDebugEnabled ()) {
96+ logger .debug ("save result " + resultId + ", data " + jsonData );
9797 }
9898 int status = idStatus .get (resultId );
9999 if (status != 1 ) {
@@ -105,7 +105,7 @@ public boolean saveFile(int resultId, String jsonData) {
105105 idStatus .set (resultId , 2 );
106106 idStatus .notifyAll ();
107107 }
108- log .info ("saved all result of result " + resultId );
108+ logger .info ("saved all result of result " + resultId );
109109 return true ;
110110 }
111111 // save to <log path>/tmp_result/<result_id>/<unique file name>
@@ -114,7 +114,7 @@ public boolean saveFile(int resultId, String jsonData) {
114114 File saveP = new File (savePath );
115115 if (!saveP .exists ()) {
116116 boolean res = saveP .mkdirs ();
117- log .info ("create save path " + savePath + ", status " + res );
117+ logger .info ("create save path " + savePath + ", status " + res );
118118 }
119119 }
120120 String fileFullPath = String .format ("%s/%s" , savePath , genUniqueFileName ());
@@ -125,7 +125,7 @@ public boolean saveFile(int resultId, String jsonData) {
125125 + fileFullPath );
126126 }
127127 } catch (IOException e ) {
128- log .error ("create file failed, path " + fileFullPath , e );
128+ logger .error ("create file failed, path " + fileFullPath , e );
129129 return false ;
130130 }
131131
@@ -135,7 +135,7 @@ public boolean saveFile(int resultId, String jsonData) {
135135 } catch (IOException e ) {
136136 // Write failed, we'll lost a part of result, but it's ok for show sync job
137137 // output. So we just log it, and response the http request.
138- log .error ("write result to file failed, path " + fileFullPath , e );
138+ logger .error ("write result to file failed, path " + fileFullPath , e );
139139 return false ;
140140 }
141141 return true ;
@@ -151,7 +151,7 @@ public String readResult(int resultId, long timeoutMs) throws InterruptedExcepti
151151 }
152152 }
153153 if (idStatus .get (resultId ) != 2 ) {
154- log .warn ("read result timeout, result saving may be still running, try read anyway, id " + resultId );
154+ logger .warn ("read result timeout, result saving may be still running, try read anyway, id " + resultId );
155155 }
156156 String output = "" ;
157157 // all finished, read csv from savePath
@@ -163,7 +163,7 @@ public String readResult(int resultId, long timeoutMs) throws InterruptedExcepti
163163 output = printFilesTostr (savePath );
164164 FileUtils .forceDelete (saveP );
165165 } else {
166- log .info ("empty result for " + resultId + ", show empty string" );
166+ logger .info ("empty result for " + resultId + ", show empty string" );
167167 }
168168 // reset id
169169 synchronized (idStatus ) {
@@ -189,7 +189,7 @@ public String printFilesTostr(String fileDir) {
189189 }
190190 return stringWriter .toString ();
191191 } catch (Exception e ) {
192- log .warn ("read result met exception when read " + fileDir + ", " + e .getMessage ());
192+ logger .warn ("read result met exception when read " + fileDir + ", " + e .getMessage ());
193193 e .printStackTrace ();
194194 return "read met exception, check the taskmanager log" ;
195195 }
@@ -219,7 +219,7 @@ private void printFile(String file, StringWriter stringWriter, boolean printHead
219219 csvPrinter .printRecord (iter .next ());
220220 }
221221 } catch (Exception e ) {
222- log .warn ("error when print result file " + file + ", ignore it" );
222+ logger .warn ("error when print result file " + file + ", ignore it" );
223223 e .printStackTrace ();
224224 }
225225 }
0 commit comments