日志优化

master
liuqingkun 3 years ago
parent f7c0627d6d
commit 1e5d1485c3
  1. 2
      commons/src/main/java/org/yzh/commons/constant/BusinessConstant.java
  2. 4
      jtt808-server/src/main/java/io/github/yezhihao/netmc/handler/TCPMessageAdapter.java
  3. 2
      jtt808-server/src/main/java/io/github/yezhihao/netmc/handler/UDPMessageAdapter.java
  4. 2
      jtt808-server/src/main/java/io/github/yezhihao/netmc/session/Session.java
  5. 61
      jtt808-server/src/main/java/io/github/yezhihao/netmc/websocket/WsChannelInboundHandler.java
  6. 13
      jtt808-server/src/main/java/org/yzh/protocol/codec/JTMessageAdapter.java
  7. 16
      jtt808-server/src/main/java/org/yzh/web/controller/JT1078Controller.java
  8. 8
      jtt808-server/src/main/java/org/yzh/web/endpoint/JT808Endpoint.java
  9. 6
      jtt808-server/src/main/java/org/yzh/web/endpoint/MessageManager.java
  10. 32
      jtt808-server/src/main/java/org/yzh/web/service/SendCommandService.java
  11. 18
      jtt808-server/src/main/resources/log4j2.xml

@ -10,6 +10,7 @@ public interface BusinessConstant {
* 默认通道号
*/
Integer DEFAULT_CHANNEL_NO = 9;
// Integer DEFAULT_CHANNEL_NO = 1;
/**
* 直播推流状态
@ -27,4 +28,5 @@ public interface BusinessConstant {
* jtt1078服务IP地址
*/
String JTT1078_SERVER_HOST = "112.6.27.89";
// String JTT1078_SERVER_HOST = "192.168.1.106";
}

