Skip to content

Commit

Permalink
Merge branch 'master' into fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bgrozev committed Sep 4, 2018
2 parents 5e3b912 + aef3b62 commit 6ca96e7
Show file tree
Hide file tree
Showing 6 changed files with 304 additions and 216 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<properties>
<assembly.skipAssembly>true</assembly.skipAssembly>
<exec.mainClass>org.jitsi.videobridge.Main</exec.mainClass>
<jitsi-desktop.version>2.13.f0a8003</jitsi-desktop.version>
<jitsi-desktop.version>2.13.389bc25</jitsi-desktop.version>
<smack.version>4.2.2-b1c107f</smack.version>
</properties>

Expand Down
11 changes: 11 additions & 0 deletions src/main/java/org/jitsi/videobridge/IceUdpTransportManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.jitsi.service.neomedia.*;
import org.jitsi.util.*;
import org.jitsi.util.Logger;
import org.jitsi.videobridge.health.*;
import org.jitsi.videobridge.rest.*;
import org.osgi.framework.*;

Expand Down Expand Up @@ -1795,6 +1796,16 @@ else if (transport == Transport.UDP)
getChannels().forEach(Channel::transportConnected);
}

/**
* The name of the property which controls whether health checks failures
* should be permanent. If this is set to true and the bridge fails its
* health check once, it will not go back to the healthy state.
*/
private static final String PERMANENT_FAILURE_PNAME
= Health.class.getName() + ".PERMANENT_FAILURE";

private static BundleContext bundleContext = null;
private static boolean permanentFailureMode = false;
/**
* @return the {@link Transport} (e.g. UDP or TCP) of the selected pair
* of this {@link IceUdpTransportManager}. If the transport manager is
Expand Down
47 changes: 43 additions & 4 deletions src/main/java/org/jitsi/videobridge/Videobridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,12 @@ public static Collection<Videobridge> getVideobridges(
*/
private VideobridgeExpireThread videobridgeExpireThread;

/**
* The {@link Health} instance responsible for periodically performing
* health checks on this videobridge.
*/
private Health health;

/**
* Initializes a new <tt>Videobridge</tt> instance.
*/
Expand Down Expand Up @@ -1210,12 +1216,13 @@ public IQ handleHealthCheckIQ(HealthCheckIQ healthCheckIQ)

try
{
Health.check(this);
healthCheck();

return IQ.createResultIQ(healthCheckIQ);
}
catch (Exception e)
{
e.printStackTrace();
return
IQUtils.createError(
healthCheckIQ,
Expand All @@ -1224,6 +1231,27 @@ public IQ handleHealthCheckIQ(HealthCheckIQ healthCheckIQ)
}
}

/**
* Checks the health of this {@link Videobridge}. If it is healthy it just
* returns silently, otherwise it throws an exception. Note that this
* method does not perform any tests, but only checks the cached value
* provided by the bridge's {@link Health} instance.
*
* @throws Exception if the videobridge is not healthy.
*/
public void healthCheck()
throws Exception
{
if (health == null)
{
throw new Exception("No health checks running");
}
else
{
health.check();
}
}

/**
* Handles a <tt>GracefulShutdownIQ</tt> stanza which represents a request.
*
Expand Down Expand Up @@ -1309,7 +1337,9 @@ public boolean isXmppApiEnabled()
= ServiceUtils.getService(
getBundleContext(), ConfigurationService.class);

return config.getBoolean(Videobridge.XMPP_API_PNAME, false);
// The XMPP API is disabled by default.
return config != null &&
config.getBoolean(Videobridge.XMPP_API_PNAME, false);
}

/**
Expand Down Expand Up @@ -1382,7 +1412,11 @@ void start(final BundleContext bundleContext)
ConfigurationService.class);

videobridgeExpireThread.start(bundleContext);
Health.start(this);
if (health != null)
{
health.stop();
}
health = new Health(this, cfg);

defaultProcessingOptions
= (cfg == null)
Expand Down Expand Up @@ -1611,9 +1645,14 @@ private void startIce4j(
void stop(BundleContext bundleContext)
throws Exception
{
Health.stop(this);
try
{
if (health != null)
{
health.stop();
health = null;
}

ConfigurationService cfg
= ServiceUtils2.getService(
bundleContext,
Expand Down
Loading

0 comments on commit 6ca96e7

Please sign in to comment.