You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@eventmesh.apache.org by ti...@apache.org on 2022/11/27 03:46:22 UTC
[incubator-eventmesh] branch master updated: [ISSUE #2255] simplify the code (#2259)
This is an automated email from the ASF dual-hosted git repository.
timcross pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-eventmesh.git
The following commit(s) were added to refs/heads/master by this push:
new dd2a9e9a [ISSUE #2255] simplify the code (#2259)
dd2a9e9a is described below
commit dd2a9e9aa7ad61a14f90f837445d747ddfd6345d
Author: weihubeats <we...@163.com>
AuthorDate: Sun Nov 27 11:46:16 2022 +0800
[ISSUE #2255] simplify the code (#2259)
* simplify the code
* format code
---
.../runtime/client/impl/PubClientImpl.java | 27 ++++++++++------------
1 file changed, 12 insertions(+), 15 deletions(-)
diff --git a/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/client/impl/PubClientImpl.java b/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/client/impl/PubClientImpl.java
index 2e76d7fe..d5a83942 100644
--- a/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/client/impl/PubClientImpl.java
+++ b/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/client/impl/PubClientImpl.java
@@ -41,9 +41,9 @@ import io.netty.channel.SimpleChannelInboundHandler;
public class PubClientImpl extends TCPClient implements PubClient {
- private Logger publogger = LoggerFactory.getLogger(this.getClass());
+ private final Logger publogger = LoggerFactory.getLogger(this.getClass());
- private UserAgent userAgent;
+ private final UserAgent userAgent;
private ReceiveMsgHook callback;
@@ -79,19 +79,16 @@ public class PubClientImpl extends TCPClient implements PubClient {
}
public void heartbeat() throws Exception {
- task = scheduler.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- try {
- if (!isActive()) {
- PubClientImpl.this.reconnect();
- }
- Package msg = MessageUtils.heartBeat();
- publogger.debug("PubClientImpl|{}|send heartbeat|Command={}|msg={}", clientNo, msg.getHeader().getCommand(), msg);
- PubClientImpl.this.dispatcher(msg, ClientConstants.DEFAULT_TIMEOUT_IN_MILLISECONDS);
- } catch (Exception e) {
- //ignore
+ task = scheduler.scheduleAtFixedRate(() -> {
+ try {
+ if (!isActive()) {
+ PubClientImpl.this.reconnect();
}
+ Package msg = MessageUtils.heartBeat();
+ publogger.debug("PubClientImpl|{}|send heartbeat|Command={}|msg={}", clientNo, msg.getHeader().getCommand(), msg);
+ PubClientImpl.this.dispatcher(msg, ClientConstants.DEFAULT_TIMEOUT_IN_MILLISECONDS);
+ } catch (Exception e) {
+ //ignore
}
}, ClientConstants.HEARTBEAT, ClientConstants.HEARTBEAT, TimeUnit.MILLISECONDS);
}
@@ -116,7 +113,7 @@ public class PubClientImpl extends TCPClient implements PubClient {
*/
@Override
public Package rr(Package msg, long timeout) throws Exception {
- publogger.info("PubClientImpl|{}|rr|send|Command={}|msg={}", clientNo, msg.getHeader().getCommand().REQUEST_TO_SERVER, msg);
+ publogger.info("PubClientImpl|{}|rr|send|Command={}|msg={}", clientNo, Command.REQUEST_TO_SERVER, msg);
return dispatcher(msg, timeout);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: commits-help@eventmesh.apache.org