Skip to content

Commit 59c836c

Browse files
committed
Addressed review comments
Signed-off-by: Rashmi <[email protected]>
1 parent 8f7d260 commit 59c836c

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

lte/gateway/c/core/oai/include/s1ap_types.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ enum mme_s1_enb_state_s {
6565
S1AP_SHUTDOWN /// The S1 state is being torn down due to sctp shutdown.
6666
};
6767

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
6970
typedef magma::proto_map_s<uint64_t, magma::lte::oai::UeDescription*>
7071
map_uint64_ue_description_t;
7172

lte/gateway/c/core/oai/tasks/s1ap/s1ap_state.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff 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
}

lte/gateway/c/core/oai/tasks/s1ap/s1ap_state_manager.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff 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

lte/gateway/c/core/oai/tasks/s1ap/s1ap_state_manager.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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();

0 commit comments

Comments
 (0)