use of com.biglybt.pif.network.OutgoingMessageQueue in project BiglyBT by BiglySoftware.
the class PEPeerControlImpl method updateStats.
private void updateStats() {
if ((mainloop_loop_count % MAINLOOP_ONE_SECOND_INTERVAL) != 0) {
return;
}
stats_tick_count++;
// calculate seeds vs peers
final ArrayList<PEPeerTransport> peer_transports = peer_transports_cow;
int new_pending_tcp_connections = 0;
int new_connecting_tcp_connections = 0;
int new_seeds = 0;
int new_peers = 0;
int new_tcp_incoming = 0;
int new_udp_incoming = 0;
int new_utp_incoming = 0;
int bytes_queued = 0;
int con_queued = 0;
int con_blocked = 0;
int con_unchoked = 0;
for (Iterator<PEPeerTransport> it = peer_transports.iterator(); it.hasNext(); ) {
final PEPeerTransport pc = it.next();
if (pc.getPeerState() == PEPeer.TRANSFERING) {
if (!pc.isChokedByMe()) {
con_unchoked++;
}
Connection connection = pc.getPluginConnection();
if (connection != null) {
OutgoingMessageQueue mq = connection.getOutgoingMessageQueue();
int q = mq.getDataQueuedBytes() + mq.getProtocolQueuedBytes();
bytes_queued += q;
if (q > 0) {
con_queued++;
if (mq.isBlocked()) {
con_blocked++;
}
}
}
if (pc.isSeed())
new_seeds++;
else
new_peers++;
if (pc.isIncoming() && !pc.isLANLocal()) {
if (pc.isTCP()) {
if (pc.getNetwork() == AENetworkClassifier.AT_PUBLIC) {
new_tcp_incoming++;
}
} else {
String protocol = pc.getProtocol();
if (protocol.equals("UDP")) {
new_udp_incoming++;
} else {
new_utp_incoming++;
}
}
}
} else {
if (pc.isTCP()) {
int c_state = pc.getConnectionState();
if (c_state == PEPeerTransport.CONNECTION_PENDING) {
new_pending_tcp_connections++;
} else if (c_state == PEPeerTransport.CONNECTION_CONNECTING) {
new_connecting_tcp_connections++;
}
}
}
}
_seeds = new_seeds;
_peers = new_peers;
_remotesTCPNoLan = new_tcp_incoming;
_remotesUDPNoLan = new_udp_incoming;
_remotesUTPNoLan = new_utp_incoming;
_tcpPendingConnections = new_pending_tcp_connections;
_tcpConnectingConnections = new_connecting_tcp_connections;
bytes_queued_for_upload = bytes_queued;
connections_with_queued_data = con_queued;
connections_with_queued_data_blocked = con_blocked;
connections_unchoked = con_unchoked;
_stats.update(stats_tick_count);
}
Aggregations