int RIniFile::loadRecord() { string line; open(ROPENMODE_READ); while (readLine(line) != RERR_CANNOTREAD) { string key; string value; if (parseLine(line,key,value)) { pair<string,string> recordLine(key,value); _record.push_back(recordLine); } } close(); return _record.size(); }
sai_status_t internal_redis_generic_remove( _In_ sai_object_type_t object_type, _In_ const std::string &serialized_object_id) { SWSS_LOG_ENTER(); std::string str_object_type = sai_serialize_object_type(object_type); std::string key = str_object_type + ":" + serialized_object_id; SWSS_LOG_DEBUG("generic remove key: %s", key.c_str()); if (g_record) { recordLine("r|" + key); } g_asicState->del(key, "remove"); return SAI_STATUS_SUCCESS; }
void Recorder::record(const QByteArray &line) { recordLine(QString::fromUtf8(line)); }
sai_status_t internal_redis_bulk_generic_remove( _In_ sai_object_type_t object_type, _In_ const std::vector<std::string> &serialized_object_ids, _Out_ sai_status_t *object_statuses) /* array */ { SWSS_LOG_ENTER(); std::string str_object_type = sai_serialize_object_type(object_type); std::vector<swss::FieldValueTuple> entries; /* * We are recording all entries and their statuses, but we send to sairedis * only those that succeeded metadata check, since only those will be * executed on syncd, so there is no need with bothering decoding statuses * on syncd side. */ for (size_t idx = 0; idx < serialized_object_ids.size(); ++idx) { std::string str_attr = ""; swss::FieldValueTuple fvtNoStatus(serialized_object_ids[idx], str_attr); entries.push_back(fvtNoStatus); } /* * We are adding number of entries to actually add ':' to be compatible * with previous */ if (g_record) { std::string joined; for (const auto &e: entries) { // ||obj_id|attr=val|attr=val||obj_id|attr=val|attr=val joined += "||" + fvField(e) + "|" + fvValue(e); } /* * Capital 'C' stands for bulk CREATE operation. */ recordLine("C|" + str_object_type + joined); } // key: object_type:count // field: object_id // value: object_attrs std::string key = str_object_type + ":" + std::to_string(entries.size()); if (entries.size()) { g_asicState->set(key, entries, "bulkremove"); } return SAI_STATUS_SUCCESS; }
sai_status_t internal_redis_generic_get_stats( _In_ sai_object_type_t object_type, _In_ const std::string &serialized_object_id, _In_ const sai_enum_metadata_t *stats_enum, _In_ uint32_t count, _In_ const int32_t *counter_id_list, _Out_ uint64_t *counter_list) { SWSS_LOG_ENTER(); std::vector<swss::FieldValueTuple> entry = serialize_counter_id_list( stats_enum, count, counter_id_list); std::string str_object_type = sai_serialize_object_type(object_type); std::string key = str_object_type + ":" + serialized_object_id; SWSS_LOG_DEBUG("generic get stats key: %s, fields: %lu", key.c_str(), entry.size()); if (g_record) { recordLine("m|" + key + "|" + joinFieldValues(entry)); } // get is special, it will not put data // into asic view, only to message queue g_asicState->set(key, entry, "get_stats"); // wait for response swss::Select s; s.addSelectable(g_redisGetConsumer.get()); while (true) { SWSS_LOG_DEBUG("wait for get_stats response"); swss::Selectable *sel; int result = s.select(&sel, GET_RESPONSE_TIMEOUT); if (result == swss::Select::OBJECT) { swss::KeyOpFieldsValuesTuple kco; g_redisGetConsumer->pop(kco); const std::string &op = kfvOp(kco); const std::string &opkey = kfvKey(kco); SWSS_LOG_DEBUG("response: op = %s, key = %s", opkey.c_str(), op.c_str()); if (op != "getresponse") // ignore non response messages { continue; } sai_status_t status = internal_redis_get_stats_process( object_type, count, counter_list, kco); if (g_record) { const auto &str_status = kfvKey(kco); const auto &values = kfvFieldsValues(kco); // first serialized is status recordLine("M|" + str_status + "|" + joinFieldValues(values)); } SWSS_LOG_DEBUG("generic get status: %d", status); return status; } SWSS_LOG_ERROR("generic get failed due to SELECT operation result"); break; } if (g_record) { recordLine("M|SAI_STATUS_FAILURE"); } SWSS_LOG_ERROR("generic get stats failed to get response"); return SAI_STATUS_FAILURE; }
void Recorder::record(char *line) { recordLine(line); }