This example illustrates various parameters that can be adjusted when using the on-premise device detection engine, and controls when a new data file is sought and when it is loaded by the device detection software.
Three main aspects are demonstrated:
- Update on Start-Up
- Filesystem Watcher
- Daily auto-update
License Key
In order to test this example you will need a 51Degrees Enterprise license which can be purchased from our pricing page.
Data Files
You can find out more about data files, licenses etc. at our FAQ page
Enterprise Data File
Enterprise (fully-featured) data files are typically released by 51Degrees five days a week (Mon-Fri) and on-premise deployments can fetch and download those files automatically. Equally, customers may choose to download the files themselves and move them into place to be detected by the 51Degrees filesystem watcher.
Manual Download
If you prefer to download files yourself, you may do so here:
Lite Data File
Lite data files (free-to-use, limited capabilities, no license key required) are created roughly once a month and cannot be updated using auto-update, they may be downloaded from Github and are included with source distributions of this software.
Update on Start-Up
You can configure the pipeline builder to download an Enterprise data file on start-up.
Pre-Requisites
- a license key
- a file location for the download
- this may be an existing file - which will be overwritten
- or if it does not exist must end in ".hash" and must be in an existing directory
Configuration
- the pipeline must be configured to use a temp file .useOnPremise(dataFilename, true)
- a DataUpdateService must be supplied UpdateCompletionListener completionListener = new UpdateCompletionListener();try (DataUpdateService dataUpdateService = new DataUpdateServiceDefault()) {dataUpdateService.onUpdateComplete(completionListener);....setDataUpdateService(dataUpdateService)
- update on start-up must be specified, which will cause pipeline creation to block until a file is downloaded .setDataUpdateOnStartup(true)
File System Watcher
You can configure the pipeline builder to watch for changes to the currently loaded device detection data file, and to replace the file currently in use with the new one. This is useful, for example, if you wish to download and update the device detection file "manually" - i.e. you would download it then drop it into place with the same path as the currently loaded file. That location is checked periodically (by default every 30 mins) and this frequency can be configured.
Pre-Requisites
- a license key
- the file location of the existing file
Configuration
- the pipeline must be configured to use a temp file .useOnPremise(dataFilename, true)
- a DataUpdateService must be supplied UpdateCompletionListener completionListener = new UpdateCompletionListener();try (DataUpdateService dataUpdateService = new DataUpdateServiceDefault()) {dataUpdateService.onUpdateComplete(completionListener);....setDataUpdateService(dataUpdateService)
- configure the frequency with which the location is checked, in seconds (10 mins as shown) .setUpdatePollingInterval(10*60)
Daily auto-update
Enterprise data files are usually created four times a week. Each data file contains a date for when the next data file is expected. You can configure the pipeline so that it starts looking for a newer data file after that time, by connecting to the 51Degrees distributor to see if an update is available. If one is, then it is downloaded and will replace the existing device detection file, which is currently in use.
Pre-Requisites
- a license key
- the file location of the existing file
Configuration
- the pipeline must be configured to use a temp file .useOnPremise(dataFilename, true)
- a DataUpdateService must be supplied UpdateCompletionListener completionListener = new UpdateCompletionListener();try (DataUpdateService dataUpdateService = new DataUpdateServiceDefault()) {dataUpdateService.onUpdateComplete(completionListener);....setDataUpdateService(dataUpdateService)
- Set the frequency in seconds that the pipeline should check for updates to data files. A recommended polling interval in a production environment is around 30 minutes. .setUpdatePollingInterval(30*60)
- Set the max amount of time in seconds that should be added to the polling interval. This is useful in datacenter applications where multiple instances may be polling for updates at the same time. A recommended ammount in production environments is 600 seconds. .setUpdateRandomisationMax(10*60)
Location
This example is available in full on GitHub.