weihubeats commented on code in PR #2786:
URL:
https://github.com/apache/incubator-eventmesh/pull/2786#discussion_r1060017797
##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/tcp/client/group/ClientSessionGroupMapping.java:
##########
@@ -325,60 +320,57 @@ private void handleUnackMsgsInSession(Session session) {
}
}
- private void cleanClientGroupWrapperCommon(Session session) throws
Exception {
+ private void cleanClientGroupWrapperCommon(ClientGroupWrapper
clientGroupWrapper) throws Exception {
log.info("GroupConsumerSessions size:{}",
-
Objects.requireNonNull(session.getClientGroupWrapper().get()).getGroupConsumerSessions().size());
- if
(Objects.requireNonNull(session.getClientGroupWrapper().get()).getGroupConsumerSessions().size()
== 0) {
- shutdownClientGroupConsumer(session);
+ clientGroupWrapper.getGroupConsumerSessions().size());
+ if (clientGroupWrapper.getGroupConsumerSessions().size() == 0) {
+ shutdownClientGroupConsumer(clientGroupWrapper);
}
log.info("GroupProducerSessions size:{}",
-
Objects.requireNonNull(session.getClientGroupWrapper().get()).getGroupProducerSessions().size());
- if
((Objects.requireNonNull(session.getClientGroupWrapper().get()).getGroupConsumerSessions().size()
== 0)
- &&
(Objects.requireNonNull(session.getClientGroupWrapper().get()).getGroupProducerSessions().size()
== 0)) {
- shutdownClientGroupProducer(session);
-
-
clientGroupMap.remove(Objects.requireNonNull(session.getClientGroupWrapper().get()).getGroup());
-
lockMap.remove(Objects.requireNonNull(session.getClientGroupWrapper().get()).getGroup());
- log.info("remove clientGroupWrapper group[{}]",
Objects.requireNonNull(session.getClientGroupWrapper().get()).getGroup());
+ clientGroupWrapper.getGroupProducerSessions().size());
+ if ((clientGroupWrapper.getGroupConsumerSessions().size() == 0)
+ && (clientGroupWrapper.getGroupProducerSessions().size() ==
0)) {
+ shutdownClientGroupProducer(clientGroupWrapper);
+
+ clientGroupMap.remove(clientGroupWrapper.getGroup());
+ lockMap.remove(clientGroupWrapper.getGroup());
+ log.info("remove clientGroupWrapper group[{}]",
clientGroupWrapper.getGroup());
}
}
- private void shutdownClientGroupConsumer(Session session) throws Exception
{
- if
(Objects.requireNonNull(session.getClientGroupWrapper().get()).started4Broadcast.get()
== Boolean.TRUE) {
-
Objects.requireNonNull(session.getClientGroupWrapper().get()).shutdownBroadCastConsumer();
+ private void shutdownClientGroupConsumer(ClientGroupWrapper
clientGroupWrapper) throws Exception {
+ if (clientGroupWrapper.started4Broadcast.get() == Boolean.TRUE) {
+ clientGroupWrapper.shutdownBroadCastConsumer();
}
- if
(Objects.requireNonNull(session.getClientGroupWrapper().get()).started4Persistent.get()
== Boolean.TRUE) {
-
Objects.requireNonNull(session.getClientGroupWrapper().get()).shutdownPersistentConsumer();
+ if (clientGroupWrapper.started4Persistent.get() == Boolean.TRUE) {
+ clientGroupWrapper.shutdownPersistentConsumer();
}
}
- private void shutdownClientGroupProducer(Session session) throws Exception
{
- if
(Objects.requireNonNull(session.getClientGroupWrapper().get()).producerStarted.get()
== Boolean.TRUE) {
-
Objects.requireNonNull(session.getClientGroupWrapper().get()).shutdownProducer();
+ private void shutdownClientGroupProducer(ClientGroupWrapper
clientGroupWrapper) throws Exception {
+ if (clientGroupWrapper.producerStarted.get() == Boolean.TRUE) {
+ clientGroupWrapper.shutdownProducer();
}
}
private void initSessionCleaner() {
eventMeshTCPServer.getScheduler().scheduleAtFixedRate(
- new Runnable() {
- @Override
- public void run() {
- for (Session tmp : sessionTable.values()) {
- if (System.currentTimeMillis() -
tmp.getLastHeartbeatTime()
- >
eventMeshTCPServer.getEventMeshTCPConfiguration().eventMeshTcpSessionExpiredInMills)
{
- try {
- log.warn("clean expired
session,client:{}", tmp.getClient());
- closeSession(tmp.getContext());
- } catch (Exception e) {
- log.error("say goodbye to session error!
{}", tmp, e);
- }
- }
+ () -> {
+ for (Session tmp : sessionTable.values()) {
+ if (System.currentTimeMillis() - tmp.getLastHeartbeatTime()
+ >
eventMeshTCPServer.getEventMeshTCPConfiguration().eventMeshTcpSessionExpiredInMills)
{
+ try {
+ log.warn("clean expired session,client:{}",
tmp.getClient());
+ closeSession(tmp.getContext());
+ } catch (Exception e) {
+ log.error("say goodbye to session error! {}", tmp,
e);
Review Comment:
What is the variable num?
What's wrong with this log method?
<img width="1219" alt="image"
src="https://user-images.githubusercontent.com/42484192/210234227-6ae5985c-121a-4828-a1de-0c10009a54d9.png">
<img width="1178" alt="image"
src="https://user-images.githubusercontent.com/42484192/210234439-c78d2a80-473d-472d-a07b-fee8e99eaa6b.png">
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]