Skip to content

Commit 2248f7c

Browse files
authored
feat: Add a debug HTTP interface. (#860)
* feat: Add a debug HTTP interface.
1 parent c81ec67 commit 2248f7c

25 files changed

+415
-3
lines changed

src/main/java/org/jitsi/impl/protocol/xmpp/ChatMemberImpl.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
*/
1818
package org.jitsi.impl.protocol.xmpp;
1919

20+
import org.jetbrains.annotations.*;
2021
import org.jitsi.jicofo.xmpp.*;
2122
import org.jitsi.jicofo.xmpp.muc.*;
23+
import org.jitsi.utils.*;
2224
import org.jitsi.utils.logging2.*;
2325
import org.jitsi.xmpp.extensions.jitsimeet.*;
2426

@@ -43,6 +45,7 @@ public class ChatMemberImpl
4345
/**
4446
* The resource part of this {@link ChatMemberImpl}'s JID in the MUC.
4547
*/
48+
@NotNull
4649
private final Resourcepart resourcepart;
4750

4851
/**
@@ -65,6 +68,7 @@ public class ChatMemberImpl
6568
* Full MUC address:
6669
* [email protected]/nickname
6770
*/
71+
@NotNull
6872
private final EntityFullJid occupantJid;
6973

7074
/**
@@ -368,4 +372,24 @@ public String toString()
368372
{
369373
return String.format("ChatMember[%s, jid: %s]@%s", occupantJid, jid, hashCode());
370374
}
375+
376+
@NotNull
377+
public OrderedJsonObject getDebugState()
378+
{
379+
OrderedJsonObject o = new OrderedJsonObject();
380+
o.put("resourcepart", resourcepart.toString());
381+
o.put("region", String.valueOf(region));
382+
o.put("join_order_number", joinOrderNumber);
383+
o.put("occupant_jid", occupantJid.toString());
384+
o.put("jid", String.valueOf(jid));
385+
o.put("robot", robot);
386+
o.put("is_jibri", isJibri);
387+
o.put("is_jigasi", isJigasi);
388+
o.put("role", String.valueOf(role));
389+
o.put("stats_id", String.valueOf(statsId));
390+
o.put("is_audio_muted", isAudioMuted);
391+
o.put("is_video_muted", isVideoMuted);
392+
393+
return o;
394+
}
371395
}

src/main/java/org/jitsi/impl/protocol/xmpp/ChatRoom.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,4 +208,7 @@ void join()
208208
* @return The main room JID as a string.
209209
*/
210210
String getMainRoom();
211+
212+
@NotNull
213+
OrderedJsonObject getDebugState();
211214
}

src/main/java/org/jitsi/impl/protocol/xmpp/ChatRoomImpl.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import org.jxmpp.stringprep.*;
4141

4242
import java.util.*;
43-
import java.util.concurrent.*;
4443
import java.util.function.*;
4544

4645
/**
@@ -64,6 +63,7 @@ public class ChatRoomImpl
6463
/**
6564
* The room JID (e.g. "room@service").
6665
*/
66+
@NotNull
6767
private final EntityBareJid roomJid;
6868

6969
/**
@@ -929,6 +929,29 @@ public boolean isMemberAllowedToUnmute(Jid jid, MediaType mediaType)
929929
return whitelist != null && whitelist.contains(jid.toString());
930930
}
931931

932+
@Override
933+
@NotNull
934+
public OrderedJsonObject getDebugState()
935+
{
936+
OrderedJsonObject o = new OrderedJsonObject();
937+
o.put("room_jid", roomJid.toString());
938+
o.put("my_occupant_jid", String.valueOf(myOccupantJid));
939+
OrderedJsonObject membersJson = new OrderedJsonObject();
940+
for (ChatMemberImpl m : members.values())
941+
{
942+
membersJson.put(m.getJid(), m.getDebugState());
943+
}
944+
o.put("members", membersJson);
945+
o.put("role", String.valueOf(role));
946+
o.put("meeting_id", String.valueOf(meetingId));
947+
o.put("is_breakout_room", isBreakoutRoom);
948+
o.put("main_room", String.valueOf(mainRoom));
949+
o.put("num_audio_senders", numAudioSenders);
950+
o.put("num_video_senders", numVideoSenders);
951+
952+
return o;
953+
}
954+
932955
class MemberListener implements ParticipantStatusListener
933956
{
934957
@Override

src/main/java/org/jitsi/jicofo/FocusManager.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.jitsi.jicofo.conference.*;
2222
import org.jitsi.jicofo.jibri.*;
2323
import org.jitsi.jicofo.stats.*;
24+
import org.jitsi.utils.*;
2425
import org.jitsi.utils.logging2.*;
2526
import org.jitsi.utils.logging2.Logger;
2627
import org.jitsi.utils.queue.*;
@@ -531,6 +532,24 @@ public boolean isJicofoIdConfigured()
531532
return octoId != 0;
532533
}
533534

535+
@NotNull
536+
OrderedJsonObject getDebugState(boolean full)
537+
{
538+
OrderedJsonObject o = new OrderedJsonObject();
539+
for (JitsiMeetConference conference : getConferences())
540+
{
541+
if (full)
542+
{
543+
o.put(conference.getRoomName().toString(), conference.getDebugState());
544+
}
545+
else
546+
{
547+
o.put(conference.getRoomName().toString(), conference.getParticipantCount());
548+
}
549+
550+
}
551+
return o;
552+
}
534553
/**
535554
* Takes care of stopping {@link JitsiMeetConference} if no participant ever joins.
536555
*

src/main/java/org/jitsi/jicofo/JitsiMeetConfig.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
*/
1818
package org.jitsi.jicofo;
1919

20+
import org.jetbrains.annotations.*;
21+
import org.jitsi.utils.*;
2022
import org.jitsi.utils.logging2.*;
2123

2224
import java.util.*;
@@ -202,4 +204,20 @@ public int getOpusMaxAverageBitrate()
202204
Integer maxAvgBitrate = getInt(PNAME_OPUS_MAX_AVG_BITRATE);
203205
return maxAvgBitrate == null ? -1 : maxAvgBitrate;
204206
}
207+
208+
@NotNull
209+
public OrderedJsonObject getDebugState()
210+
{
211+
OrderedJsonObject o = new OrderedJsonObject();
212+
o.put("start_audio_muted", String.valueOf(getStartAudioMuted()));
213+
o.put("start_video_muted", String.valueOf(getStartVideoMuted()));
214+
o.put("rtcstats_enabled", getRtcStatsEnabled());
215+
o.put("callstats_enabled", getCallStatsEnabled());
216+
o.put("min_bitrate", getMinBitrate());
217+
o.put("start_bitrate", getStartBitrate());
218+
o.put("stereo_enabled", stereoEnabled());
219+
o.put("opus_max_average_bitrate", getOpusMaxAverageBitrate());
220+
221+
return o;
222+
}
205223
}

src/main/java/org/jitsi/jicofo/bridge/Bridge.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import edu.umd.cs.findbugs.annotations.*;
2121
import org.jitsi.jicofo.xmpp.*;
22+
import org.jitsi.utils.*;
2223
import org.jitsi.utils.stats.*;
2324
import org.jitsi.xmpp.extensions.colibri.*;
2425
import org.jxmpp.jid.*;
@@ -387,4 +388,20 @@ public boolean isInGracefulShutdown()
387388
{
388389
return shutdownInProgress;
389390
}
391+
392+
@NonNull
393+
public OrderedJsonObject getDebugState()
394+
{
395+
OrderedJsonObject o = new OrderedJsonObject();
396+
o.put("version", String.valueOf(version));
397+
o.put("stress", getStress());
398+
o.put("operational", isOperational());
399+
o.put("packet_rate", lastReportedPacketRatePps);
400+
o.put("region", String.valueOf(region));
401+
o.put("graceful-shutdown", isInGracefulShutdown());
402+
o.put("overloaded", isOverloaded());
403+
o.put("relay-id", String.valueOf(relayId));
404+
405+
return o;
406+
}
390407
}

src/main/java/org/jitsi/jicofo/bridge/BridgeSelector.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.jetbrains.annotations.*;
2222
import org.jitsi.jicofo.*;
2323
import org.jitsi.jicofo.conference.*;
24+
import org.jitsi.utils.*;
2425
import org.jitsi.utils.concurrent.*;
2526
import org.jitsi.utils.event.*;
2627
import org.jitsi.xmpp.extensions.colibri.*;
@@ -350,6 +351,20 @@ public void removeHandler(EventHandler eventHandler)
350351
eventEmitter.removeHandler(eventHandler);
351352
}
352353

354+
@NotNull
355+
public OrderedJsonObject getDebugState()
356+
{
357+
OrderedJsonObject o = new OrderedJsonObject();
358+
o.put("strategy", bridgeSelectionStrategy.getClass().getSimpleName());
359+
OrderedJsonObject bridgesJson = new OrderedJsonObject();
360+
for (Bridge b : bridges.values())
361+
{
362+
bridgesJson.put(b.getJid().toString(), b.getDebugState());
363+
}
364+
o.put("bridges", bridgesJson);
365+
return o;
366+
}
367+
353368
public interface EventHandler
354369
{
355370
void bridgeRemoved(Bridge bridge);

src/main/java/org/jitsi/jicofo/conference/JitsiMeetConference.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.jitsi.jicofo.xmpp.muc.*;
2626
import org.jitsi.utils.*;
2727
import org.jitsi.xmpp.extensions.jibri.*;
28+
import org.json.simple.*;
2829
import org.jxmpp.jid.*;
2930

3031
import java.util.*;
@@ -126,4 +127,7 @@ MuteResult handleMuteRequest(
126127
Jid toBeMutedJid,
127128
boolean doMute,
128129
MediaType mediaType);
130+
131+
@NotNull
132+
OrderedJsonObject getDebugState();
129133
}

src/main/java/org/jitsi/jicofo/conference/JitsiMeetConferenceImpl.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,6 +1575,48 @@ else if (!participant.hasModeratorRights()
15751575
return colibriSessionManager.mute(participant, doMute, mediaType) ? MuteResult.SUCCESS : MuteResult.ERROR;
15761576
}
15771577

1578+
@Override
1579+
@NotNull
1580+
public OrderedJsonObject getDebugState()
1581+
{
1582+
OrderedJsonObject o = new OrderedJsonObject();
1583+
o.put("name", roomName.toString());
1584+
o.put("config", config.getDebugState());
1585+
ChatRoom chatRoom = this.chatRoom;
1586+
o.put("chat_room", chatRoom == null ? "null" : chatRoom.getDebugState());
1587+
OrderedJsonObject participantsJson = new OrderedJsonObject();
1588+
for (Participant participant : participants)
1589+
{
1590+
participantsJson.put(participant.getEndpointId(), participant.getDebugState());
1591+
}
1592+
o.put("participants", participantsJson);
1593+
//o.put("jibri_recorder", jibriRecorder.getDebugState());
1594+
//o.put("jibri_sip_gateway", jibriSipGateway.getDebugState());
1595+
//o.put("transcriber_manager", transcriberManager.getDebugState());
1596+
ChatRoomRoleManager chatRoomRoleManager = this.chatRoomRoleManager;
1597+
o.put("chat_room_role_manager", chatRoomRoleManager == null ? "null" : chatRoomRoleManager.getDebugState());
1598+
o.put("started", started.get());
1599+
o.put("creation_time", creationTime.toString());
1600+
o.put("has_had_at_least_one_participant", hasHadAtLeastOneParticipant);
1601+
o.put("start_audio_muted", startAudioMuted);
1602+
o.put("start_video_muted", startVideoMuted);
1603+
o.put("colibri_session_manager", colibriSessionManager.getDebugState());
1604+
OrderedJsonObject conferencePropertiesJson = new OrderedJsonObject();
1605+
for (ConferenceProperties.ConferenceProperty conferenceProperty : conferenceProperties.getProperties())
1606+
{
1607+
conferencePropertiesJson.put(conferenceProperty.getKey(), conferenceProperty.getValue());
1608+
}
1609+
o.put("conference_properties", conferencePropertiesJson);
1610+
o.put("include_in_statistics", includeInStatistics);
1611+
o.put("conference_sources", conferenceSources.toJson());
1612+
o.put("audio_limit_reached", audioLimitReached);
1613+
o.put("video_limit_reached", videoLimitReached);
1614+
o.put("gid", gid);
1615+
1616+
1617+
return o;
1618+
}
1619+
15781620
/**
15791621
* Mutes all participants (except jibri or jigasi without "audioMute" support). Will block for colibri responses.
15801622
*/

src/main/java/org/jitsi/jicofo/conference/Participant.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,4 +607,15 @@ public String toString()
607607
return "Participant[" + getMucJid() + "]@" + hashCode();
608608
}
609609

610+
@NotNull
611+
public OrderedJsonObject getDebugState()
612+
{
613+
OrderedJsonObject o = new OrderedJsonObject();
614+
o.put("id", getEndpointId());
615+
o.put("remote_sources_queue", remoteSourcesQueue.getDebugState());
616+
o.put("invite_runnable", inviteRunnable != null ? "Running" : "Not running");
617+
//o.put("room_member", roomMember.getDebugState());
618+
o.put("jingle_session", jingleSession == null ? "null" : "not null");
619+
return o;
620+
}
610621
}

0 commit comments

Comments
 (0)