Skip to content

Commit

Permalink
bugfix fix collector run cyclic when connect auth failed (#1256)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomsun28 authored Sep 23, 2023
1 parent 8aba410 commit 69bb0e2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import lombok.extern.slf4j.Slf4j;
import org.dromara.hertzbeat.collector.dispatch.entrance.CollectServer;
import org.dromara.hertzbeat.collector.dispatch.timer.TimerDispatch;
import org.dromara.hertzbeat.common.constants.CommonConstants;
import org.dromara.hertzbeat.common.entity.message.ClusterMsg;
import org.dromara.hertzbeat.common.support.SpringContextHolder;
import org.dromara.hertzbeat.remoting.netty.NettyRemotingProcessor;
Expand All @@ -27,6 +28,9 @@ public ClusterMsg.Message handle(ChannelHandlerContext ctx, ClusterMsg.Message m
if (this.timerDispatch == null) {
this.timerDispatch = SpringContextHolder.getBean(TimerDispatch.class);
}
if (message.getMsg().contains(CommonConstants.COLLECTOR_AUTH_FAILED)) {
log.error("receive client auth failed message and go close. {}", message.getMsg());
}
this.timerDispatch.goOffline();
this.collectServer.shutdown();
SpringApplication.exit(SpringContextHolder.getApplicationContext(), () -> 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ public ClusterMsg.Message handle(ChannelHandlerContext ctx, ClusterMsg.Message m
}
timerDispatch.goOffline();
log.info("receive offline message and handle success");
message.getMsg();
if (message.getMsg().contains(CommonConstants.COLLECTOR_AUTH_FAILED)) {
log.error("receive client auth failed message and go offline. {}", message.getMsg());
return null;
}
return ClusterMsg.Message.newBuilder()
.setIdentity(message.getIdentity())
.setDirection(ClusterMsg.Direction.RESPONSE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,4 +316,9 @@ public interface CommonConstants {
* collector mode private
*/
String MODE_PRIVATE = "private";

/**
* collector auth failed message
*/
String COLLECTOR_AUTH_FAILED = "Auth Failed";
}

0 comments on commit 69bb0e2

Please sign in to comment.