orbit.client.mesh.NodeLeaseRenewalHandler.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of orbit-client Show documentation
Show all versions of orbit-client Show documentation
Orbit is a system to make building highly scalable realtime services easier.
/*
Copyright (C) 2015 - 2019 Electronic Arts Inc. All rights reserved.
This file is part of the Orbit Project .
See license in LICENSE.
*/
package orbit.client.mesh
import kotlinx.coroutines.launch
import mu.KotlinLogging
import orbit.client.OrbitClient
import orbit.util.concurrent.SupervisorScope
import orbit.util.di.ExternallyConfigured
interface NodeLeaseRenewalFailedHandler {
fun onLeaseRenewalFailed()
}
class RestartOnNodeRenewalFailure(private val orbitClient: OrbitClient, private val supervisorScope: SupervisorScope) :
NodeLeaseRenewalFailedHandler {
val logger = KotlinLogging.logger { }
object RestartOnNodeRenewalFailureSingleton : ExternallyConfigured {
override val instanceType = RestartOnNodeRenewalFailure::class.java
}
override fun onLeaseRenewalFailed() {
supervisorScope.launch {
logger.info { "Beginning Orbit restart..." }
orbitClient.stop().join()
orbitClient.start().join()
logger.info { "Restart complete" }
}
}
}
class NodeLeaseRenewalFailed(msg: String) : Throwable(msg)
© 2015 - 2025 Weber Informatics LLC | Privacy Policy