|
|
@ -17,7 +17,6 @@ |
|
|
|
|
|
|
|
|
|
|
|
package org.apache.dolphinscheduler.server.log; |
|
|
|
package org.apache.dolphinscheduler.server.log; |
|
|
|
|
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.common.utils.IOUtils; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.common.utils.JSONUtils; |
|
|
|
import org.apache.dolphinscheduler.common.utils.JSONUtils; |
|
|
|
import org.apache.dolphinscheduler.common.utils.LoggerUtils; |
|
|
|
import org.apache.dolphinscheduler.common.utils.LoggerUtils; |
|
|
|
import org.apache.dolphinscheduler.remote.command.Command; |
|
|
|
import org.apache.dolphinscheduler.remote.command.Command; |
|
|
@ -44,9 +43,6 @@ import java.util.Collections; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.concurrent.ExecutorService; |
|
|
|
import java.util.concurrent.ExecutorService; |
|
|
|
import java.util.concurrent.Executors; |
|
|
|
import java.util.concurrent.Executors; |
|
|
|
import java.util.concurrent.LinkedBlockingQueue; |
|
|
|
|
|
|
|
import java.util.concurrent.ThreadPoolExecutor; |
|
|
|
|
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Stream; |
|
|
|
import java.util.stream.Stream; |
|
|
|
|
|
|
|
|
|
|
@ -56,7 +52,7 @@ import org.slf4j.LoggerFactory; |
|
|
|
import io.netty.channel.Channel; |
|
|
|
import io.netty.channel.Channel; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* logger request process logic |
|
|
|
* logger request process logic |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class LoggerRequestProcessor implements NettyRequestProcessor { |
|
|
|
public class LoggerRequestProcessor implements NettyRequestProcessor { |
|
|
|
|
|
|
|
|
|
|
@ -139,11 +135,8 @@ public class LoggerRequestProcessor implements NettyRequestProcessor { |
|
|
|
* @throws Exception exception |
|
|
|
* @throws Exception exception |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private byte[] getFileContentBytes(String filePath) { |
|
|
|
private byte[] getFileContentBytes(String filePath) { |
|
|
|
InputStream in = null; |
|
|
|
try (InputStream in = new FileInputStream(filePath); |
|
|
|
ByteArrayOutputStream bos = null; |
|
|
|
ByteArrayOutputStream bos = new ByteArrayOutputStream()) { |
|
|
|
try { |
|
|
|
|
|
|
|
in = new FileInputStream(filePath); |
|
|
|
|
|
|
|
bos = new ByteArrayOutputStream(); |
|
|
|
|
|
|
|
byte[] buf = new byte[1024]; |
|
|
|
byte[] buf = new byte[1024]; |
|
|
|
int len; |
|
|
|
int len; |
|
|
|
while ((len = in.read(buf)) != -1) { |
|
|
|
while ((len = in.read(buf)) != -1) { |
|
|
@ -151,10 +144,7 @@ public class LoggerRequestProcessor implements NettyRequestProcessor { |
|
|
|
} |
|
|
|
} |
|
|
|
return bos.toByteArray(); |
|
|
|
return bos.toByteArray(); |
|
|
|
} catch (IOException e) { |
|
|
|
} catch (IOException e) { |
|
|
|
logger.error("get file bytes error",e); |
|
|
|
logger.error("get file bytes error", e); |
|
|
|
} finally { |
|
|
|
|
|
|
|
IOUtils.closeQuietly(bos); |
|
|
|
|
|
|
|
IOUtils.closeQuietly(in); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return new byte[0]; |
|
|
|
return new byte[0]; |
|
|
|
} |
|
|
|
} |
|
|
@ -168,14 +158,14 @@ public class LoggerRequestProcessor implements NettyRequestProcessor { |
|
|
|
* @return part file content |
|
|
|
* @return part file content |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private List<String> readPartFileContent(String filePath, |
|
|
|
private List<String> readPartFileContent(String filePath, |
|
|
|
int skipLine, |
|
|
|
int skipLine, |
|
|
|
int limit) { |
|
|
|
int limit) { |
|
|
|
File file = new File(filePath); |
|
|
|
File file = new File(filePath); |
|
|
|
if (file.exists() && file.isFile()) { |
|
|
|
if (file.exists() && file.isFile()) { |
|
|
|
try (Stream<String> stream = Files.lines(Paths.get(filePath))) { |
|
|
|
try (Stream<String> stream = Files.lines(Paths.get(filePath))) { |
|
|
|
return stream.skip(skipLine).limit(limit).collect(Collectors.toList()); |
|
|
|
return stream.skip(skipLine).limit(limit).collect(Collectors.toList()); |
|
|
|
} catch (IOException e) { |
|
|
|
} catch (IOException e) { |
|
|
|
logger.error("read file error",e); |
|
|
|
logger.error("read file error", e); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
logger.info("file path: {} not exists", filePath); |
|
|
|
logger.info("file path: {} not exists", filePath); |
|
|
|