NetworkSummaryEvent .java

net.minecraft.util.profiling.jfr.event.NetworkSummaryEvent (class, 86 lines): members: SumAggregation, receivedBytes, sentBytes, receivedPackets, Fields.

net.minecraft.util.profiling.jfr.eventclass86 linescommonextends Event2.5 KB

API Surface (3)

void trackSentPacket(final int size)
void trackReceivedPacket(final int size)
void commitEvent()

Fields & Constants (7)

EVENT_NAME
TYPE
remoteAddress
sentBytes
sentPackets
receivedBytes
receivedPackets

String literals (14)

"minecraft.NetworkSummary"
"Network Summary"
"Minecraft"
"Network"
"remoteAddress"
"Remote Address"
"sentBytes"
"Sent Bytes"
"sentPackets"
"Sent Packets"
"receivedBytes"
"Received Bytes"
"receivedPackets"
"Received Packets"

Full Source

NetworkSummaryEvent.java86 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.util.profiling.jfr.event;
2
3
import java.util.concurrent.atomic.AtomicInteger;
4
import java.util.concurrent.atomic.AtomicLong;
5
import jdk.jfr.Category;
6
import jdk.jfr.DataAmount;
7
import jdk.jfr.Event;
8
import jdk.jfr.EventType;
9
import jdk.jfr.Label;
10
import jdk.jfr.Name;
11
import jdk.jfr.Period;
12
import jdk.jfr.StackTrace;
13
14
@Name("minecraft.NetworkSummary")
15
@Label("Network Summary")
16
@Category({"Minecraft", "Network"})
17
@StackTrace(false)
18
@Period("10 s")
19
public class NetworkSummaryEvent extends Event {
20
	public static final String EVENT_NAME = "minecraft.NetworkSummary";
21
	public static final EventType TYPE = EventType.getEventType(NetworkSummaryEvent.class);
22
	@Name("remoteAddress")
23
	@Label("Remote Address")
24
	public final String remoteAddress;
25
	@Name("sentBytes")
26
	@Label("Sent Bytes")
27
	@DataAmount
28
	public long sentBytes;
29
	@Name("sentPackets")
30
	@Label("Sent Packets")
31
	public int sentPackets;
32
	@Name("receivedBytes")
33
	@Label("Received Bytes")
34
	@DataAmount
35
	public long receivedBytes;
36
	@Name("receivedPackets")
37
	@Label("Received Packets")
38
	public int receivedPackets;
39
40
	public NetworkSummaryEvent(final String remoteAddress) {
41
		this.remoteAddress = remoteAddress;
42
	}
43
44
	public static final class Fields {
45
		public static final String REMOTE_ADDRESS = "remoteAddress";
46
		public static final String SENT_BYTES = "sentBytes";
47
		private static final String SENT_PACKETS = "sentPackets";
48
		public static final String RECEIVED_BYTES = "receivedBytes";
49
		private static final String RECEIVED_PACKETS = "receivedPackets";
50
51
		private Fields() {
52
		}
53
	}
54
55
	public static final class SumAggregation {
56
		private final AtomicLong sentBytes = new AtomicLong();
57
		private final AtomicInteger sentPackets = new AtomicInteger();
58
		private final AtomicLong receivedBytes = new AtomicLong();
59
		private final AtomicInteger receivedPackets = new AtomicInteger();
60
		private final NetworkSummaryEvent event;
61
62
		public SumAggregation(final String remoteAddress) {
63
			this.event = new NetworkSummaryEvent(remoteAddress);
64
			this.event.begin();
65
		}
66
67
		public void trackSentPacket(final int size) {
68
			this.sentPackets.incrementAndGet();
69
			this.sentBytes.addAndGet(size);
70
		}
71
72
		public void trackReceivedPacket(final int size) {
73
			this.receivedPackets.incrementAndGet();
74
			this.receivedBytes.addAndGet(size);
75
		}
76
77
		public void commitEvent() {
78
			this.event.sentBytes = this.sentBytes.get();
79
			this.event.sentPackets = this.sentPackets.get();
80
			this.event.receivedBytes = this.receivedBytes.get();
81
			this.event.receivedPackets = this.receivedPackets.get();
82
			this.event.commit();
83
		}
84
	}
85
}
86

Decompiled Minecraft 26.3 source of NetworkSummaryEvent (net/minecraft/util/profiling/jfr/event/NetworkSummaryEvent.java) with Mojang official mappings, stored verbatim on the site.