18#include <unordered_set>
21#include "ClientEndpoint.h"
22#include "UrmSettings.h"
27 static std::mutex handleGenLock;
30 static std::string readFromFile(
const std::string& fileName);
31 static void writeToFile(
const std::string& fileName,
const std::string& value);
32 static void deleteFile(
const std::string& fileName);
33 static void writeSysFsDefaults();
34 static int8_t fileExists(
const std::string& filePath);
35 static int8_t fileWritable(
const std::string& filePath);
36 static std::string getMachineName();
38 static int8_t isNumericString(
const std::string& str);
39 static void cpuMaskToHex(uint64_t mask, std::string& result);
40 static pid_t fetchPid(
const std::string& processName);
41 static int32_t fetchComm(pid_t pid, std::string &comm);
43 static int64_t generateUniqueHandle();
44 static int64_t getCurrentTimeInMilliseconds();
45 static void toLowerCase(std::string& str);
49class FlatBuffEncoder {
53 int32_t mRunningIndex;
59 FlatBuffEncoder& append(T val) {
60 if(this->mRunningIndex == -1 || this->mBuffer ==
nullptr) {
64 if(this->mRunningIndex +
sizeof(T) < REQ_BUFFER_SIZE) {
65 T* tPtr = (T*)(this->mCurPtr);
67 ASSIGN_AND_INCR(tPtr, val);
68 this->mRunningIndex +=
sizeof(T);
69 this->mCurPtr =
reinterpret_cast<char*
>(tPtr);
71 }
catch(
const std::exception& e) {
72 this->mRunningIndex = -1;
76 this->mRunningIndex = REQ_BUFFER_SIZE;
82 FlatBuffEncoder appendString(
const char* valStr);
84 void setBuf(
char* buffer);
88class ConnectionManager {
90 std::shared_ptr<ClientEndpoint> connection;
93 ConnectionManager(std::shared_ptr<ClientEndpoint> connection) {
94 this->connection = connection;
97 ~ConnectionManager() {
98 if(this->connection !=
nullptr) {
99 this->connection->closeConnection();
107 std::unordered_set<int64_t> mDataSet;
108 std::queue<int64_t> mRecencyQueue;
111 MinLRUCache(int32_t maxSize = 30);
113 void insert(int64_t data);
114 int8_t isPresent(int64_t data);