@ -56,7 +56,7 @@ public class TCPMessageAdapter extends ChannelInboundHandlerAdapter {
@Override
public void channelActive(ChannelHandlerContext ctx) {
log.info("<<<<< Connected{}", ctx.channel().remoteAddress());
log.warn("<<<<< Connected{}", ctx.channel().remoteAddress());
}
@Override
@ -68,7 +68,7 @@ public class TCPMessageAdapter extends ChannelInboundHandlerAdapter {
session.invalidate();
}
log.info(">>>>> Disconnected clientId = {} , address = {}", clientId, client(ctx));
log.warn(">>>>> Disconnected clientId = {} , address = {}", clientId, client(ctx));
// 若掉线设备为当前推流设备, 调用推流方法, 发送推流
if (clientId.equals(BusinessCacheUtil.getCurrentPushDevice()) && SendCommandUtil.getService() != null) {

@ -62,7 +62,7 @@ public class UDPMessageAdapter extends ChannelInboundHandlerAdapter {
if (session == null) {
session = sessionManager.newInstance(ctx.channel(), sender, s -> sessionMap.remove(sender, s));
sessionMap.put(sender, session);
log.info("<<<<< Connected{}", session);
log.warn("<<<<< Connected{}", session);
}
return session;
}

@ -78,7 +78,7 @@ public class Session {
this.clientId = message.getClientId();
if (sessionManager != null)
sessionManager.add(this);
log.info("<<<<< Registered{}", this);
log.warn("<<<<< Registered{}", this);
}
public boolean isRegistered() {

@ -48,7 +48,7 @@ public class WsChannelInboundHandler extends SimpleChannelInboundHandler<TextWeb
// 每分钟的0s, 打印当前推流通道
LocalTime localTime = LocalTime.now();
if (localTime.getSecond() == 0) {
log.info(BusinessConstant.LOGGER_PREFIX + " : jt1078推送信息 : currentChannel = {}:{}:{}, content = {}",
log.warn(BusinessConstant.LOGGER_PREFIX + " : jt1078推送信息 : currentChannel = {}:{}:{}, content = {}",
currentChannel.id(), currentChannel.localAddress(), currentChannel.remoteAddress(), content);
}
@ -60,7 +60,6 @@ public class WsChannelInboundHandler extends SimpleChannelInboundHandler<TextWeb
String clientId = content.split("-")[0].substring(1);
String channelNo = content.split("-")[1];
BusinessCacheUtil.set1078PushDevice(clientId);
// 重置1078推送为空的次数
@ -73,8 +72,7 @@ public class WsChannelInboundHandler extends SimpleChannelInboundHandler<TextWeb
// 如果1078推送的正在推流的设备 != 808记录的当前推流的设备, 调用接口通知慢直播服务, 当前推流车辆及推流状态信息
if (!clientId.equals(curPush)) {
if (SendCommandUtil.getService() != null) {
log.info(BusinessConstant.LOGGER_PREFIX + " : websocket接收 : 原推流设备 = {} - {} ", curPush, curPushChannel);
log.info(BusinessConstant.LOGGER_PREFIX + " : websocket接收 : 更新为1078正在推流设备 = {} - {} ", clientId, channelNo);
log.warn(BusinessConstant.LOGGER_PREFIX + " : websocket接收 : 原推流设备 = {} - {} : 更新为1078正在推流设备 = {} - {} ", curPush, curPushChannel, clientId, channelNo);
SendCommandUtil.getService().noticeCarStatus(clientId, Integer.parseInt(channelNo), BusinessConstant.LIVE_STATUS_ONLINE);
}
}
@ -83,23 +81,23 @@ public class WsChannelInboundHandler extends SimpleChannelInboundHandler<TextWeb
String curPush = BusinessCacheUtil.getCurrentPushDevice();
if (!StringUtil.isNullOrEmpty(curPush)) {
if (SendCommandUtil.getService() != null) {
log.info(BusinessConstant.LOGGER_PREFIX + " : websocket接收 : 更新为1078正在推流设备 = {} - {} ", curPush, "null");
log.warn(BusinessConstant.LOGGER_PREFIX + " : websocket接收 : 更新为1078正在推流设备 = {} - {} ", curPush, "null");
SendCommandUtil.getService().noticeCarStatus(null, BusinessConstant.DEFAULT_CHANNEL_NO, BusinessConstant.LIVE_STATUS_OFFLINE);
}
}
int emptyTimes = BusinessCacheUtil.getPushEmptyTimes();
// 若持续2分钟收到的消息都为空, 调用推流方法
if (emptyTimes == 120) {
log.info(BusinessConstant.LOGGER_PREFIX + " : websocket接收 : 持续2分钟收到的消息都为空, 调用推流方法 ");
if (SendCommandUtil.getService() != null) {
SendCommandUtil.getService().sendToDevice();
}
emptyTimes = 0;
} else {
emptyTimes++;
}
BusinessCacheUtil.setPushEmptyTimes(emptyTimes);
// int emptyTimes = BusinessCacheUtil.getPushEmptyTimes();
// // 若持续30s收到的消息都为空, 调用推流方法
// if (emptyTimes == 30) {
// log.warn(BusinessConstant.LOGGER_PREFIX + " : websocket接收 : 持续30s收到的消息都为空, 调用推流方法 ");
// if (SendCommandUtil.getService() != null) {
// SendCommandUtil.getService().sendToDevice();
// }
// emptyTimes = 0;
// } else {
// emptyTimes++;
// }
// BusinessCacheUtil.setPushEmptyTimes(emptyTimes);
}
currentChannel.writeAndFlush(new TextWebSocketFrame("服务器时间" + LocalDateTime.now() + " : " + content));
@ -112,30 +110,29 @@ public class WsChannelInboundHandler extends SimpleChannelInboundHandler<TextWeb
*/
@Override
public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
users.add(ctx.channel());
log.info("netty 获得连接..... ");
log.info(BusinessConstant.LOGGER_PREFIX + " : websocket连接 : 客户端上线 : channelId = {} ", ctx.channel().id().asShortText());
Channel nettyChannel = ctx.channel();
if (!users.contains(nettyChannel)) {
users.add(nettyChannel);
log.warn(BusinessConstant.LOGGER_PREFIX + " : websocket连接 : 客户端上线 : channelId = {} ", nettyChannel.id().asLongText());
BusinessCacheUtil.set1078PushDevice("");
if (SendCommandUtil.getService() != null) {
// 1078上线后, 停止原推流线程, 重新启动线程发送推流命令
SendCommandUtil.getService().restartSendToDevice();
}
}
ctx.channel().writeAndFlush(new TextWebSocketFrame("服务器时间" + LocalDateTime.now() + " qw12312"));
BusinessCacheUtil.set1078PushDevice("");
if (SendCommandUtil.getService() != null) {
// 1078上线后, 停止原推流线程, 重新启动线程发送推流命令
SendCommandUtil.getService().restartSendToDevice();
}
}
@Override
public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
String channelId = ctx.channel().id().asShortText();
Channel nettyChannel = ctx.channel();
// 当触发handlerRemoved,ChannelGroup会自动移除对应客户端的channel
users.remove(ctx.channel());
log.info(BusinessConstant.LOGGER_PREFIX + " : websocket连接 : 客户端掉线 : channelId = {} ", channelId);
users.remove(nettyChannel);
log.warn(BusinessConstant.LOGGER_PREFIX + " : websocket连接 : 客户端掉线 : channelId = {} ", nettyChannel.id().asLongText());
BusinessCacheUtil.set1078PushDevice("");
if (SendCommandUtil.getService() != null) {
SendCommandUtil.getService().sendToDevice();
}
}
@Override

@ -9,10 +9,13 @@ import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.yzh.commons.constant.BusinessConstant;
import org.yzh.protocol.basics.JTMessage;
import org.yzh.protocol.commons.JT1078;
/**
* JT消息编解码适配器
*
* @author yezhihao
* https://gitee.com/yezhihao/jt808-server
*/
@ -70,12 +73,18 @@ public class JTMessageAdapter implements MessageEncoder<JTMessage>, MessageDecod
}
public void encodeLog(Session session, JTMessage message, ByteBuf output) {
if (log.isInfoEnabled())
if (log.isInfoEnabled()) {
log.info("{}\n>>>>>-{},hex[{}]", session, message, ByteBufUtil.hexDump(output));
} else if (message.getMessageId() == JT1078.实时音视频传输请求) {
log.warn(BusinessConstant.LOGGER_PREFIX + " : >>>>>-{} ", message);
}
}
public void decodeLog(Session session, JTMessage message, ByteBuf input) {
if (log.isInfoEnabled())
if (log.isInfoEnabled()) {
log.info("{}\n<<<<<-{},hex[{}]", session, message, ByteBufUtil.hexDump(input, 0, input.writerIndex()));
} else if (message.getMessageId() == JT1078.实时音视频传输请求) {
log.warn(BusinessConstant.LOGGER_PREFIX + " : <<<<<-{} ", message);
}
}
}

