File tree Expand file tree Collapse file tree 3 files changed +28
-2
lines changed
lte/gateway/c/core/oai/tasks/s1ap Expand file tree Collapse file tree 3 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -155,7 +155,8 @@ void put_s1ap_ue_state(imsi64_t imsi64) {
155155 oai::UeDescription* ue_ctxt = s1ap_state_get_ue_imsi (imsi64);
156156 if (ue_ctxt) {
157157 auto imsi_str = S1apStateManager::getInstance ().get_imsi_str (imsi64);
158- S1apStateManager::getInstance ().write_ue_state_to_db (ue_ctxt, imsi_str);
158+ S1apStateManager::getInstance ().s1ap_write_ue_state_to_db (ue_ctxt,
159+ imsi_str);
159160 }
160161 }
161162}
Original file line number Diff line number Diff line change @@ -167,7 +167,7 @@ status_code_e S1apStateManager::read_ue_state_from_db() {
167167 return RETURNerror;
168168 }
169169
170- S1apStateConverter::proto_to_ue (ue_proto, ue_context );
170+ ue_context-> MergeFrom (ue_proto);
171171
172172 proto_map_rc_t rc =
173173 state_ue_map.insert (ue_context->comp_s1ap_id (), ue_context);
@@ -240,5 +240,28 @@ map_uint64_ue_description_t* S1apStateManager::get_s1ap_ue_state() {
240240 return &state_ue_map;
241241}
242242
243+ void S1apStateManager::s1ap_write_ue_state_to_db (
244+ const oai::UeDescription* ue_context, const std::string& imsi_str) {
245+ AssertFatal (
246+ is_initialized,
247+ " StateManager init() function should be called to initialize state" );
248+
249+ std::string proto_str;
250+ redis_client->serialize (*ue_context, proto_str);
251+ std::size_t new_hash = std::hash<std::string>{}(proto_str);
252+ if (new_hash != this ->ue_state_hash [imsi_str]) {
253+ std::string key = IMSI_PREFIX + imsi_str + " :" + task_name;
254+ if (redis_client->write_proto_str (key, proto_str,
255+ ue_state_version[imsi_str]) != RETURNok) {
256+ OAILOG_ERROR (log_task, " Failed to write UE state to db for IMSI %s" ,
257+ imsi_str.c_str ());
258+ return ;
259+ }
260+ this ->ue_state_version [imsi_str]++;
261+ this ->ue_state_hash [imsi_str] = new_hash;
262+ OAILOG_DEBUG (log_task, " Finished writing UE state for IMSI %s" ,
263+ imsi_str.c_str ());
264+ }
265+ }
243266} // namespace lte
244267} // namespace magma
Original file line number Diff line number Diff line change @@ -99,6 +99,8 @@ class S1apStateManager
9999 */
100100 s1ap_imsi_map_t * get_s1ap_imsi_map ();
101101 map_uint64_ue_description_t * get_s1ap_ue_state ();
102+ void s1ap_write_ue_state_to_db (const oai::UeDescription* ue_context,
103+ const std::string& imsi_str);
102104
103105 private:
104106 S1apStateManager ();
You can’t perform that action at this time.
0 commit comments