Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issues #405]code polish and fix typo #404

Merged
merged 2 commits into from
Jul 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ on:
push:
branches:
- develop
- '[0-9]+.[0-9]+.[0-9]+**'
pull_request:
branches:
- develop
- '[0-9]+.[0-9]+.[0-9]+**'
workflow_dispatch:

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/greetings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

name: Greetings

on: [pull_request, issues]
on: [pull_request_target, issues]

jobs:
greeting:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public LiteConsumer(LiteClientConfig liteClientConfig,
// this.remotingServer = new RemotingServer(this.consumeExecutor);
}

private AtomicBoolean started = new AtomicBoolean(Boolean.FALSE);
private final AtomicBoolean started = new AtomicBoolean(Boolean.FALSE);

@Override
public void start() throws Exception {
Expand Down Expand Up @@ -226,15 +226,14 @@ public void run() {

EventMeshRetObj ret = JSON.parseObject(res, EventMeshRetObj.class);

if (ret.getRetCode() == EventMeshRetCode.SUCCESS.getRetCode()) {
} else {
if (ret.getRetCode() != EventMeshRetCode.SUCCESS.getRetCode()) {
throw new EventMeshException(ret.getRetCode(), ret.getRetMsg());
}
} catch (Exception e) {
logger.error("send heartBeat error", e);
}
}
}, EventMeshCommon.HEATBEAT, EventMeshCommon.HEATBEAT, TimeUnit.MILLISECONDS);
}, EventMeshCommon.HEARTBEAT, EventMeshCommon.HEARTBEAT, TimeUnit.MILLISECONDS);
}

public boolean unsubscribe(List<String> topicList, String url) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class EventMeshCommon {
/**
* CLIENT端心跳间隔时间
*/
public static int HEATBEAT = 30 * 1000;
public static int HEARTBEAT = 30 * 1000;

/**
* RR 废弃清理的时间间隔
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
import org.slf4j.LoggerFactory;

public abstract class TcpClient implements Closeable {
private Logger logger = LoggerFactory.getLogger(this.getClass());
private final Logger logger = LoggerFactory.getLogger(this.getClass());

public int clientNo = (new Random()).nextInt(1000);

Expand All @@ -67,8 +67,6 @@ public abstract class TcpClient implements Closeable {

protected static final ScheduledThreadPoolExecutor scheduler = new ScheduledThreadPoolExecutor(4, new EventMeshThreadFactoryImpl("TCPClientScheduler", true));

private ScheduledFuture<?> task;

public TcpClient(String host, int port) {
this.host = host;
this.port = port;
Expand Down Expand Up @@ -119,7 +117,7 @@ protected void send(Package msg) throws Exception {
if (channel.isWritable()) {
channel.writeAndFlush(msg).addListener((ChannelFutureListener) future -> {
if (!future.isSuccess()) {
logger.warn("send msg failed", future.isSuccess(), future.cause());
logger.warn("send msg failed", future.cause());
}
});
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

public class SimplePubClientImpl extends TcpClient implements SimplePubClient {

private Logger logger = LoggerFactory.getLogger(this.getClass());
private final Logger logger = LoggerFactory.getLogger(this.getClass());

private UserAgent userAgent;

Expand Down Expand Up @@ -90,10 +90,10 @@ public void run() {
}
Package msg = MessageUtils.heartBeat();
io(msg, EventMeshCommon.DEFAULT_TIME_OUT_MILLS);
} catch (Exception e) {
} catch (Exception ignore) {
}
}
}, EventMeshCommon.HEATBEAT, EventMeshCommon.HEATBEAT, TimeUnit.MILLISECONDS);
}, EventMeshCommon.HEARTBEAT, EventMeshCommon.HEARTBEAT, TimeUnit.MILLISECONDS);
}

private void goodbye() throws Exception {
Expand Down Expand Up @@ -176,16 +176,13 @@ protected void channelRead0(ChannelHandlerContext ctx, Package msg) throws Excep
Package pkg = MessageUtils.responseToClientAck(msg);
send(pkg);
} else if (cmd == Command.SERVER_GOODBYE_REQUEST) {

//TODO
}

RequestContext context = contexts.get(RequestContext._key(msg));
if (context != null) {
contexts.remove(context.getKey());
context.finish(msg);
return;
} else {
return;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

public class SimpleSubClientImpl extends TcpClient implements SimpleSubClient {

private Logger logger = LoggerFactory.getLogger(this.getClass());
private final Logger logger = LoggerFactory.getLogger(this.getClass());

private UserAgent userAgent;

Expand Down Expand Up @@ -101,10 +101,10 @@ public void run() {
}
Package msg = MessageUtils.heartBeat();
SimpleSubClientImpl.this.io(msg, EventMeshCommon.DEFAULT_TIME_OUT_MILLS);
} catch (Exception e) {
} catch (Exception ignore) {
}
}
}, EventMeshCommon.HEATBEAT, EventMeshCommon.HEATBEAT, TimeUnit.MILLISECONDS);
}, EventMeshCommon.HEARTBEAT, EventMeshCommon.HEARTBEAT, TimeUnit.MILLISECONDS);
}

private void goodbye() throws Exception {
Expand Down Expand Up @@ -172,10 +172,8 @@ protected void channelRead0(ChannelHandlerContext ctx, Package msg) throws Excep
if (context != null) {
contexts.remove(context.getKey());
context.finish(msg);
return;
} else {
logger.error("msg ignored,context not found.|{}|{}", cmd, msg);
return;
}
}
}
Expand Down