Skip to content

Commit

Permalink
Update for ktlint 1.0.0 (ktlint-maven-plugin 3.0.0). (#1116)
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanLennox authored Oct 3, 2023
1 parent ea5b27f commit 839b212
Show file tree
Hide file tree
Showing 39 changed files with 272 additions and 305 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[*.{kt,kts}]
max_line_length=120
ktlint_code_style = intellij_idea

# I find trailing commas annoying
ktlint_standard_trailing-comma-on-call-site = disabled
Expand Down
8 changes: 6 additions & 2 deletions jicofo-common/src/main/kotlin/org/jitsi/jicofo/TaskPools.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ class TaskPools {
@JvmStatic
var ioPool: ExecutorService = defaultIoPool

fun resetIoPool() { ioPool = defaultIoPool }
fun resetIoPool() {
ioPool = defaultIoPool
}

private val defaultScheduledPool: ScheduledExecutorService = Executors.newScheduledThreadPool(
3,
Expand All @@ -42,7 +44,9 @@ class TaskPools {
@JvmStatic
var scheduledPool: ScheduledExecutorService = defaultScheduledPool

fun resetScheduledPool() { scheduledPool = defaultScheduledPool }
fun resetScheduledPool() {
scheduledPool = defaultScheduledPool
}

@JvmStatic
fun shutdown() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,15 +272,12 @@ class CodecUtil {
}
}

private fun createPayloadTypeExtension(
id: Int,
name: String,
clockRate: Int
) = PayloadTypePacketExtension().apply {
setId(id)
this.name = name
clockrate = clockRate
}
private fun createPayloadTypeExtension(id: Int, name: String, clockRate: Int) =
PayloadTypePacketExtension().apply {
setId(id)
this.name = name
clockrate = clockRate
}

fun PayloadTypePacketExtension.addVideoExtensions(options: OfferOptions, codecConfig: CodecConfig) {
// a=rtcp-fb:XXX ccm fir
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,7 @@ data class EndpointSourceSet(
*/
@JvmStatic
@Throws(IllegalArgumentException::class)
fun fromJingle(
contents: List<ContentPacketExtension>
): EndpointSourceSet {
fun fromJingle(contents: List<ContentPacketExtension>): EndpointSourceSet {
val sources = mutableSetOf<Source>()
val ssrcGroups = mutableSetOf<SsrcGroup>()

Expand Down Expand Up @@ -237,28 +235,24 @@ private fun ContentPacketExtension.getOrCreateRtpDescription() =
this@getOrCreateRtpDescription.addChildExtension(this)
}

operator fun EndpointSourceSet?.plus(other: EndpointSourceSet?): EndpointSourceSet =
when {
this == null && other == null -> EndpointSourceSet.EMPTY
this == null -> other!!
other == null -> this
else -> EndpointSourceSet(
sources + other.sources,
ssrcGroups + other.ssrcGroups
)
}
operator fun EndpointSourceSet?.plus(other: EndpointSourceSet?): EndpointSourceSet = when {
this == null && other == null -> EndpointSourceSet.EMPTY
this == null -> other!!
other == null -> this
else -> EndpointSourceSet(
sources + other.sources,
ssrcGroups + other.ssrcGroups
)
}

operator fun EndpointSourceSet.minus(other: EndpointSourceSet): EndpointSourceSet =
EndpointSourceSet(sources - other.sources, ssrcGroups - other.ssrcGroups)

operator fun EndpointSourceSet.plus(sources: Set<Source>) =
EndpointSourceSet(this.sources + sources, this.ssrcGroups)
operator fun EndpointSourceSet.plus(sources: Set<Source>) = EndpointSourceSet(this.sources + sources, this.ssrcGroups)

operator fun EndpointSourceSet.plus(source: Source) =
EndpointSourceSet(this.sources + source, this.ssrcGroups)
operator fun EndpointSourceSet.plus(source: Source) = EndpointSourceSet(this.sources + source, this.ssrcGroups)

operator fun EndpointSourceSet.plus(ssrcGroup: SsrcGroup) =
EndpointSourceSet(this.sources, this.ssrcGroups + ssrcGroup)
operator fun EndpointSourceSet.plus(ssrcGroup: SsrcGroup) = EndpointSourceSet(this.sources, this.ssrcGroups + ssrcGroup)

private fun EndpointSourceSet.doStripSimulcast(): EndpointSourceSet {
val groupsToRemove = mutableSetOf<SsrcGroup>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ data class SsrcGroup(
* @throws IllegalArgumentException if the XML extension does not have a valid "semantics" field.
*/
@Throws(IllegalArgumentException::class)
fun fromPacketExtension(
sgpe: SourceGroupPacketExtension,
mediaType: MediaType = MediaType.VIDEO
): SsrcGroup {
fun fromPacketExtension(sgpe: SourceGroupPacketExtension, mediaType: MediaType = MediaType.VIDEO): SsrcGroup {
val semantics = try {
SsrcGroupSemantics.fromString(sgpe.semantics)
} catch (e: NoSuchElementException) {
Expand Down
15 changes: 7 additions & 8 deletions jicofo-common/src/main/kotlin/org/jitsi/jicofo/xmpp/Util.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,13 @@ fun parseJidFromClientProxyJid(
return jid
}

fun XMPPConnection.tryToSendStanza(stanza: Stanza) =
try {
sendStanza(stanza)
} catch (e: SmackException.NotConnectedException) {
logger.error("No connection - unable to send packet: " + stanza.toXML(), e)
} catch (e: InterruptedException) {
logger.error("Failed to send packet: " + stanza.toXML().toString(), e)
}
fun XMPPConnection.tryToSendStanza(stanza: Stanza) = try {
sendStanza(stanza)
} catch (e: SmackException.NotConnectedException) {
logger.error("No connection - unable to send packet: " + stanza.toXML(), e)
} catch (e: InterruptedException) {
logger.error("Failed to send packet: " + stanza.toXML().toString(), e)
}

@Throws(SmackException.NotConnectedException::class)
fun AbstractXMPPConnection.sendIqAndGetResponse(iq: IQ): IQ? = createStanzaCollectorAndSend(iq).let {
Expand Down
24 changes: 12 additions & 12 deletions jicofo-common/src/main/kotlin/org/jitsi/jicofo/xmpp/XmppConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class XmppServiceConnectionConfig : XmppConnectionConfig {
}
}

override val xmppDomain: DomainBareJid? by optionalconfig() {
override val xmppDomain: DomainBareJid? by optionalconfig {
"jicofo.xmpp.service.xmpp-domain".from(newConfig)
}

Expand Down Expand Up @@ -193,12 +193,12 @@ class XmppServiceConnectionConfig : XmppConnectionConfig {

class XmppClientConnectionConfig : XmppConnectionConfig {
override val enabled: Boolean by config {
legacyHostnamePropertyName.from(legacyConfig).convertFrom<String> { true }
LEGACY_HOSTNAME_PROPERTY_NAME.from(legacyConfig).convertFrom<String> { true }
"jicofo.xmpp.client.enabled".from(newConfig)
}

override val hostname: String by config {
legacyHostnamePropertyName.from(legacyConfig)
LEGACY_HOSTNAME_PROPERTY_NAME.from(legacyConfig)
"jicofo.xmpp.client.hostname".from(newConfig)
}

Expand All @@ -211,7 +211,7 @@ class XmppClientConnectionConfig : XmppConnectionConfig {
* This is the domain used for login. Not necessarily the root XMPP domain.
*/
override val domain: DomainBareJid by config {
legacyDomainPropertyName.from(legacyConfig).convertFrom<String> {
LEGACY_DOMAIN_PROPERTY_NAME.from(legacyConfig).convertFrom<String> {
JidCreate.domainBareFrom(it)
}
"jicofo.xmpp.client.domain".from(newConfig).convertFrom<String> {
Expand All @@ -220,7 +220,7 @@ class XmppClientConnectionConfig : XmppConnectionConfig {
}

override val username: Resourcepart by config {
legacyUsernamePropertyName.from(legacyConfig).convertFrom<String> {
LEGACY_USERNAME_PROPERTY_NAME.from(legacyConfig).convertFrom<String> {
Resourcepart.from(it)
}
"jicofo.xmpp.client.username".from(newConfig).convertFrom<String> {
Expand All @@ -235,15 +235,15 @@ class XmppClientConnectionConfig : XmppConnectionConfig {
}

override val password: String? by optionalconfig {
legacyPasswordPropertyName.from(legacyConfig)
LEGACY_PASSWORD_PROPERTY_NAME.from(legacyConfig)
"jicofo.xmpp.client.password".from(newConfig)
}

/**
* This is the top-level domain hosted by the XMPP server (not necessarily the one used for login).
*/
override val xmppDomain: DomainBareJid by config {
legacyXmppDomainPropertyName.from(legacyConfig).convertFrom<String> {
LEGACY_XMPP_DOMAIN_PROPERTY_NAME.from(legacyConfig).convertFrom<String> {
JidCreate.domainBareFrom(it)
}
"jicofo.xmpp.client.xmpp-domain".from(newConfig).convertFrom<String> {
Expand Down Expand Up @@ -285,10 +285,10 @@ class XmppClientConnectionConfig : XmppConnectionConfig {
override val name = "client"

companion object {
const val legacyHostnamePropertyName = "org.jitsi.jicofo.HOSTNAME"
const val legacyDomainPropertyName = "org.jitsi.jicofo.FOCUS_USER_DOMAIN"
const val legacyUsernamePropertyName = "org.jitsi.jicofo.FOCUS_USER_NAME"
const val legacyPasswordPropertyName = "org.jitsi.jicofo.FOCUS_USER_PASSWORD"
const val legacyXmppDomainPropertyName = "org.jitsi.jicofo.XMPP_DOMAIN"
const val LEGACY_HOSTNAME_PROPERTY_NAME = "org.jitsi.jicofo.HOSTNAME"
const val LEGACY_DOMAIN_PROPERTY_NAME = "org.jitsi.jicofo.FOCUS_USER_DOMAIN"
const val LEGACY_USERNAME_PROPERTY_NAME = "org.jitsi.jicofo.FOCUS_USER_NAME"
const val LEGACY_PASSWORD_PROPERTY_NAME = "org.jitsi.jicofo.FOCUS_USER_PASSWORD"
const val LEGACY_XMPP_DOMAIN_PROPERTY_NAME = "org.jitsi.jicofo.XMPP_DOMAIN"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,7 @@ interface JingleRequestHandler {
* @return a [StanzaError] if an error should be returned as response to the original request or null if
* processing was successful.
*/
fun onTransportAccept(
jingleSession: JingleSession,
contents: List<ContentPacketExtension>
): StanzaError? = null
fun onTransportAccept(jingleSession: JingleSession, contents: List<ContentPacketExtension>): StanzaError? = null

/**
* A 'transport-reject' IQ was received.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,11 @@ class Bridge @JvmOverloads internal constructor(
}

private fun getPriority(b: Bridge): Int {
return if (b.isOperational) { if (b.isInGracefulShutdown) 2 else 1 } else 3
return if (b.isOperational) {
if (b.isInGracefulShutdown) 2 else 1
} else {
3
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,9 @@ class BridgeConfig private constructor() {
}
}

private fun createSelectionStrategy(className: String): BridgeSelectionStrategy =
createClassInstance(className)
private fun createSelectionStrategy(className: String): BridgeSelectionStrategy = createClassInstance(className)

private fun createTopologyStrategy(className: String): TopologySelectionStrategy =
createClassInstance(className)
private fun createTopologyStrategy(className: String): TopologySelectionStrategy = createClassInstance(className)

val healthChecksEnabled: Boolean by config {
"org.jitsi.jicofo.HEALTH_CHECK_INTERVAL".from(JitsiConfig.legacyConfig)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,10 +399,7 @@ abstract class BridgeSelectionStrategy {
* @param conferenceBridges the bridges in the conference
* @return `true` if the bridge should be considered overloaded.
*/
private fun isOverloaded(
bridge: Bridge,
conferenceBridges: Map<Bridge, ConferenceBridgeProperties>
): Boolean {
private fun isOverloaded(bridge: Bridge, conferenceBridges: Map<Bridge, ConferenceBridgeProperties>): Boolean {
return bridge.isOverloaded || (
maxParticipantsPerBridge > 0 &&
conferenceBridges.containsKey(bridge) &&
Expand Down
13 changes: 3 additions & 10 deletions jicofo-selector/src/main/kotlin/org/jitsi/jicofo/bridge/Cascade.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ data class CascadeRepair<N : CascadeNode<N, L>, L : CascadeLink>(
val meshId: String
)

fun <N : CascadeNode<N, L>, L : CascadeLink> Cascade<N, L>.containsNode(node: N) =
sessions[node.relayId] === node
fun <N : CascadeNode<N, L>, L : CascadeLink> Cascade<N, L>.containsNode(node: N) = sessions[node.relayId] === node

fun <N : CascadeNode<N, L>, L : CascadeLink> N.hasMesh(meshId: String?): Boolean =
relays.values.any { it.meshId == meshId }
Expand Down Expand Up @@ -191,10 +190,7 @@ private fun <N : CascadeNode<N, L>, L : CascadeLink> Cascade<N, L>.getNodesBehin
}

/* Traverse the graph from a node; for each other node, indicate the node from which it was reached. */
fun <C : Cascade<N, L>, N : CascadeNode<N, L>, L : CascadeLink> C.getPathsFrom(
node: N,
pathFn: (C, N, N?) -> Unit
) {
fun <C : Cascade<N, L>, N : CascadeNode<N, L>, L : CascadeLink> C.getPathsFrom(node: N, pathFn: (C, N, N?) -> Unit) {
pathFn(this, node, null)
node.relays.values.forEach {
getPathsFrom(it, node, pathFn)
Expand Down Expand Up @@ -317,10 +313,7 @@ fun <N : CascadeNode<N, L>, L : CascadeLink> Cascade<N, L>.getDistanceFrom(node:
return Int.MAX_VALUE
}

private fun <N : CascadeNode<N, L>, L : CascadeLink> Cascade<N, L>.getDistanceFrom(
link: L,
pred: (N) -> Boolean
): Int {
private fun <N : CascadeNode<N, L>, L : CascadeLink> Cascade<N, L>.getDistanceFrom(link: L, pred: (N) -> Boolean): Int {
val node = checkNotNull(sessions[link.relayId])

if (pred(node)) return 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ import org.jitsi.jicofo.bridge.colibri.ColibriV2SessionManager

/** Put all bridge nodes into a single mesh, named "0". */
class SingleMeshTopologyStrategy : TopologySelectionStrategy() {
override fun connectNode(
cascade: ColibriV2SessionManager,
node: Colibri2Session
): TopologySelectionResult =
override fun connectNode(cascade: ColibriV2SessionManager, node: Colibri2Session): TopologySelectionResult =
TopologySelectionResult(cascade.sessions.values.firstOrNull(), "0")

override fun repairMesh(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ import org.jitsi.jicofo.bridge.colibri.ColibriV2SessionManager
* Represents a strategy for selecting bridge topologies.
*/
abstract class TopologySelectionStrategy {
abstract fun connectNode(
cascade: ColibriV2SessionManager,
node: Colibri2Session
): TopologySelectionResult
abstract fun connectNode(cascade: ColibriV2SessionManager, node: Colibri2Session): TopologySelectionResult
abstract fun repairMesh(
cascade: ColibriV2SessionManager,
disconnected: Set<Set<Colibri2Session>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,10 @@ class VisitorTopologyStrategy : TopologySelectionStrategy() {
?: existingNodes.first()
}

override fun connectNode(
cascade: ColibriV2SessionManager,
node: Colibri2Session
): TopologySelectionResult {
override fun connectNode(cascade: ColibriV2SessionManager, node: Colibri2Session): TopologySelectionResult {
val existingNodes = cascade.sessions.values
if (!node.visitor) {
return TopologySelectionResult(existingNodes.firstOrNull(), coreMesh)
return TopologySelectionResult(existingNodes.firstOrNull(), CORE_MESH)
}

if (existingNodes.isEmpty()) {
Expand Down Expand Up @@ -96,6 +93,6 @@ class VisitorTopologyStrategy : TopologySelectionStrategy() {
}

companion object {
private const val coreMesh = "0"
private const val CORE_MESH = "0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@ class ColibriV2SessionManager(
return participants.toSet()
}

private fun removeParticipantInfosBySession(bySession: Map<Colibri2Session, List<ParticipantInfo>>):
Set<ParticipantInfo> {
private fun removeParticipantInfosBySession(
bySession: Map<Colibri2Session, List<ParticipantInfo>>
): Set<ParticipantInfo> {
var sessionRemoved = false
val participantsRemoved = mutableSetOf<ParticipantInfo>()
bySession.forEach { (session, sessionParticipantsToRemove) ->
Expand Down Expand Up @@ -229,16 +230,16 @@ class ColibriV2SessionManager(
* Get the [Colibri2Session] for a specific [Bridge]. If one doesn't exist, create it. Returns the session and
* a boolean indicating whether the session was just created (true) or existed (false).
*/
private fun getOrCreateSession(bridge: Bridge, visitor: Boolean):
Pair<Colibri2Session, Boolean> = synchronized(syncRoot) {
var session = sessions[bridge.relayId]
if (session != null) {
return Pair(session, false)
}
private fun getOrCreateSession(bridge: Bridge, visitor: Boolean): Pair<Colibri2Session, Boolean> =
synchronized(syncRoot) {
var session = sessions[bridge.relayId]
if (session != null) {
return Pair(session, false)
}

session = Colibri2Session(this, bridge, visitor, logger)
return Pair(session, true)
}
session = Colibri2Session(this, bridge, visitor, logger)
return Pair(session, true)
}

/** Get the bridge-to-bridge-properties map needed for bridge selection. */
private fun getBridges(): Map<Bridge, ConferenceBridgeProperties> = synchronized(syncRoot) {
Expand Down
Loading

0 comments on commit 839b212

Please sign in to comment.