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

Use JitsiXmppStringprep, update smack #2127

Merged
merged 9 commits into from
Apr 29, 2024
65 changes: 0 additions & 65 deletions jvb/src/main/java/org/jitsi/videobridge/Videobridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,13 @@
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.*;
import org.jitsi.health.Result;
import org.jitsi.nlj.*;
import org.jitsi.shutdown.*;
import org.jitsi.utils.*;
import org.jitsi.utils.logging2.*;
import org.jitsi.utils.queue.*;
import org.jitsi.utils.version.*;
import org.jitsi.videobridge.health.*;
import org.jitsi.videobridge.load_management.*;
import org.jitsi.videobridge.metrics.*;
import org.jitsi.videobridge.relay.*;
import org.jitsi.videobridge.shutdown.*;
import org.jitsi.videobridge.stats.*;
import org.jitsi.videobridge.util.*;
Expand Down Expand Up @@ -562,68 +559,6 @@ public OrderedJsonObject getDebugState(String conferenceId, String endpointId, b
return debugState;
}

/**
* Gets statistics for the different {@code PacketQueue}s that this bridge
* uses.
* TODO: is there a better place for this?
*/
@SuppressWarnings("unchecked")
public JSONObject getQueueStats()
{
JSONObject queueStats = new JSONObject();

queueStats.put(
"srtp_send_queue",
getJsonFromQueueStatisticsAndErrorHandler(Endpoint.queueErrorCounter,
"Endpoint-outgoing-packet-queue"));
queueStats.put(
"relay_srtp_send_queue",
getJsonFromQueueStatisticsAndErrorHandler(Relay.queueErrorCounter,
"Relay-outgoing-packet-queue"));
queueStats.put(
"relay_endpoint_sender_srtp_send_queue",
getJsonFromQueueStatisticsAndErrorHandler(RelayEndpointSender.queueErrorCounter,
"RelayEndpointSender-outgoing-packet-queue"));
queueStats.put(
"rtp_receiver_queue",
getJsonFromQueueStatisticsAndErrorHandler(RtpReceiverImpl.Companion.getQueueErrorCounter(),
"rtp-receiver-incoming-packet-queue"));
queueStats.put(
"rtp_sender_queue",
getJsonFromQueueStatisticsAndErrorHandler(RtpSenderImpl.Companion.getQueueErrorCounter(),
"rtp-sender-incoming-packet-queue"));
queueStats.put(
"colibri_queue",
QueueStatistics.Companion.getStatistics().get("colibri-queue")
);

queueStats.put(
AbstractEndpointMessageTransport.INCOMING_MESSAGE_QUEUE_ID,
getJsonFromQueueStatisticsAndErrorHandler(
null,
AbstractEndpointMessageTransport.INCOMING_MESSAGE_QUEUE_ID));

return queueStats;
}

private OrderedJsonObject getJsonFromQueueStatisticsAndErrorHandler(
CountingErrorHandler countingErrorHandler,
String queueName)
{
OrderedJsonObject json = (OrderedJsonObject)QueueStatistics.Companion.getStatistics().get(queueName);
if (countingErrorHandler != null)
{
if (json == null)
{
json = new OrderedJsonObject();
json.put("dropped_packets", countingErrorHandler.getNumPacketsDropped());
}
json.put("exceptions", countingErrorHandler.getNumExceptions());
}

return json;
}

@NotNull
public Version getVersion()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ public String getJvbFeatureStats(@PathParam("feature") DebugFeatures feature)
return ByteBufferPool.getStatsJson().toJSONString();
}
case QUEUE_STATS: {
return videobridge.getQueueStats().toJSONString();
return QueueStats.getQueueStats().toJSONString();
}
case TRANSIT_STATS: {
return PacketTransitStats.getStatsJson().toJSONString();
Expand Down
80 changes: 80 additions & 0 deletions jvb/src/main/kotlin/org/jitsi/videobridge/stats/QueueStats.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* Copyright @ 2024 - present 8x8, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jitsi.videobridge.stats

import org.jitsi.nlj.RtpReceiverImpl
import org.jitsi.nlj.RtpSenderImpl
import org.jitsi.utils.OrderedJsonObject
import org.jitsi.utils.queue.CountingErrorHandler
import org.jitsi.utils.queue.QueueStatistics.Companion.getStatistics
import org.jitsi.videobridge.AbstractEndpointMessageTransport
import org.jitsi.videobridge.Endpoint
import org.jitsi.videobridge.relay.Relay
import org.jitsi.videobridge.relay.RelayEndpointSender
import org.json.simple.JSONObject

object QueueStats {
/**
* Gets statistics for the different `PacketQueue`s that this bridge
* uses.
* TODO: is there a better place for this?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you've answered this TODO?

*/
@JvmStatic
fun getQueueStats() = JSONObject().apply {
this["srtp_send_queue"] = getJsonFromQueueStatisticsAndErrorHandler(
Endpoint.queueErrorCounter,
"Endpoint-outgoing-packet-queue"
)
this["relay_srtp_send_queue"] = getJsonFromQueueStatisticsAndErrorHandler(
Relay.queueErrorCounter,
"Relay-outgoing-packet-queue"
)
this["relay_endpoint_sender_srtp_send_queue"] = getJsonFromQueueStatisticsAndErrorHandler(
RelayEndpointSender.queueErrorCounter,
"RelayEndpointSender-outgoing-packet-queue"
)
this["rtp_receiver_queue"] = getJsonFromQueueStatisticsAndErrorHandler(
RtpReceiverImpl.queueErrorCounter,
"rtp-receiver-incoming-packet-queue"
)
this["rtp_sender_queue"] = getJsonFromQueueStatisticsAndErrorHandler(
RtpSenderImpl.queueErrorCounter,
"rtp-sender-incoming-packet-queue"
)
this["colibri_queue"] = getStatistics()["colibri-queue"]
this[AbstractEndpointMessageTransport.INCOMING_MESSAGE_QUEUE_ID] =
getJsonFromQueueStatisticsAndErrorHandler(
null,
AbstractEndpointMessageTransport.INCOMING_MESSAGE_QUEUE_ID
)
}

private fun getJsonFromQueueStatisticsAndErrorHandler(
countingErrorHandler: CountingErrorHandler?,
queueName: String
): OrderedJsonObject? {
var json = getStatistics()[queueName] as OrderedJsonObject?
if (countingErrorHandler != null) {
if (json == null) {
json = OrderedJsonObject()
json["dropped_packets"] = countingErrorHandler.numPacketsDropped
}
json["exceptions"] = countingErrorHandler.numExceptions
}

return json
}
}