Class OTAService
- All Implemented Interfaces:
CtxEventListener
,ContextHandleAware
,HandleAware
,Ready
,ReadyListener
targetManifestId
config property. If this differs from
the active manifestId then the service will attempt to download the requested
manifest chain and all referenced artifacts that are not already installed.
Once all artifacts are available, the service will install the software on
the primary node and wait until the activateAndRebootTime
to activate
the software. During this time, the pendingManifestId
property will
be set to the new manifestId. Upon activation time, the primary will activate
the new manifest and reboot. The side effect of this is that all other nodes
in the device will be updated as they reconnect to the primary node.
This service delegates downloading of artifacts to implementations of
OTADownloader
. Each downloader represents an agent that can potentially
fetch a kab given a kab id. This is typically implemented by an agent but it
is possible for a release to be spread across multiple repositories with a
downloader per repository to fetch the associated kabs. This avoids the need
to store every kab in a central location even when using centralized device
management system.
During the OTA process, this service will track detailed information about every referenced artifact, including counters per-artifact, per downloader. This also includes download progress information, which artifacts are already installed, which are staged and so on. This service also handles backoffs on retries, and aborting the OTA process if any artifacts will prevent the OTA from completing, such as artifacts with expired certificates.
If an OTA is in progress or already staged and pending and the
targetManifestId
is changed, the current OTA will be aborted and
any staged artifacts that are not required by the next manifest chain will
be automatically purged. Even if already installed, but waiting for activation
the newer OTA target can garbage collect the already installed, but not yet
activated artifacts.
Rebooting while in the pending state will not result in the new software being run. It is common that a software update may include firmware updates which may take considerable time to apply. To ensure this does not disrupt normal operations, the new software will not be run until activated.
- Version:
- 2023-08-21
-
Method Summary
Modifier and TypeMethodDescriptionvoid
If there is a pending manifest activation, this will activate it and trigger a reboot to boot into the new image.void
active
(OTADownloader downloader) Called when a downloader becomes active to speed up the process of retrying pending downloads.void
Cancel any current download that is in progress.void
cancelDownload
(OTADownloader downloader) Cancel a download being performed by the specified downloader.getDownloadArtifact
(String kabId) Return theOTAArtifact
associated with the specified kab id.Return the collection ofOTAArtifact
s that are currently active.Return the list of paused downloader names.boolean
isPause
(OTADownloader downloader) Return true if the specified downloader is paused.void
pause
(OTADownloader downloader) Pause the specified downloader.void
resume
(OTADownloader downloader) Resume a paused downloader.void
Resume a download that has been stopped due to invalid manifests.void
setTargetManifestId
(String targetManifestId) Set thetargetManifestId
to the specified value.Methods inherited from class com.tccc.kos.commons.core.service.AbstractService
getHandle, getHandlePrefix
Methods inherited from class com.tccc.kos.commons.util.ready.ReadyBean
getReady, onBeanReady, onDependenciesReady
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.tccc.kos.commons.core.context.CtxEventListener
onCtxAutowiringCompleted, onCtxDestroyed, onCtxPhaseCompleted
Methods inherited from interface com.tccc.kos.commons.core.service.handle.HandleAware
addHandleChild, getName, getPath
Methods inherited from interface com.tccc.kos.commons.util.ready.ReadyListener
onDependenciesGroupReady
-
Method Details
-
resumeFromInvalidManifest
public void resumeFromInvalidManifest()Resume a download that has been stopped due to invalid manifests. Don't simply call this if you determine the download stopped due to errors as it will continue to suck up bandwidth and cpu needlessly. Only call this if you think something has changed that will fix the underlying issue.There is no need to call this if you intend to change the
targetManifestId
as that will automatically restart OTA. Similarly, this manifest will be retried on each reboot. Only call this if you actively know of a change and want to start OTA again with the currently configuredtargetManifestId
. -
setTargetManifestId
Set thetargetManifestId
to the specified value. This simply updates the config property which triggers the service accordingly.- Parameters:
targetManifestId
- the new targetManifestId
-
getDownloadArtifacts
Return the collection ofOTAArtifact
s that are currently active. -
getDownloadArtifact
Return theOTAArtifact
associated with the specified kab id.- Parameters:
kabId
- kab id to return the artifact data for
-
active
Called when a downloader becomes active to speed up the process of retrying pending downloads. Without calling this, downloaders are checked during the normal polling cycle which can be subject to long timeouts. There is no need to notify that a downloader is inactive as the service will naturally throttle in that case.- Parameters:
downloader
- the downloader that is active
-
activateAndReboot
public void activateAndReboot()If there is a pending manifest activation, this will activate it and trigger a reboot to boot into the new image. This will cause the release to be propagated to all other nodes in the device. -
cancelCurrentDownload
public void cancelCurrentDownload()Cancel any current download that is in progress. This interrupts the download thread and the downloader should return as a result. If downloaders remain active, the service will schedule another download attempt. -
cancelDownload
Cancel a download being performed by the specified downloader. This does nothing of the downloader is not actively downloading. -
pause
Pause the specified downloader. This will cancel any download the downloader is processing and mark the downloader unavailable until resumed. This does not survive a reboot. -
resume
Resume a paused downloader. This will remove the pause on the downloader and callactive()
with the downloader to have it evaluated immediately. -
isPause
Return true if the specified downloader is paused. -
getPaused
Return the list of paused downloader names.
-