File tree 4 files changed +30
-3
lines changed 4 files changed +30
-3
lines changed Original file line number Diff line number Diff line change @@ -65,7 +65,8 @@ enum mme_s1_enb_state_s {
65
65
S1AP_SHUTDOWN // / The S1 state is being torn down due to sctp shutdown.
66
66
};
67
67
68
- // Map- Key:uint64_t, Data: pointer to protobuf object, UeDescription
68
+ // Map- Key:comp_s1ap_id of uint64_t, Data: pointer to protobuf object,
69
+ // UeDescription
69
70
typedef magma::proto_map_s<uint64_t , magma::lte::oai::UeDescription*>
70
71
map_uint64_ue_description_t ;
71
72
Original file line number Diff line number Diff line change @@ -155,7 +155,8 @@ void put_s1ap_ue_state(imsi64_t imsi64) {
155
155
oai::UeDescription* ue_ctxt = s1ap_state_get_ue_imsi (imsi64);
156
156
if (ue_ctxt) {
157
157
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);
159
160
}
160
161
}
161
162
}
Original file line number Diff line number Diff line change @@ -167,7 +167,7 @@ status_code_e S1apStateManager::read_ue_state_from_db() {
167
167
return RETURNerror;
168
168
}
169
169
170
- S1apStateConverter::proto_to_ue (ue_proto, ue_context );
170
+ ue_context-> MergeFrom (ue_proto);
171
171
172
172
proto_map_rc_t rc =
173
173
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() {
240
240
return &state_ue_map;
241
241
}
242
242
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
+ }
243
266
} // namespace lte
244
267
} // namespace magma
Original file line number Diff line number Diff line change @@ -99,6 +99,8 @@ class S1apStateManager
99
99
*/
100
100
s1ap_imsi_map_t * get_s1ap_imsi_map ();
101
101
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);
102
104
103
105
private:
104
106
S1apStateManager ();
You can’t perform that action at this time.
0 commit comments