底层RPC序列化协议调整为hessian2;
This commit is contained in:
parent
68c4e2cd26
commit
f7966b9bad
|
@ -1268,9 +1268,10 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
|
||||||
- 29、GLUE脚本文件自动清理功能,及时清理过期脚本文件;
|
- 29、GLUE脚本文件自动清理功能,及时清理过期脚本文件;
|
||||||
- 30、执行器注册方式切换优化,切换自动注册时主动同步在线机器,避免执行器为空的问题;
|
- 30、执行器注册方式切换优化,切换自动注册时主动同步在线机器,避免执行器为空的问题;
|
||||||
- 31、跨平台:除了提供Java、Python、PHP等十来种任务模式之外,新增提供基于HTTP的任务模式;
|
- 31、跨平台:除了提供Java、Python、PHP等十来种任务模式之外,新增提供基于HTTP的任务模式;
|
||||||
- 32、【迭代中】分片任务失败重试优化,仅重试当前失败的分片;
|
- 32、底层RPC序列化协议调整为hessian2;
|
||||||
- 33、【迭代中】支持通过API服务操作任务信息;
|
- 33、【迭代中】分片任务失败重试优化,仅重试当前失败的分片;
|
||||||
- 34、【迭代中】底层RPC协议更换为hessian2;
|
- 34、【迭代中】支持通过API服务操作任务信息;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### TODO LIST
|
### TODO LIST
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.xxl.job.core.rpc.serialize;
|
package com.xxl.job.core.rpc.serialize;
|
||||||
|
|
||||||
import com.caucho.hessian.io.HessianInput;
|
import com.caucho.hessian.io.Hessian2Input;
|
||||||
import com.caucho.hessian.io.HessianOutput;
|
import com.caucho.hessian.io.Hessian2Output;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
@ -15,22 +15,47 @@ public class HessianSerializer {
|
||||||
|
|
||||||
public static <T> byte[] serialize(T obj){
|
public static <T> byte[] serialize(T obj){
|
||||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||||
HessianOutput ho = new HessianOutput(os);
|
Hessian2Output ho = new Hessian2Output(os);
|
||||||
try {
|
try {
|
||||||
ho.writeObject(obj);
|
ho.writeObject(obj);
|
||||||
|
ho.flush();
|
||||||
|
byte[] result = os.toByteArray();
|
||||||
|
return result;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new IllegalStateException(e.getMessage(), e);
|
throw new IllegalStateException(e.getMessage(), e);
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
ho.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new IllegalStateException(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
os.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new IllegalStateException(e.getMessage(), e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return os.toByteArray();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> Object deserialize(byte[] bytes, Class<T> clazz) {
|
public static <T> Object deserialize(byte[] bytes, Class<T> clazz) {
|
||||||
ByteArrayInputStream is = new ByteArrayInputStream(bytes);
|
ByteArrayInputStream is = new ByteArrayInputStream(bytes);
|
||||||
HessianInput hi = new HessianInput(is);
|
Hessian2Input hi = new Hessian2Input(is);
|
||||||
try {
|
try {
|
||||||
return hi.readObject();
|
Object result = hi.readObject();
|
||||||
|
return result;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new IllegalStateException(e.getMessage(), e);
|
throw new IllegalStateException(e.getMessage(), e);
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
hi.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new IllegalStateException(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
is.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new IllegalStateException(e.getMessage(), e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue