From 23a2436af4f387f0440764616dc0e9c640076a26 Mon Sep 17 00:00:00 2001 From: damencho Date: Fri, 27 May 2016 11:54:58 -0500 Subject: [PATCH 1/4] Changes conference id reported to callstats to be the room name. Adds conferenceIDPrefix setting which can add the service name to add as a prefix so it can match the conference id reported by meet client. --- .../eventadmin/callstats/Activator.java | 5 +++ .../CallStatsConferenceStatsHandler.java | 45 ++++++++++++++----- 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/jitsi/videobridge/eventadmin/callstats/Activator.java b/src/main/java/org/jitsi/videobridge/eventadmin/callstats/Activator.java index 573e2f9c47..eee5df4250 100644 --- a/src/main/java/org/jitsi/videobridge/eventadmin/callstats/Activator.java +++ b/src/main/java/org/jitsi/videobridge/eventadmin/callstats/Activator.java @@ -133,11 +133,16 @@ public void serviceChanged(ServiceEvent ev) + "." + StatsManagerBundleActivator.STAT_TRANSPORT_CALLSTATS_IO, interval); + String conferenceIDPrefix = ConfigUtils.getString( + cfg, + "io.callstats.sdk.CallStats.conferenceIDPrefix", + null); conferenceStatsHandler = new CallStatsConferenceStatsHandler(); conferenceStatsHandler.start( (CallStats) service, bridgeId, + conferenceIDPrefix, interval); String[] topics = { "org/jitsi/*" }; diff --git a/src/main/java/org/jitsi/videobridge/eventadmin/callstats/CallStatsConferenceStatsHandler.java b/src/main/java/org/jitsi/videobridge/eventadmin/callstats/CallStatsConferenceStatsHandler.java index 4b769635ba..a2b4f555b8 100644 --- a/src/main/java/org/jitsi/videobridge/eventadmin/callstats/CallStatsConferenceStatsHandler.java +++ b/src/main/java/org/jitsi/videobridge/eventadmin/callstats/CallStatsConferenceStatsHandler.java @@ -61,6 +61,11 @@ class CallStatsConferenceStatsHandler */ private String bridgeId; + /** + * The prefix to use when creating conference ID to report. + */ + private String conferenceIDPrefix; + /** * The {@link RecurringProcessibleExecutor} which periodically invokes * generating and pushing statistics per conference for every Channel. @@ -83,13 +88,24 @@ class CallStatsConferenceStatsHandler /** * Starts the handler with initialized callstats library. - * @param callStats + * @param callStats entry point into the callstats.io (Java) library. + * @param bridgeId the id which identifies the current bridge. + * @param conferenceIDPrefix prefix to use when creating conference IDs. + * @param interval interval to poll for stats and + * to push them to the callstats service. */ - void start(CallStats callStats, String bridgeId, int interval) + void start(CallStats callStats, String bridgeId, + String conferenceIDPrefix, + int interval) { this.callStats = callStats; this.bridgeId = bridgeId; this.interval = interval; + + this.conferenceIDPrefix = conferenceIDPrefix; + if(this.conferenceIDPrefix != null + && !this.conferenceIDPrefix.endsWith("/")) + this.conferenceIDPrefix += "/"; } /** @@ -189,6 +205,11 @@ private class ConferencePeriodicProcessible */ private UserInfo userInfo; + /** + * The conference ID to use when reporting stats. + */ + private final String conferenceID; + /** * Initializes a new {@code ConferencePeriodicProcessible} instance * which is to {@code period}ically generate statistics for the @@ -204,6 +225,10 @@ public ConferencePeriodicProcessible( long period) { super(conference, period); + + this.conferenceID = + (conferenceIDPrefix != null ? conferenceIDPrefix : "") + + conference.getName(); } /** @@ -232,9 +257,7 @@ protected void doProcess() void start() { ConferenceInfo conferenceInfo - = new ConferenceInfo( - o.getID(), - bridgeId); + = new ConferenceInfo(this.conferenceID, bridgeId); // Send setup event to callstats and on successful response create // the userInfo object. @@ -246,7 +269,8 @@ void start() @Override public void onResponse(String ucid) { - userInfo = new UserInfo(o.getID(), bridgeId, ucid); + userInfo + = new UserInfo(conferenceID, bridgeId, ucid); // Successful setup from callstats' perspective. Add // it to statisticsProcessors map and register it // for periodic execution. @@ -304,11 +328,10 @@ private void processChannelStats(RtpChannel channel) Endpoint endpoint = channel.getEndpoint(); String endpointID = (endpoint == null) ? "" : endpoint.getID(); - String conferenceID = channel.getContent().getConference().getID(); callStats.startStatsReportingForUser( endpointID, - conferenceID); + this.conferenceID); // Send stats for received streams. for (MediaStreamSSRCStats receivedStat : stats.getReceivedStats()) @@ -318,7 +341,7 @@ private void processChannelStats(RtpChannel channel) .bytesSent(receivedStat.getNbBytes()) .packetsSent(receivedStat.getNbPackets()) .ssrc(String.valueOf(receivedStat.getSSRC())) - .confID(conferenceID) + .confID(this.conferenceID) .localUserID(bridgeId) .remoteUserID(endpointID) .statsType(CallStatsStreamType.INBOUND) @@ -337,7 +360,7 @@ private void processChannelStats(RtpChannel channel) .bytesSent(sentStat.getNbBytes()) .packetsSent(sentStat.getNbPackets()) .ssrc(String.valueOf(sentStat.getSSRC())) - .confID(conferenceID) + .confID(this.conferenceID) .localUserID(bridgeId) .remoteUserID(endpointID) .statsType(CallStatsStreamType.OUTBOUND) @@ -348,7 +371,7 @@ private void processChannelStats(RtpChannel channel) callStats.reportConferenceStats(endpointID, conferenceStats); } - callStats.stopStatsReportingForUser(endpointID, conferenceID); + callStats.stopStatsReportingForUser(endpointID, this.conferenceID); } } } From b914288e6a09d1cec80eed975e47f45705f1c06d Mon Sep 17 00:00:00 2001 From: damencho Date: Fri, 27 May 2016 15:18:10 -0500 Subject: [PATCH 2/4] Makes available the name of the conference on its creation. --- .../java/org/jitsi/videobridge/Conference.java | 13 +++---------- .../java/org/jitsi/videobridge/Videobridge.java | 17 +++++++++-------- .../org/jitsi/videobridge/health/Health.java | 1 + 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/jitsi/videobridge/Conference.java b/src/main/java/org/jitsi/videobridge/Conference.java index 4192f91e41..742e068661 100644 --- a/src/main/java/org/jitsi/videobridge/Conference.java +++ b/src/main/java/org/jitsi/videobridge/Conference.java @@ -203,6 +203,7 @@ public void onSctpConnectionReady(SctpConnection source) * initialization of the new instance and from whom further/future requests * to manage the new instance must come or they will be ignored. * Pass null to override this safety check. + * @param name world readable name of this instance if any. * @param eventAdmin the {@code EventAdmin} instance to be used by the new * instance and all instances (of {@code Content}, {@code Channel}, etc.) * created by it. @@ -210,6 +211,7 @@ public void onSctpConnectionReady(SctpConnection source) public Conference(Videobridge videobridge, String id, String focus, + String name, EventAdmin eventAdmin) { if (videobridge == null) @@ -221,6 +223,7 @@ public Conference(Videobridge videobridge, this.id = id; this.focus = focus; this.eventAdmin = eventAdmin; + this.name = name; lastKnownFocus = focus; @@ -1673,16 +1676,6 @@ void updateEndpoint(ColibriConferenceIQ.Endpoint colibriEndpoint) } } - /** - * Sets the conference name. - * - * @param name the new name. - */ - public void setName(String name) - { - this.name = name; - } - /** * Gets the conference name. * diff --git a/src/main/java/org/jitsi/videobridge/Videobridge.java b/src/main/java/org/jitsi/videobridge/Videobridge.java index fe9b80874e..3548b3caa0 100644 --- a/src/main/java/org/jitsi/videobridge/Videobridge.java +++ b/src/main/java/org/jitsi/videobridge/Videobridge.java @@ -221,12 +221,13 @@ public Videobridge() * the conference focus which will own the new instance i.e. from whom * further/future requests to manage the new instance must come or they will * be ignored. Pass null to override this safety check. + * @param name world readable name of the conference to create. * @return a new Conference instance with an ID unique to the * Conference instances listed by this Videobridge */ - public Conference createConference(String focus) + public Conference createConference(String focus, String name) { - return this.createConference(focus, /* eventadmin */ true); + return this.createConference(focus, name, /* eventadmin */ true); } /** @@ -242,13 +243,15 @@ public Conference createConference(String focus) * the conference focus which will own the new instance i.e. from whom * further/future requests to manage the new instance must come or they will * be ignored. Pass null to override this safety check. + * @param name world readable name of the conference to create. * @param eventadmin {@code true} to enable support for the * {@code eventadmin} package i.e. fire {@code Event}s through * {@code EventAdmin}; otherwise, {@code false} * @return a new Conference instance with an ID unique to the * Conference instances listed by this Videobridge */ - public Conference createConference(String focus, boolean eventadmin) + public Conference createConference( + String focus, String name, boolean eventadmin) { Conference conference = null; @@ -265,6 +268,7 @@ public Conference createConference(String focus, boolean eventadmin) this, id, focus, + name, eventadmin ? getEventAdmin() : null); conferences.put(id, conference); } @@ -640,7 +644,8 @@ else if (authorizedSourcePattern != null { if (!isShutdownInProgress()) { - conference = createConference(focus); + conference + = createConference(focus, conferenceIQ.getName()); } else { @@ -671,10 +676,6 @@ else if (authorizedSourcePattern != null } else { - String name = conferenceIQ.getName(); - if (name != null) - conference.setName(name); - responseConferenceIQ = new ColibriConferenceIQ(); conference.describeShallow(responseConferenceIQ); diff --git a/src/main/java/org/jitsi/videobridge/health/Health.java b/src/main/java/org/jitsi/videobridge/health/Health.java index 9f65f7fa58..ff86f2d531 100644 --- a/src/main/java/org/jitsi/videobridge/health/Health.java +++ b/src/main/java/org/jitsi/videobridge/health/Health.java @@ -141,6 +141,7 @@ public static void check(Videobridge videobridge) Conference conference = videobridge.createConference( /* focus */ null, + /* name */ null, /* eventadmin */ false); // Fail as quickly as possible. From b42d68dd2308d10d95660990d699eccfe8c5a2f5 Mon Sep 17 00:00:00 2001 From: damencho Date: Tue, 31 May 2016 15:38:16 -0500 Subject: [PATCH 3/4] Adds executors thread name. --- .../eventadmin/callstats/CallStatsConferenceStatsHandler.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/jitsi/videobridge/eventadmin/callstats/CallStatsConferenceStatsHandler.java b/src/main/java/org/jitsi/videobridge/eventadmin/callstats/CallStatsConferenceStatsHandler.java index a2b4f555b8..efa75dcd9c 100644 --- a/src/main/java/org/jitsi/videobridge/eventadmin/callstats/CallStatsConferenceStatsHandler.java +++ b/src/main/java/org/jitsi/videobridge/eventadmin/callstats/CallStatsConferenceStatsHandler.java @@ -71,7 +71,9 @@ class CallStatsConferenceStatsHandler * generating and pushing statistics per conference for every Channel. */ private final RecurringProcessibleExecutor statisticsExecutor - = new RecurringProcessibleExecutor(); + = new RecurringProcessibleExecutor( + CallStatsConferenceStatsHandler.class.getSimpleName() + + "-statisticsExecutor"); /** * List of the processor per conference. Kept in order to stop and From 277f91294bf1cfc066e78877079f1ff38a00650a Mon Sep 17 00:00:00 2001 From: damencho Date: Tue, 31 May 2016 15:39:01 -0500 Subject: [PATCH 4/4] Pulls callstats lib from maven central. --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 977d53c966..befc5f1dd1 100644 --- a/pom.xml +++ b/pom.xml @@ -29,9 +29,9 @@ - callstats - callstats - 0.0.1-20160426.085453-7 + io.callstats + callstats-java-sdk + 3.1.1 com.googlecode.json-simple