重要更新: ByteWriteFactory内部Byte[]长度改为动态初始化; 一方面在小数据量下节省字节开销;另一方面在大数据量下可以保证数据存放没问题;

master
xueli.xue 8 years ago
parent f48ac05cdd
commit 57abd14b6d
  1. 6
      xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobLogController.java
  2. 3
      xxl-job-core/src/main/java/com/xxl/job/core/util/ByteWriteFactory.java
  3. 2
      xxl-job-core/src/main/java/com/xxl/job/core/util/XxlJobNetCommUtil.java

@ -108,10 +108,10 @@ public class JobLogController {
// base check
XxlJobLog log = xxlJobLogDao.load(id);
if (log == null) {
return new ReturnT<String>(500, "参数异常");
return new ReturnT<String>(500, "查看执行日志失败: 参数异常");
}
if (!(ResponseModel.SUCCESS.equals(log.getTriggerStatus()) || StringUtils.isNotBlank(log.getHandleStatus()))) {
return new ReturnT<String>(500, "调度失败,无法查看执行日志");
return new ReturnT<String>(500, "查看执行日志失败: 任务发起调度失败,无法查看执行日志");
}
// trigger id, trigger time
@ -125,7 +125,7 @@ public class JobLogController {
if (ResponseModel.SUCCESS.equals(responseModel.getStatus())) {
return new ReturnT<String>(responseModel.getMsg());
} else {
return new ReturnT<String>(500, responseModel.getMsg());
return new ReturnT<String>(500, "查看执行日志失败: " + responseModel.getMsg());
}
}

@ -16,6 +16,9 @@ public class ByteWriteFactory {
public ByteWriteFactory() {
m_byteBuf = ByteBuffer.allocate(1024 * 4);
}
public ByteWriteFactory(int capacity) {
m_byteBuf = ByteBuffer.allocate(capacity);
}
public void writeInt(int intValue) {
byte[] intBytes = new byte[4];

@ -42,7 +42,7 @@ public class XxlJobNetCommUtil {
int len = ByteHexConverter.getByteLen(json);
// json to byte[]
ByteWriteFactory byteWriteFactory = new ByteWriteFactory();
ByteWriteFactory byteWriteFactory = new ByteWriteFactory(4 + len);
byteWriteFactory.writeInt(len);
byteWriteFactory.writeString(json, len);
byte[] bytes = byteWriteFactory.getBytes();

Loading…
Cancel
Save