@ -49,7 +49,7 @@ public class JT1078Controller {
@Operation(summary = "9101 实时音视频传输请求")
@PostMapping("9101")
public Mono<APIResult<T0001>> T9101(@RequestBody T9101 request) {
log.info(BusinessConstant.LOGGER_PREFIX + " : 9101 实时音视频传输请求 开始执行.");
log.warn(BusinessConstant.LOGGER_PREFIX + " : 9101 实时音视频传输请求 开始执行.");
Mono<APIResult<T0001>> resultMono = null;
APIResult<T0001> result = new APIResult<>();
@ -58,7 +58,7 @@ public class JT1078Controller {
int channelNo = request.getChannelNo();
// 若指定设备与当前推流设备相同, 直接返回
if (clientId.equals(BusinessCacheUtil.getCurrentPushDevice()) && channelNo == BusinessCacheUtil.getCurrentPushChannel()) {
log.info(BusinessConstant.LOGGER_PREFIX + " : T9101 {} - {}, 指定设备正在推流.", clientId, channelNo);
log.warn(BusinessConstant.LOGGER_PREFIX + " : T9101 {} - {}, 指定设备正在推流.", clientId, channelNo);
result.setMsg("指定设备正在推流");
return Mono.create(sink -> {
sink.success(result);
@ -66,7 +66,7 @@ public class JT1078Controller {
}
log.info(BusinessConstant.LOGGER_PREFIX + " : T9101 - step1 : 当前推流设备 = {} - {} ", BusinessCacheUtil.getCurrentPushDevice(), BusinessCacheUtil.getCurrentPushChannel());
log.warn(BusinessConstant.LOGGER_PREFIX + " : T9101 - step1 : 当前推流设备 = {} - {} ", BusinessCacheUtil.getCurrentPushDevice(), BusinessCacheUtil.getCurrentPushChannel());
// 先调用停止推流方法, 然后指定设备推流
if (StringUtil.isNullOrEmpty(BusinessCacheUtil.getCurrentPushDevice())) {
T9102 t9102 = new T9102();
@ -76,7 +76,7 @@ public class JT1078Controller {
t9102.setCommand(0);
t9102.setStreamType(0);
log.info(BusinessConstant.LOGGER_PREFIX + " : T9101 - step2 : 停止推流当前设备 : {} - {} ", BusinessCacheUtil.getCurrentPushDevice(), BusinessCacheUtil.getCurrentPushChannel());
log.warn(BusinessConstant.LOGGER_PREFIX + " : T9101 - step2 : 停止推流当前设备 : {} - {} ", BusinessCacheUtil.getCurrentPushDevice(), BusinessCacheUtil.getCurrentPushChannel());
resultMono = messageManager.requestR(t9102, T0001.class);
}
@ -89,7 +89,7 @@ public class JT1078Controller {
SendCommandUtil.setService(sendCommandService);
log.info(BusinessConstant.LOGGER_PREFIX + " : T9101 - step3 : 开始推流 设备 = {} - {} ", request.getClientId(), BusinessConstant.DEFAULT_CHANNEL_NO);
log.warn(BusinessConstant.LOGGER_PREFIX + " : T9101 - step3 : 开始推流 设备 = {} - {} ", request.getClientId(), BusinessConstant.DEFAULT_CHANNEL_NO);
sendCommandService.sendToDevice(request.getClientId(), null);
return resultMono;
}
@ -97,13 +97,13 @@ public class JT1078Controller {
@Operation(summary = "9102 音视频实时传输控制")
@PostMapping("9102")
public Mono<APIResult<T0001>> T9102(@RequestBody T9102 request) {
log.info(BusinessConstant.LOGGER_PREFIX + " : T9102 - step1 : 停止推流 ");
log.warn(BusinessConstant.LOGGER_PREFIX + " : T9102 - step1 : 停止推流 ");
Mono<APIResult<T0001>> resultMono = messageManager.requestR(request, T0001.class);
// 若停止推流设备为正在推流设备, 触发推流方法
log.info(BusinessConstant.LOGGER_PREFIX + " : T9102 - step2 : 当前推流设备 = {} - {} " + BusinessCacheUtil.getCurrentPushDevice(), BusinessCacheUtil.getCurrentPushChannel());
log.warn(BusinessConstant.LOGGER_PREFIX + " : T9102 - step2 : 当前推流设备 = {} - {} " + BusinessCacheUtil.getCurrentPushDevice(), BusinessCacheUtil.getCurrentPushChannel());
if (request.getClientId().equals(BusinessCacheUtil.getCurrentPushDevice())) {
log.info(BusinessConstant.LOGGER_PREFIX + " : T9102 - step3 : 调用推流方法 ");
log.warn(BusinessConstant.LOGGER_PREFIX + " : T9102 - step3 : 调用推流方法 ");
sendCommandService.sendToDevice();
}
return resultMono;

@ -77,10 +77,10 @@ public class JT808Endpoint {
// 若无正在推流的设备, 调用推流方法
SendCommandUtil.setService(sendCommandService);
if (StringUtil.isNullOrEmpty(BusinessCacheUtil.getCurrentPushDevice()) || BusinessCacheUtil.getCurrentPushDevice().equals(message.getClientId())) {
log.info(BusinessConstant.LOGGER_PREFIX + " : 终端鉴权触发 - 发送推流命令 : 当前指定推流设备 = {} -> 将要推流设备 = {} ", BusinessCacheUtil.getCurrentPushDevice(), message.getClientId());
log.warn(BusinessConstant.LOGGER_PREFIX + " : 终端注册触发 - 发送推流命令 : 当前指定推流设备 = {} -> 将要推流设备 = {} ", BusinessCacheUtil.getCurrentPushDevice(), message.getClientId());
sendCommandService.sendToDevice(message.getClientId(), null);
} else {
log.info(BusinessConstant.LOGGER_PREFIX + " : 终端鉴权触发 - 发送推流命令 : 已有推流设备, 当前指定推流设备 = {}", BusinessCacheUtil.getCurrentPushDevice());
log.warn(BusinessConstant.LOGGER_PREFIX + " : 终端注册触发 - 发送推流命令 : 已有推流设备, 当前指定推流设备 = {}", BusinessCacheUtil.getCurrentPushDevice());
}
T8100 result = new T8100();
@ -105,10 +105,10 @@ public class JT808Endpoint {
// 若无正在推流的设备, 调用推流方法
SendCommandUtil.setService(sendCommandService);
if (StringUtil.isNullOrEmpty(BusinessCacheUtil.getCurrentPushDevice()) || BusinessCacheUtil.getCurrentPushDevice().equals(message.getClientId())) {
log.info(BusinessConstant.LOGGER_PREFIX + " : 终端鉴权触发 - 发送推流命令 : 当前指定推流设备 = {} -> 将要推流设备 = {} ", BusinessCacheUtil.getCurrentPushDevice(), message.getClientId());
log.warn(BusinessConstant.LOGGER_PREFIX + " : 终端鉴权触发 - 发送推流命令 : 当前指定推流设备 = {} -> 将要推流设备 = {} ", BusinessCacheUtil.getCurrentPushDevice(), message.getClientId());
sendCommandService.sendToDevice(message.getClientId(), null);
} else {
log.info(BusinessConstant.LOGGER_PREFIX + " : 终端鉴权触发 - 发送推流命令 : 已有推流设备, 当前指定推流设备 = {}", BusinessCacheUtil.getCurrentPushDevice());
log.warn(BusinessConstant.LOGGER_PREFIX + " : 终端鉴权触发 - 发送推流命令 : 已有推流设备, 当前指定推流设备 = {}", BusinessCacheUtil.getCurrentPushDevice());
}
T0001 result = new T0001();

@ -82,16 +82,16 @@ public class MessageManager {
if (session == null)
return OFFLINE_RESULT;
log.info(BusinessConstant.LOGGER_PREFIX + " : 发送推流命令 : 参数 = {}", request.toString());
log.warn(BusinessConstant.LOGGER_PREFIX + " : 发送推流命令 : 参数 = {}", request.toString());
Mono<APIResult<T>> resultMono = session.request(request, responseClass)
.map(message -> APIResult.ok(message))
.timeout(Duration.ofSeconds(10), TIMEOUT_RESULT)
.onErrorResume(e -> {
// log.warn("消息发送失败", e);
log.info(BusinessConstant.LOGGER_PREFIX + " : 发送推流命令 : 结果 = 消息发送失败. msg : {}", e);
log.warn(BusinessConstant.LOGGER_PREFIX + " : 发送推流命令 : 结果 = 消息发送失败. msg : {}", e);
return SENDFAIL_RESULT;
});
log.info(BusinessConstant.LOGGER_PREFIX + " : 发送推流命令 : 结果 = {}", resultMono.block().toString());
log.warn(BusinessConstant.LOGGER_PREFIX + " : 发送推流命令 : 结果 = {}", resultMono.block().toString());
return resultMono;
}

@ -67,7 +67,7 @@ public class SendCommandService {
*/
public void restartSendToDevice() {
if (sendCommandToDeviceThread != null && sendCommandToDeviceThread.isAlive()) {
log.info(BusinessConstant.LOGGER_PREFIX + " : 自定义推流方法 sendToDevice : 停止原线程, 重新开启线程 ");
log.warn(BusinessConstant.LOGGER_PREFIX + " : 自定义推流方法 sendToDevice : 停止原线程, 重新开启线程 ");
sendCommandToDeviceThread.interrupt();
}
@ -80,26 +80,26 @@ public class SendCommandService {
public void sendToDevice() {
if (sessionManager.all() == null || sessionManager.all().size() == 0) {
// 当前无在线设备, 直接返回, 通知给慢直播设备离线
log.info(BusinessConstant.LOGGER_PREFIX + " : 自定义推流方法 sendToDevice : 当前无在线设备, 直接返回, 通知给慢直播设备离线 ");
log.warn(BusinessConstant.LOGGER_PREFIX + " : 自定义推流方法 sendToDevice() : 当前无在线设备, 直接返回, 通知给慢直播设备离线 ");
noticeCarStatus(null, null, BusinessConstant.LIVE_STATUS_OFFLINE);
return;
}
log.info(BusinessConstant.LOGGER_PREFIX + " : 自定义推流方法 sendToDevice : 开始执行 ");
log.warn(BusinessConstant.LOGGER_PREFIX + " : 自定义推流方法 sendToDevice() : 开始执行 ");
if (sendCommandToDeviceThread != null && sendCommandToDeviceThread.isAlive()) {
log.info(BusinessConstant.LOGGER_PREFIX + " : 自定义推流方法 sendToDevice : 已有线程执行推流, 直接返回 ");
log.warn(BusinessConstant.LOGGER_PREFIX + " : 自定义推流方法 sendToDevice() : 已有线程执行推流, 直接返回 ");
return;
}
noticeCarStatus(null, BusinessConstant.DEFAULT_CHANNEL_NO, BusinessConstant.LIVE_STATUS_WAITING);
log.info(BusinessConstant.LOGGER_PREFIX + " : 自定义推流方法 sendToDevice : 启动线程, 开始执行发送推流命令 ");
log.warn(BusinessConstant.LOGGER_PREFIX + " : 自定义推流方法 sendToDevice() : 启动线程, 开始执行发送推流命令 ");
sendCommandToDeviceThread = new Thread(new Runnable() {
@Override
public void run() {
for (Session session : sessionManager.all()) {
log.info(BusinessConstant.LOGGER_PREFIX + " : 自定义推流方法 sendToDevice : 调用推流方法开始 ");
log.warn(BusinessConstant.LOGGER_PREFIX + " : 自定义推流方法 sendToDevice() : 调用推流方法开始 ");
boolean result = sendCommand(session.getClientId(), BusinessConstant.DEFAULT_CHANNEL_NO);
// 只要有一个设备发送推流命令成功, 直接返回, 不继续向其他设备发送推流命令
@ -123,7 +123,7 @@ public class SendCommandService {
* @param channelNo
*/
public boolean sendToDevice(String clientId, Integer channelNo) {
log.info(BusinessConstant.LOGGER_PREFIX + " : 自定义推流方法 sendToDevice {} - {} : 开始执行 ", clientId, channelNo);
log.warn(BusinessConstant.LOGGER_PREFIX + " : 自定义推流方法 sendToDevice(clientId, channelNo) {} - {} : 开始执行 ", clientId, channelNo);
channelNo = channelNo == null ? BusinessConstant.DEFAULT_CHANNEL_NO : channelNo;
if (StringUtil.isNullOrEmpty(clientId)) {
@ -164,32 +164,28 @@ public class SendCommandService {
boolean sendResult = resultObj.isSuccess();
// 若命令发送失败, 返回false
if (!sendResult) {
log.info(BusinessConstant.LOGGER_PREFIX + " : 自定义推流方法 : 发送命令失败 ");
log.warn(BusinessConstant.LOGGER_PREFIX + " : 自定义推流方法-sendCommand : 发送命令失败 ");
return false;
}
// step2: 由于延迟原因, 等待1s后调用jtt1078上传到缓存的推流车辆, 确认设备是否已推流
log.info(BusinessConstant.LOGGER_PREFIX + " : 自定义推流方法 : 获取1078推流设备, 1s延迟开始 ");
Thread.sleep(1000);
log.info(BusinessConstant.LOGGER_PREFIX + " : 自定义推流方法 : 获取1078推流设备, 1s延迟结束 ");
// step3: 调用3次, 失败后等待1s, 继续调用3次. 若仍然失败, 视为命令发送失败, 返回false
int times = 0;
while (times < 3) {
// 调用jtt1078流媒体接口
String clientId1078 = BusinessCacheUtil.get1078PushDevice();
log.info(BusinessConstant.LOGGER_PREFIX + " : 自定义推流方法 : 1078推流设备 = {} ", clientId1078);
log.warn(BusinessConstant.LOGGER_PREFIX + " : 自定义推流方法-sendCommand : 1078推流设备 = {} ", clientId1078);
// 判断返回的推流设备是否为发送命令的设备, 如果是, 返回true, 否则继续下次循环
if (clientId.equals(clientId1078)) {
log.info(BusinessConstant.LOGGER_PREFIX + " : 自定义推流方法 : 推流设备 = 发送命令的设备, 返回推流成功");
log.warn(BusinessConstant.LOGGER_PREFIX + " : 自定义推流方法-sendCommand : 推流设备 = 发送命令的设备, 返回推流成功");
noticeCarStatus(clientId, channelNo, BusinessConstant.LIVE_STATUS_ONLINE);
return true;
}
log.info(BusinessConstant.LOGGER_PREFIX + " : 自定义推流方法 : 重试1s延迟开始 ");
Thread.sleep(1000);
log.info(BusinessConstant.LOGGER_PREFIX + " : 自定义推流方法 : 重试1s延迟结束 ");
times++;
}
@ -211,7 +207,7 @@ public class SendCommandService {
public void noticeCarStatus(String clientId, Integer channelNo, String status) {
// 若1078通知在线, 但此时无在线设备, 不再更新状态
if (BusinessConstant.LIVE_STATUS_ONLINE.equals(status) && (sessionManager.all() == null || sessionManager.all().size() == 0)) {
log.info(BusinessConstant.LOGGER_PREFIX + " : 自定义推流方法 noticeCarStatus : 当前无在线设备, 将设备强制置为离线, 推送给慢直播服务");
log.warn(BusinessConstant.LOGGER_PREFIX + " : noticeCarStatus(更新车辆状态缓存) : 当前无在线设备, 将设备强制置为离线, 推送给慢直播服务");
clientId = null;
status = BusinessConstant.LIVE_STATUS_OFFLINE;
}
@ -219,7 +215,7 @@ public class SendCommandService {
// 若当前推流状态为离线, 且要更新的状态为等待, 直接返回. 离线状态不用切换等待状态
if (BusinessConstant.LIVE_STATUS_OFFLINE.equals(BusinessCacheUtil.getPushStatus())
&& BusinessConstant.LIVE_STATUS_WAITING.equals(status)) {
log.info(BusinessConstant.LOGGER_PREFIX + " : 自定义推流方法 noticeCarStatus : 离线状态不用切换等待状态");
log.warn(BusinessConstant.LOGGER_PREFIX + " : noticeCarStatus(更新车辆状态缓存) : 离线状态不用切换等待状态");
return;
}
@ -235,8 +231,8 @@ public class SendCommandService {
Map<String, String> params = new HashMap<>();
params.put("clientId", clientId);
params.put("carStat", status);
log.info(BusinessConstant.LOGGER_PREFIX + " : 调用慢直播服务接口 : 当前推流设备 = {} - {} - {}", clientId, channelNo, status);
log.warn(BusinessConstant.LOGGER_PREFIX + " : 调用慢直播服务接口 : 当前推流设备 = {} - {} - {}", clientId, channelNo, status);
String res = HttpClientUtils.doGet(url, params);
log.info(BusinessConstant.LOGGER_PREFIX + " : 调用慢直播服务接口 : 返回结果 = {}", res);
log.warn(BusinessConstant.LOGGER_PREFIX + " : 调用慢直播服务接口 : 返回结果 = {}", res);
}
}

@ -7,32 +7,26 @@
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="[%p] %d{HH:mm:ss.SSS} [%t] %c{2}[%L]%m%n"/>
<PatternLayout pattern="[%p] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{2}[%L] | %m%n"/>
</Console>
<RollingRandomAccessFile name="AppLog" fileName="${LOG_HOME}/${LOG_NAME}.log" filePattern="${LOG_HOME}/jt808/$${date:yyyy-MM}/${LOG_NAME}-%d{yyyy-MM-dd}-%i.log">
<PatternLayout pattern="[%p] %d{HH:mm:ss.SSS} [%t] %c{2}[%L]%m%n"/>
<RollingRandomAccessFile name="AppLog" fileName="${LOG_HOME}/${LOG_NAME}.log"
filePattern="${LOG_HOME}/jt808/$${date:yyyy-MM}/${LOG_NAME}-%d{yyyy-MM-dd}-%i.log">
<PatternLayout pattern="[%p] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{2}[%L] | %m%n"/>
<Policies>
<TimeBasedTriggeringPolicy/>
<SizeBasedTriggeringPolicy size="250 MB"/>
</Policies>
</RollingRandomAccessFile>
<RollingRandomAccessFile name="AccessLog" fileName="${LOG_HOME}/${LOG_NAME}-access.log" filePattern="${LOG_HOME}/jt808/${LOG_NAME}-access-%d{yyyy-MM-dd}-%i.log">
<PatternLayout pattern="[%p] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %m%n"/>
<Policies>
<SizeBasedTriggeringPolicy size="100 MB"/>
</Policies>
</RollingRandomAccessFile>
</Appenders>
<Loggers>
<logger name="io.github.yezhihao.netmc" level="info" additivity="false">
<logger name="io.github.yezhihao.netmc" level="WARN" additivity="false">
<AppenderRef ref="AppLog"/>
<AppenderRef ref="Console"/>
</logger>
<Root level="info">
<Root level="WARN">
<AppenderRef ref="AppLog"/>
<AppenderRef ref="Console"/>
</Root>

Loading…
Cancel
Save