Skip to content

Commit

Permalink
Remove additional polling while installing updates
Browse files Browse the repository at this point in the history
Upon receiving a new deployment, the client starts to poll the server
every 30 seconds (Hardcoded value)
This commit removes this additional polling.

Signed-off-by: Saeed Rezaee <[email protected]>
  • Loading branch information
SaeedRe committed Jan 15, 2025
1 parent 8617dd5 commit 974c757
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ test {
systemProperty("LOG_HTTP", project.findProperty("logHttp") ?: "false")
systemProperty("LOG_INTERNAL", project.findProperty("logInternal") ?: "false")
systemProperty("BACKOFF_INTERVAL_SECONDS", 45)
systemProperty("FREQUENT_POLLING_WHILE_UPDATING", false)

dependsOn ':virtual-device:test'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ import org.joda.time.Duration
class ActionManager
private constructor(scope: ActorScope) : AbstractActor(scope) {

private val isFrequentPollingEnabled: Boolean by lazy {
System.getProperty("FREQUENT_POLLING_WHILE_UPDATING", null) == "true"
}

private val registry = coroutineContext[HaraClientContext]!!.registry
private val configDataProvider = coroutineContext[HaraClientContext]!!.configDataProvider
private val connectionManager = coroutineContext[CMActor]!!.ref
Expand Down Expand Up @@ -55,17 +59,21 @@ private constructor(scope: ActorScope) : AbstractActor(scope) {
LOG.info(msg.javaClass.simpleName)
become(defaultReceive(state.copy(deployment = null)))
child("deploymentManager")!!.close()
LOG.info("Restore server ping interval")
connectionManager.send(In.SetPing(null))
if (isFrequentPollingEnabled) {
LOG.info("Restore server ping interval")
connectionManager.send(In.SetPing(null))
}
}

msg is Out.DeploymentCancelInfo -> onCancelInfo(msg, state)

msg is Message.UpdateStopped -> {
LOG.info("update stopped")
become(defaultReceive(state.copy(deployment = null)))
LOG.info("Restore server ping interval")
connectionManager.send(In.SetPing(null))
if (isFrequentPollingEnabled) {
LOG.info("Restore server ping interval")
connectionManager.send(In.SetPing(null))
}
}

state.inDeployment && msg is Out.NoAction -> {
Expand Down Expand Up @@ -93,8 +101,10 @@ private constructor(scope: ActorScope) : AbstractActor(scope) {
val deploymentManager = actorOf("deploymentManager") { DeploymentManager.of(it) }
become(defaultReceive(state.copy(deployment = msg)))
deploymentManager.send(msg)
LOG.info("DeploymentInfo msg, decreased ping interval to be reactive on server requests (ping: 30s)")
connectionManager.send(In.SetPing(Duration.standardSeconds(30)))
if (isFrequentPollingEnabled) {
LOG.info("DeploymentInfo msg, decreased ping interval to be reactive on server requests (ping: 30s)")
connectionManager.send(In.SetPing(Duration.standardSeconds(30)))
}
}
}
}
Expand All @@ -107,7 +117,9 @@ private constructor(scope: ActorScope) : AbstractActor(scope) {
CancelFeedbackRequest.Status.Execution.closed,
CancelFeedbackRequest.Status.Result.Finished.success)))
notificationManager.send(MessageListener.Message.State.CancellingUpdate)
connectionManager.send(In.SetPing(null))
if (isFrequentPollingEnabled) {
connectionManager.send(In.SetPing(null))
}
}

!registry.currentUpdateIsCancellable() -> {
Expand All @@ -121,8 +133,10 @@ private constructor(scope: ActorScope) : AbstractActor(scope) {
else -> {
LOG.warn("DeploymentCancelInfo")
child("deploymentManager")!!.send(msg)
LOG.info("Restore server ping interval")
connectionManager.send(In.SetPing(null))
if (isFrequentPollingEnabled) {
LOG.info("Restore server ping interval")
connectionManager.send(In.SetPing(null))
}
}
}
}
Expand Down

0 comments on commit 974c757

Please sign in to comment.