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

Improved number pattern in logs #396

Merged
merged 1 commit into from
Oct 8, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public FailureDetectorImpl(
ex ->
LOGGER.log(
Level.ERROR,
"[{0}][{1}][onMessage][error] cause:",
"[{0}][{1,number,#}][onMessage][error] cause:",
localMember,
currentPeriod,
ex)),
Expand All @@ -102,7 +102,7 @@ public FailureDetectorImpl(
ex ->
LOGGER.log(
Level.ERROR,
"[{0}][{1}][onMembershipEvent][error] cause:",
"[{0}][{1,number,#}][onMembershipEvent][error] cause:",
localMember,
currentPeriod,
ex))));
Expand Down Expand Up @@ -148,7 +148,8 @@ private void doPing() {
PingData pingData = new PingData(localMember, pingMember);
Message pingMsg = Message.withData(pingData).qualifier(PING).correlationId(cid).build();

LOGGER.log(Level.DEBUG, "[{0}][{1}] Send Ping to {2}", localMember, period, pingMember);
LOGGER.log(
Level.DEBUG, "[{0}][{1,number,#}] Send Ping to {2}", localMember, period, pingMember);
String address = pingMember.address();
transport
.requestResponse(address, pingMsg)
Expand All @@ -158,7 +159,7 @@ private void doPing() {
message -> {
LOGGER.log(
Level.DEBUG,
"[{0}][{1}] Received PingAck from {2}",
"[{0}][{1,number,#}] Received PingAck from {2}",
localMember,
period,
message.sender());
Expand All @@ -167,7 +168,7 @@ private void doPing() {
ex -> {
LOGGER.log(
Level.DEBUG,
"[{0}][{1}] Failed to get PingAck from {2} within {3} ms",
"[{0}][{1,number,#}] Failed to get PingAck from {2} within {3} ms",
localMember,
period,
pingMember,
Expand All @@ -177,7 +178,8 @@ private void doPing() {
final List<Member> pingReqMembers = selectPingReqMembers(pingMember);

if (timeLeft <= 0 || pingReqMembers.isEmpty()) {
LOGGER.log(Level.DEBUG, "[{0}][{1}] No PingReq occurred", localMember, period);
LOGGER.log(
Level.DEBUG, "[{0}][{1,number,#}] No PingReq occurred", localMember, period);
publishPingResult(period, pingMember, MemberStatus.SUSPECT);
} else {
doPingReq(currentPeriod, pingMember, pingReqMembers, cid);
Expand All @@ -194,7 +196,7 @@ private void doPingReq(
.build();
LOGGER.log(
Level.DEBUG,
"[{0}][{1}] Send PingReq to {2} for {3}",
"[{0}][{1,number,#}] Send PingReq to {2} for {3}",
localMember,
period,
pingReqMembers,
Expand All @@ -211,7 +213,7 @@ private void doPingReq(
message -> {
LOGGER.log(
Level.DEBUG,
"[{0}][{1}] Received transit PingAck from {2} to {3}",
"[{0}][{1,number,#}] Received transit PingAck from {2} to {3}",
localMember,
period,
message.sender(),
Expand All @@ -221,8 +223,9 @@ private void doPingReq(
throwable -> {
LOGGER.log(
Level.DEBUG,
"[{0}][{1}] "
+ "Timeout getting transit PingAck from {2} to {3} within {4} ms",
"[{0}][{1,number,#}] "
+ "Timeout getting transit "
+ "PingAck from {2} to {3} within {4,number,#}ms",
localMember,
period,
member,
Expand Down Expand Up @@ -250,13 +253,14 @@ private void onMessage(Message message) {
private void onPing(Message message) {
long period = this.currentPeriod;
String sender = message.sender();
LOGGER.log(Level.DEBUG, "[{0}][{1}] Received Ping from {2}", localMember, period, sender);
LOGGER.log(
Level.DEBUG, "[{0}][{1,number,#}] Received Ping from {2}", localMember, period, sender);
PingData data = message.data();
data = data.withAckType(AckType.DEST_OK);
if (!data.getTo().id().equals(localMember.id())) {
LOGGER.log(
Level.DEBUG,
"[{0}][{1}] Received Ping from {2} to {3}, but local member is {4}",
"[{0}][{1,number,#}] Received Ping from {2} to {3}, but local member is {4}",
localMember,
period,
sender,
Expand All @@ -268,15 +272,16 @@ private void onPing(Message message) {
Message ackMessage =
Message.withData(data).qualifier(PING_ACK).correlationId(correlationId).build();
String address = data.getFrom().address();
LOGGER.log(Level.DEBUG, "[{0}][{1}] Send PingAck to {2}", localMember, period, address);
LOGGER.log(
Level.DEBUG, "[{0}][{1,number,#}] Send PingAck to {2}", localMember, period, address);
transport
.send(address, ackMessage)
.subscribe(
null,
ex ->
LOGGER.log(
Level.DEBUG,
"[{0}][{1}] Failed to send PingAck to {2}, cause: {3}",
"[{0}][{1,number,#}] Failed to send PingAck to {2}, cause: {3}",
localMember,
period,
address,
Expand All @@ -287,7 +292,11 @@ private void onPing(Message message) {
private void onPingReq(Message message) {
long period = this.currentPeriod;
LOGGER.log(
Level.DEBUG, "[{0}][{1}] Received PingReq from {2}", localMember, period, message.sender());
Level.DEBUG,
"[{0}][{1,number,#}] Received PingReq from {2}",
localMember,
period,
message.sender());
PingData data = message.data();
Member target = data.getTo();
Member originalIssuer = data.getFrom();
Expand All @@ -296,15 +305,16 @@ private void onPingReq(Message message) {
Message pingMessage =
Message.withData(pingReqData).qualifier(PING).correlationId(correlationId).build();
String address = target.address();
LOGGER.log(Level.DEBUG, "[{0}][{1}] Send transit Ping to {2}", localMember, period, address);
LOGGER.log(
Level.DEBUG, "[{0}][{1,number,#}] Send transit Ping to {2}", localMember, period, address);
transport
.send(address, pingMessage)
.subscribe(
null,
ex ->
LOGGER.log(
Level.DEBUG,
"[{0}][{1}] Failed to send transit Ping to {2}, cause: {3}",
"[{0}][{1,number,#}] Failed to send transit Ping to {2}, cause: {3}",
localMember,
period,
address,
Expand All @@ -319,7 +329,7 @@ private void onTransitPingAck(Message message) {
long period = this.currentPeriod;
LOGGER.log(
Level.DEBUG,
"[{0}][{1}] Received transit PingAck from {2}",
"[{0}][{1,number,#}] Received transit PingAck from {2}",
localMember,
period,
message.sender());
Expand All @@ -332,15 +342,19 @@ private void onTransitPingAck(Message message) {
Message.withData(originalAckData).qualifier(PING_ACK).correlationId(correlationId).build();
String address = target.address();
LOGGER.log(
Level.DEBUG, "[{0}][{1}] Resend transit PingAck to {2}", localMember, period, address);
Level.DEBUG,
"[{0}][{1,number,#}] Resend transit PingAck to {2}",
localMember,
period,
address);
transport
.send(address, originalAckMessage)
.subscribe(
null,
ex ->
LOGGER.log(
Level.DEBUG,
"[{0}][{1}] Failed to resend transit PingAck to {2}, cause: {3}",
"[{0}][{1,number,#}] Failed to resend transit PingAck to {2}, cause: {3}",
localMember,
period,
address,
Expand All @@ -354,7 +368,7 @@ private void onMembershipEvent(MembershipEvent event) {
if (removed) {
LOGGER.log(
Level.DEBUG,
"[{0}][{1}] Removed {2} from pingMembers list (size={3})",
"[{0}][{1,number,#}] Removed {2} from pingMembers list (size={3})",
localMember,
currentPeriod,
member,
Expand All @@ -368,7 +382,7 @@ private void onMembershipEvent(MembershipEvent event) {
pingMembers.add(index, member);
LOGGER.log(
Level.DEBUG,
"[{0}][{1}] Added {2} to pingMembers list (size={3})",
"[{0}][{1,number,#}] Added {2} to pingMembers list (size={3})",
localMember,
currentPeriod,
member,
Expand Down Expand Up @@ -407,7 +421,12 @@ private List<Member> selectPingReqMembers(Member pingMember) {

private void publishPingResult(long period, Member member, MemberStatus status) {
LOGGER.log(
Level.DEBUG, "[{0}][{1}] Member {2} detected as {3}", localMember, period, member, status);
Level.DEBUG,
"[{0}][{1,number,#}] Member {2} detected as {3}",
localMember,
period,
member,
status);
sink.emitNext(new FailureDetectorEvent(member, status), busyLooping(Duration.ofSeconds(3)));
}

Expand All @@ -430,7 +449,7 @@ private MemberStatus computeMemberStatus(Message message, long period) {
default:
LOGGER.log(
Level.WARNING,
"[{0}][{1}] Unknown PingData.AckType received: {2}",
"[{0}][{1,number,#}] Unknown PingData.AckType received: {2}",
localMember,
period,
ackType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,11 @@ private void doSpreadGossip() {
Set<String> gossipsToRemove = getGossipsToRemove(period);
if (!gossipsToRemove.isEmpty()) {
LOGGER.log(
Level.DEBUG, "[{0}][{1}] Sweep gossips: {2}", localMember, period, gossipsToRemove);
Level.DEBUG,
"[{0}][{1,number,#}] Sweep gossips: {2}",
localMember,
period,
gossipsToRemove);
for (String gossipId : gossipsToRemove) {
gossips.remove(gossipId);
}
Expand All @@ -180,7 +184,7 @@ private void doSpreadGossip() {
if (!gossipsThatSpread.isEmpty()) {
LOGGER.log(
Level.DEBUG,
"[{0}][{1}] Most likely disseminated gossips: {2}",
"[{0}][{1,number,#}] Most likely disseminated gossips: {2}",
localMember,
period,
gossipsThatSpread);
Expand All @@ -193,7 +197,11 @@ private void doSpreadGossip() {
}
} catch (Exception ex) {
LOGGER.log(
Level.WARNING, "[{0}][{1}][doSpreadGossip] Exception occurred:", localMember, period, ex);
Level.WARNING,
"[{0}][{1,number,#}][doSpreadGossip] Exception occurred:",
localMember,
period,
ex);
}
}

Expand Down Expand Up @@ -240,7 +248,7 @@ private void checkGossipSegmentation() {
if (sequenceIdCollector.size() > intervalsThreshold) {
LOGGER.log(
Level.WARNING,
"[{0}][{1}] Too many missed gossip messages from original gossiper: {2}, "
"[{0}][{1,number,#}] Too many missed gossip messages from original gossiper: {2}, "
+ "current node({3}) was SUSPECTED much for a long time or connection problem",
localMember,
currentPeriod,
Expand All @@ -260,7 +268,7 @@ private void onMembershipEvent(MembershipEvent event) {
if (removed) {
LOGGER.log(
Level.DEBUG,
"[{0}][{1}] Removed {2} from remoteMembers list (size={3})",
"[{0}][{1,number,#}] Removed {2} from remoteMembers list (size={3,number,#})",
localMember,
currentPeriod,
member,
Expand All @@ -271,7 +279,7 @@ private void onMembershipEvent(MembershipEvent event) {
remoteMembers.add(member);
LOGGER.log(
Level.DEBUG,
"[{0}][{1}] Added {2} to remoteMembers list (size={3})",
"[{0}][{1,number,#}] Added {2} to remoteMembers list (size={3,number,#})",
localMember,
currentPeriod,
member,
Expand Down Expand Up @@ -316,7 +324,8 @@ private void spreadGossipsTo(long period, Member member) {
ex ->
LOGGER.log(
Level.DEBUG,
"[{0}][{1}] Failed to send GossipReq({2}) to {3}, cause: {4}",
"[{0}][{1,number,#}] "
+ "Failed to send GossipReq({2}) to {3}, cause: {4}",
localMember,
period,
message,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ private void scheduleSuspicionTimeoutTask(MembershipRecord r) {
id -> {
LOGGER.log(
Level.DEBUG,
"[{0}] Scheduled SuspicionTimeoutTask for {1}, suspicionTimeout: {2}",
"[{0}] Scheduled SuspicionTimeoutTask for {1}, suspicionTimeout: {2,number,#}ms",
localMember,
id,
suspicionTimeout);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@ public ByteBuffer updateMetadata(Member member, ByteBuffer metadata) {
if (result == null) {
LOGGER.log(
Level.DEBUG,
"[{0}] Added metadata(size={1}) for member {2}",
"[{0}] Added metadata(size={1,number,#}) for member {2}",
localMember,
value.remaining(),
member);
} else {
LOGGER.log(
Level.DEBUG,
"[{0}] Updated metadata(size={1}) for member {2}",
"[{0}] Updated metadata(size={1,number,#}) for member {2}",
localMember,
value.remaining(),
member);
Expand All @@ -142,7 +142,7 @@ public ByteBuffer removeMetadata(Member member) {
if (metadata != null) {
LOGGER.log(
Level.DEBUG,
"[{0}] Removed metadata(size={1}) for member {2}",
"[{0}] Removed metadata(size={1,number,#}) for member {2}",
localMember,
metadata.remaining(),
member);
Expand Down Expand Up @@ -187,7 +187,7 @@ public Mono<ByteBuffer> fetchMetadata(Member member) {
LOGGER.log(
Level.WARNING,
"[{0}][{1}] Timeout getting GetMetadataResp "
+ "from {2} within {3} ms, cause: {4}",
+ "from {2} within {3,number,#}ms, cause: {4}",
localMember,
cid,
targetAddress,
Expand Down
Loading