Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Overview:

The current cache time for a device profile entry in Redis is 24 hours. If any changes in the device location take place, they are not updated in Redis cache until 24 hours.

Problem Statement:

Changes to the device profile needs to be a push mechanism from the Device Register API call instead of a pull mechanism after 24 hours. A Kafka event needs to be generated and the RedisUpdater Samza job needs to update the cache entry with relevant details.

Design Flow:



Solution:

Steps:

  • The DeviceRegister Service writes the device profile details into a device-profile.log file.

    device-profile.log
    {
    	"statecustomcode": "29",
    	"country": "India",
    	"iso3166statecode": "IN-KA",
    	"device_id": "232455",
    	"uaspec": {
    		"agent": "Chrome",
    		"raw": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.75 Safari/537.36",
    		"system": "Linux",
    		"ver": "68.0.3440.75"
    	},
    	"city": "Bengaluru",
    	"countrycode": "IN",
    	"state": "Karnataka",
    	"statecode": "KA",
    	"updated_date": 1566383863167,
    	"devicespec": {
    		"os": "Android 6.0",
    		"make": "Motorola XT1706"
    	},
    	"districtcustom": "",
    	"fcm_token": "asda",
    	"firstaccess": 1565328282703,
    	"statecustomname": "Karnataka",
    	"producer_id": "dev.sunbird.portal"
    }
  • Logstash will be configured to read from the log file and push the data into a Kafka as a event.
  • RedisUpdater Samza job reads the Kafka event and:
       a) If device_id exists in cache, updates the cache.
       b) If device_id doesn't exist in cache, creates new entry in cache.



  • No labels